diff options
| -rw-r--r-- | lua/lspconfig/util.lua | 16 | ||||
| -rw-r--r-- | plugin/lspconfig.lua | 4 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index f7614924..b38b8ec6 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -438,8 +438,22 @@ function M.get_other_matching_providers(filetype) return other_matching_configs end +function M.get_config_by_ft(filetype) + local configs = require 'lspconfig.configs' + local matching_configs = {} + for _, config in pairs(configs) do + local filetypes = config.filetypes or {} + for _, ft in pairs(filetypes) do + if ft == filetype then + table.insert(matching_configs, config) + end + end + end + return matching_configs +end + function M.get_active_client_by_name(bufnr, servername) - for _, client in pairs(vim.lsp.buf_get_clients(bufnr)) do + for _, client in pairs(vim.lsp.get_active_clients { bufnr = bufnr }) do if client.name == servername then return client end diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 3ecde2f1..42ae0ff5 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -76,8 +76,8 @@ api.nvim_create_user_command('LspStart', function(info) end end - local other_matching_configs = require('lspconfig.util').get_other_matching_providers(vim.bo.filetype) - for _, config in ipairs(other_matching_configs) do + local matching_configs = require('lspconfig.util').get_config_by_ft(vim.bo.filetype) + for _, config in ipairs(matching_configs) do config.launch() end end, { |
