[SOLVED]How to get list of all lsp servers installed with nvim-lsp-installer?

Hi! In my init.lua i have these strings:

-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)

local servers = { 'clangd', 'sumneko_lua', 'ccls', 'cmake', 'lemminx', 'rust_analyzer', 'denols', 'gdscript', 'jedi_language_server', 'bashls', }

for _, lsp in ipairs(servers) do
  require 'lspconfig'[lsp].setup {
    on_attach = my_custom_on_attach,
    capabilities = capabilities,
  }
end

Question is: how can I get all installed lsp servers to update their capabilities? Or maybe there is some function, that update capabilities for all servers installed?

Do you want the list of the installed LSPs or attached LSPs, words matter here.

I’m not good at LSP terminology, but installed, i believe. In servers i store the installed servers.

I found the solution. I’m using nvim-lsp-installer. This thing installs all LSP servers in one directory (by default): vim.fn.stdpath("data").."/lsp_servers". So, here is a code to automatically setup all installed servers (tested only on linux):

-- IMPORTANT! FOR WINDOWS READ THE https://stackoverflow.com/a/11130774
local function scandir(directory)
  local i, t, popen = 0, {}, io.popen
  local pfile = popen('ls -a "'..directory..'"')
  if (pfile ~= nil) then
    for filename in pfile:lines() do
      if (filename ~= "." and filename ~= "..") then
        i = i + 1
        t[i] = filename
      end
    end
    pfile:close()
    return t
  end
end

local servers = scandir(vim.fn.stdpath("data").."/lsp_servers" )

for _, lsp in ipairs(servers) do
  require 'lspconfig'[lsp].setup {
    -- your capabilities or custom attach
  }
end

After some research, i found out that there is no simple way to find all installed LSP servers if you don’t use any LSP managers.