From 295c646488d5baa63c6c4da68fe61171b9257375 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jun 2023 21:02:33 +0800 Subject: fix(command): LspRestart should attached before buffers (#2674) --- plugin/lspconfig.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugin') diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua index 5afd0895..b2e41461 100644 --- a/plugin/lspconfig.lua +++ b/plugin/lspconfig.lua @@ -91,7 +91,7 @@ api.nvim_create_user_command('LspRestart', function(info) for _, client in ipairs(get_clients_from_cmd_args(info.args)) do client.stop() if #client.attached_buffers > 0 then - detach_clients[client.name] = client + detach_clients[client.name] = { client, client.attached_buffers } end end local timer = vim.loop.new_timer() @@ -99,9 +99,12 @@ api.nvim_create_user_command('LspRestart', function(info) 500, 100, vim.schedule_wrap(function() - for client_name, client in pairs(detach_clients) do + for client_name, tuple in pairs(detach_clients) do + local client, attached_buffers = unpack(tuple) if client.is_stopped() then - require('lspconfig.configs')[client_name].launch() + for buf in pairs(attached_buffers) do + require('lspconfig.configs')[client_name].launch(buf) + end detach_clients[client_name] = nil end end -- cgit v1.2.3-70-g09d2