mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #14180 from oberblastmeister/lsp_exit_perf
fix slow closing of lsp clients when exiting vim
This commit is contained in:
@@ -1179,11 +1179,38 @@ function lsp._vim_exit_handler()
|
||||
client.stop()
|
||||
end
|
||||
|
||||
if not vim.wait(500, function() return tbl_isempty(active_clients) end, 50) then
|
||||
for _, client in pairs(active_clients) do
|
||||
client.stop(true)
|
||||
local function wait_async(timeout, ms, predicate, cb)
|
||||
local timer = uv.new_timer()
|
||||
local time = 0
|
||||
|
||||
local function done(in_time)
|
||||
timer:stop()
|
||||
timer:close()
|
||||
cb(in_time)
|
||||
end
|
||||
|
||||
timer:start(0, ms, function()
|
||||
if predicate() == true then
|
||||
done(true)
|
||||
return
|
||||
end
|
||||
|
||||
if time == timeout then
|
||||
done(false)
|
||||
return
|
||||
end
|
||||
|
||||
time = time + ms
|
||||
end)
|
||||
end
|
||||
|
||||
wait_async(500, 50, function() return tbl_isempty(active_clients) end, function(in_time)
|
||||
if not in_time then
|
||||
for _, client in pairs(active_clients) do
|
||||
client.stop(true)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
nvim_command("autocmd VimLeavePre * lua vim.lsp._vim_exit_handler()")
|
||||
|
Reference in New Issue
Block a user