aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
authorkylo252 <59826753+kylo252@users.noreply.github.com>2021-09-04 05:58:38 +0200
committerGitHub <noreply@github.com>2021-09-03 20:58:38 -0700
commit2a7130449b2021c6c23f80f620de38e7547be235 (patch)
treed1527d19b3e5cca4f877812c6d7c27b235165904 /lua/lspconfig/util.lua
parent[docgen] Update CONFIG.md (diff)
downloadnvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar.gz
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar.bz2
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar.lz
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar.xz
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.tar.zst
nvim-lspconfig-2a7130449b2021c6c23f80f620de38e7547be235.zip
fix(ui): gracefully handle nil filetypes (#1217)
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 22e9419b..50791462 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -321,12 +321,15 @@ function M.find_package_json_ancestor(startpath)
end)
end
-function M.get_active_client_by_ft(filetype)
+function M.get_active_clients_list_by_ft(filetype)
local clients = vim.lsp.get_active_clients()
local clients_list = {}
for _, client in pairs(clients) do
- if vim.tbl_contains(client.config.filetypes, filetype) then
- table.insert(clients_list, client.name)
+ local filetypes = client.config.filetypes or {}
+ for _, ft in pairs(filetypes) do
+ if ft == filetype then
+ table.insert(clients_list, client.name)
+ end
end
end
return clients_list
@@ -334,12 +337,12 @@ end
function M.get_other_matching_providers(filetype)
local configs = require 'lspconfig/configs'
- local active_clients_list = M.get_active_client_by_ft(filetype)
+ local active_clients_list = M.get_active_clients_list_by_ft(filetype)
local other_matching_configs = {}
for _, config in pairs(configs) do
if not vim.tbl_contains(active_clients_list, config.name) then
- local filestypes = config.filetypes or {}
- for _, ft in pairs(filestypes) do
+ local filetypes = config.filetypes or {}
+ for _, ft in pairs(filetypes) do
if ft == filetype then
table.insert(other_matching_configs, config)
end