aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-04-19 17:35:58 -0700
committerGitHub <noreply@github.com>2021-04-19 17:35:58 -0700
commit26bd5a58dff1b920757f3bc010c2e8f9dbfc9d40 (patch)
treedff2bb76f2fdcfb2567354b982e399179c01fcfb /runtime/lua/vim/lsp.lua
parent66f9dd3c6e2e2968e4534ac0eacb7695f97c11b1 (diff)
parent2e6c09838f88803f31d229002715628639631897 (diff)
downloadrneovim-26bd5a58dff1b920757f3bc010c2e8f9dbfc9d40.tar.gz
rneovim-26bd5a58dff1b920757f3bc010c2e8f9dbfc9d40.tar.bz2
rneovim-26bd5a58dff1b920757f3bc010c2e8f9dbfc9d40.zip
Merge pull request #14180 from oberblastmeister/lsp_exit_perf
fix slow closing of lsp clients when exiting vim
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua33
1 files changed, 30 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index cb3d4bbe9f..d45827b0d7 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -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()")