From a39b3109e04c26c4b926460815f655570e27896d Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Mon, 5 Apr 2021 13:52:19 +0300 Subject: Restart clients attached to current buffer if none specified --- lua/lspconfig.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'lua/lspconfig.lua') diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua index 4c9fbda4..ba8660ec 100644 --- a/lua/lspconfig.lua +++ b/lua/lspconfig.lua @@ -45,15 +45,20 @@ function M._root._setup() }; LspRestart = { function(client_id) - if client_id then - local client = vim.lsp.get_client_by_id(tonumber(client_id)) - if client then - local client_name = client.name - client.stop() - vim.defer_fn(function() - require('lspconfig')[client_name].autostart() - end, 500) - end + local clients + + if client_id == nil then + clients = vim.lsp.buf_get_clients(0) + else + clients = {vim.lsp.get_client_by_id(tonumber(client_id))} + end + + for _, client in ipairs(clients) do + local client_name = client.name + client.stop() + vim.defer_fn(function() + require('lspconfig')[client_name].autostart() + end, 500) end end; "-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids"; -- cgit v1.2.3-70-g09d2