Skip to content

Commit

Permalink
fix: lspstop should close the client by given client (neovim#2101)
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir authored Aug 28, 2022
1 parent 7f0dc42 commit cedfda6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions plugin/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cedfda6

Please sign in to comment.