From 23c72d4da3656af72aba5950e5ad7c85dbca71f2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 7 Dec 2022 20:21:21 +0800 Subject: feat: support force stop language server (#2294) * feat: support force stop language server * feat: use vim syntax * feat: update doc --- plugin/lspconfig.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'plugin') diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 5526264c..d8c77493 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -117,19 +117,28 @@ end, { api.nvim_create_user_command('LspStop', function(info) local current_buf = vim.api.nvim_get_current_buf() - local server_name = string.len(info.args) > 0 and info.args or nil + local server_name, force + local arguments = vim.split(info.args, '%s') + for _, v in pairs(arguments) do + if v == '++force' then + force = true + end + if v:find '%(' then + server_name = v + end + end if not server_name then local servers_on_buffer = 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() + client.stop(force) end end else for _, client in ipairs(get_clients_from_cmd_args(server_name)) do - client.stop() + client.stop(force) end end end, { -- cgit v1.2.3-70-g09d2