aboutsummaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-12-05 18:32:32 +0800
committerGitHub <noreply@github.com>2022-12-05 18:32:32 +0800
commite96f639b608a596aa1ea8abb7e5b799cedbb0b1a (patch)
tree24cfb6556a7633c3a54c66f22ab3477c95a56368 /plugin
parentfix(lsp): don't spawn new lsp client if already persent (#2287) (diff)
downloadnvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar.gz
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar.bz2
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar.lz
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar.xz
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.tar.zst
nvim-lspconfig-e96f639b608a596aa1ea8abb7e5b799cedbb0b1a.zip
fix: restart client after client is stopped after LspRestart (#2290)
* fix: restart client after client is stopped after LspRestart * fix: format
Diffstat (limited to 'plugin')
-rw-r--r--plugin/lspconfig.lua22
1 files changed, 19 insertions, 3 deletions
diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua
index 0877cbd7..5526264c 100644
--- a/plugin/lspconfig.lua
+++ b/plugin/lspconfig.lua
@@ -87,12 +87,28 @@ end, {
})
api.nvim_create_user_command('LspRestart', function(info)
+ local detach_clients = {}
for _, client in ipairs(get_clients_from_cmd_args(info.args)) do
client.stop()
- vim.defer_fn(function()
- require('lspconfig.configs')[client.name].launch()
- end, 500)
+ detach_clients[client.name] = client
end
+ local timer = vim.loop.new_timer()
+ timer:start(
+ 500,
+ 100,
+ vim.schedule_wrap(function()
+ for client_name, client in pairs(detach_clients) do
+ if client.is_stopped() then
+ require('lspconfig.configs')[client_name].launch()
+ detach_clients[client_name] = nil
+ end
+ end
+
+ if next(detach_clients) == nil and not timer:is_closing() then
+ timer:close()
+ end
+ end)
+ )
end, {
desc = 'Manually restart the given language client(s)',
nargs = '?',