3 --- @param t table|nil list language servers available from Mason for current filetype
4 local list_available_ls
= function(t
)
8 match
= vim
.fn
.input({ prompt
= "Filetype: ", default
= vim
.bo
.filetype
}),
12 if not vim
.bo
[t
.buf
].buftype
== "" then return end
14 if not t
.all
and asked
[t
.match
] then return end
17 if not t
.all
and vim
.tbl_contains(require("lsp.fn.mason_exclude"), t
.match
) then return end
19 local mason_config
= require("mason-lspconfig")
20 local available_servers
= mason_config
.get_available_servers({ filetype
= t
.match
})
22 if #available_servers
== 0 then return end
24 local installed_servers
= mason_config
.get_installed_servers()
25 for a
, available
in ipairs(available_servers
) do
26 if vim
.tbl_contains(require("lsp.fn.mason_exclude"), available
) then return end
27 for _
, installed
in ipairs(installed_servers
) do
28 if available
== installed
then
29 available_servers
[a
] = installed
.. " " .. "✓"
30 if not t
.all
then return end
34 vim
.ui
.select(available_servers
,
35 { prompt
= "Select lsp server to install: " },
37 if item
then vim
.cmd("LspInstall " .. item
) end
41 vim
.api
.nvim_create_user_command("LspAvailable", function() list_available_ls() end, {})
43 return list_available_ls