diff options
Diffstat (limited to 'lua/lspconfig.lua')
| -rw-r--r-- | lua/lspconfig.lua | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index d2957b7e..fd15f6a0 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -26,15 +26,15 @@ function M._root._setup() LspStart = { function(server_name) if server_name then - require('lspconfig')[server_name].autostart() + if configs[server_name] then + configs[server_name].autostart() + end else local buffer_filetype = vim.bo.filetype - for client_name, config in pairs(configs) do - if config.filetypes then - for _, filetype_match in ipairs(config.filetypes) do - if buffer_filetype == filetype_match then - require('lspconfig')[client_name].autostart() - end + for _, config in pairs(configs) do + for _, filetype_match in ipairs(config.filetypes or {}) do + if buffer_filetype == filetype_match then + config.autostart() end end end @@ -44,39 +44,25 @@ function M._root._setup() description = '`:LspStart` Manually launches a language server.', }, LspStop = { - function(client_id) - if not client_id then - vim.lsp.stop_client(vim.lsp.get_active_clients()) - else - local client = vim.lsp.get_client_by_id(tonumber(client_id)) - if client then - client.stop() - end + function(cmd_args) + for _, client in ipairs(M.util.get_clients_from_cmd_args(cmd_args)) do + client.stop() end end, '-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids', - description = '`:LspStop` Manually stops the given language client.', + description = '`:LspStop` Manually stops the given language client(s).', }, LspRestart = { - function(client_id) - local clients - - if client_id == nil then - clients = vim.lsp.buf_get_clients(0) - else - clients = { vim.lsp.get_client_by_id(tonumber(client_id)) } - end - - for _, client in pairs(clients) do - local client_name = client.name + function(cmd_args) + for _, client in ipairs(M.util.get_clients_from_cmd_args(cmd_args)) do client.stop() vim.defer_fn(function() - require('lspconfig')[client_name].autostart() + configs[client.name].autostart() end, 500) end end, '-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids', - description = '`:LspRestart` Manually restart the given language client.', + description = '`:LspRestart` Manually restart the given language client(s).', }, } |
