diff options
| author | Raphael <glepnir@neovim.pro> | 2022-08-28 21:38:53 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-28 21:38:53 +0800 |
| commit | cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38 (patch) | |
| tree | da65a472127913dfc668a3be80ee97891f5f20bf /plugin | |
| parent | docs: update server_configurations.md (diff) | |
| download | nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar.gz nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar.bz2 nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar.lz nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar.xz nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.tar.zst nvim-lspconfig-cedfda66a6cdfc32b370b2d4bd5b5c3c9cb4ab38.zip | |
fix: lspstop should close the client by given client (#2101)
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/lspconfig.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 05f42199..48c73fd4 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -101,9 +101,18 @@ end, { api.nvim_create_user_command('LspStop', function(info) local current_buf = vim.api.nvim_get_current_buf() - for _, client in ipairs(get_clients_from_cmd_args(info.args)) do - local filetypes = client.config.filetypes - if filetypes and vim.tbl_contains(filetypes, vim.bo[current_buf].filetype) then + local server_name = string.len(info.args) > 0 and info.args or nil + + if not server_name then + local servers_on_buffer = vim.lsp.get_active_clients { buffer = current_buf } + for _, client in ipairs(servers_on_buffer) do + local filetypes = client.config.filetypes + if filetypes and vim.tbl_contains(filetypes, vim.bo[current_buf].filetype) then + client.stop() + end + end + else + for _, client in ipairs(get_clients_from_cmd_args(server_name)) do client.stop() end end |
