diff options
| author | Markus Koller <markus@snafu.ch> | 2025-06-10 16:14:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-10 07:14:18 -0700 |
| commit | 77d3fdfb3554632c7a3b101ded643d422de7626f (patch) | |
| tree | 85b81e2071ee8cdd74b0ff5c871584e892bb55e5 /plugin/lspconfig.lua | |
| parent | fix: support :LspStart/LspStop without arguments #3890 (diff) | |
| download | nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar.gz nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar.bz2 nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar.lz nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar.xz nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.tar.zst nvim-lspconfig-77d3fdfb3554632c7a3b101ded643d422de7626f.zip | |
fix: support :LspRestart without arguments #3895v2.3.0
Problem:
After the refactoring in e4d1c8b for Neovim 0.11.2 this command now
requires an argument.
Solution:
Restore the previous behaviour where `:LspRestart` defaults to
restarting all active servers.
Diffstat (limited to 'plugin/lspconfig.lua')
| -rw-r--r-- | plugin/lspconfig.lua | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index a5cd4715..7cde1386 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -120,9 +120,21 @@ if vim.version.ge(vim.version(), { 0, 11, 2 }) then }) api.nvim_create_user_command('LspRestart', function(info) - for _, name in ipairs(info.fargs) do + local clients = info.fargs + + -- Default to restarting all active servers + if #clients == 0 then + clients = vim + .iter(vim.lsp.get_clients()) + :map(function(client) + return client.name + end) + :totable() + end + + for _, name in ipairs(clients) do if vim.lsp.config[name] == nil then - vim.notify(("Invalid server name '%s'"):format(info.args)) + vim.notify(("Invalid server name '%s'"):format(name)) else vim.lsp.enable(name, false) end @@ -130,7 +142,7 @@ if vim.version.ge(vim.version(), { 0, 11, 2 }) then local timer = assert(vim.uv.new_timer()) timer:start(500, 0, function() - for _, name in ipairs(info.fargs) do + for _, name in ipairs(clients) do vim.schedule_wrap(function(x) vim.lsp.enable(x) end)(name) @@ -138,7 +150,7 @@ if vim.version.ge(vim.version(), { 0, 11, 2 }) then end) end, { desc = 'Restart the given client(s)', - nargs = '+', + nargs = '*', complete = complete_client, }) |
