aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lua/lspconfig.lua8
-rw-r--r--test/lspconfig_spec.lua14
2 files changed, 21 insertions, 1 deletions
diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua
index 779ec426..b46ef65d 100644
--- a/lua/lspconfig.lua
+++ b/lua/lspconfig.lua
@@ -7,7 +7,13 @@ local M = {
M._root = {}
function M.available_servers()
- return vim.tbl_keys(configs)
+ local servers = {}
+ for server, config in pairs(configs) do
+ if config.manager ~= nil then
+ table.insert(servers, server)
+ end
+ end
+ return servers
end
-- Called from plugin/lspconfig.vim because it requires knowing that the last
diff --git a/test/lspconfig_spec.lua b/test/lspconfig_spec.lua
index 163bf887..8fc117c5 100644
--- a/test/lspconfig_spec.lua
+++ b/test/lspconfig_spec.lua
@@ -251,5 +251,19 @@ describe('lspconfig', function()
}
)
end)
+
+ it("excludes indexed server configs that haven't been set up", function()
+ eq(
+ exec_lua [[
+ local lspconfig = require("lspconfig")
+ local actual = nil
+ local _ = lspconfig.sumneko_lua
+ local _ = lspconfig.tsserver
+ lspconfig.rust_analyzer.setup {}
+ return lspconfig.available_servers()
+ ]],
+ { 'rust_analyzer' }
+ )
+ end)
end)
end)