diff options
| author | glepnir <glephunter@gmail.com> | 2024-10-14 15:17:15 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-14 15:17:15 +0800 |
| commit | b1de227da4ca6baf6ba865bec75917e4b4053844 (patch) | |
| tree | 61763a88b85a2d6d8bd1bc027bf2cf0aa2830f94 /plugin/lspconfig.lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar.gz nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar.bz2 nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar.lz nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar.xz nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.tar.zst nvim-lspconfig-b1de227da4ca6baf6ba865bec75917e4b4053844.zip | |
fix: command LspStop can receive server name (#3367)
Diffstat (limited to 'plugin/lspconfig.lua')
| -rw-r--r-- | plugin/lspconfig.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index fd4631d1..e687e330 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -110,23 +110,31 @@ end, { api.nvim_create_user_command('LspStop', function(info) local current_buf = vim.api.nvim_get_current_buf() - local server_id, force + local server_id, force, server_name local arguments = vim.split(info.args, '%s') for _, v in pairs(arguments) do if v == '++force' then force = true elseif v:find '^[0-9]+$' then server_id = v + else + server_name = v end end if not server_id then local servers_on_buffer = require('lspconfig.util').get_lsp_clients { bufnr = current_buf } + local found = false for _, client in ipairs(servers_on_buffer) do - if client.attached_buffers[current_buf] then + if client.attached_buffers[current_buf] and (server_name and (server_name == client.config.name) or true) then client.stop(force) + found = true end end + + if server_name and not found then + vim.notify(('nvim-lspconfig: config "%s" not found'):format(server_name), vim.log.levels.WARN) + end else for _, client in ipairs(get_clients_from_cmd_args(server_id)) do client.stop(force) |
