aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/async.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-08-22 12:12:06 +0100
committerLewis Russell <lewis6991@gmail.com>2023-08-22 13:22:07 +0100
commit204f08ea407e4b3b7ad272287e1821f47e52d4b3 (patch)
tree738debbf786be2ecf67dbe203f642f65bd6c6199 /lua/lspconfig/async.lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar.gz
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar.bz2
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar.lz
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar.xz
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.tar.zst
nvim-lspconfig-204f08ea407e4b3b7ad272287e1821f47e52d4b3.zip
refactor: move manager to separate module
- Move manager logic to own module - Move async logic to own module - Improve type annotations
Diffstat (limited to 'lua/lspconfig/async.lua')
-rw-r--r--lua/lspconfig/async.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lua/lspconfig/async.lua b/lua/lspconfig/async.lua
new file mode 100644
index 00000000..8a160c82
--- /dev/null
+++ b/lua/lspconfig/async.lua
@@ -0,0 +1,22 @@
+local M = {}
+
+function M.run(func)
+ coroutine.resume(coroutine.create(function()
+ local status, err = pcall(func)
+ if not status then
+ vim.notify(('[lspconfig] unhandled error: %s'):format(tostring(err)), vim.log.levels.WARN)
+ end
+ end))
+end
+
+function M.reenter()
+ if vim.in_fast_event() then
+ local co = assert(coroutine.running())
+ vim.schedule(function()
+ coroutine.resume(co)
+ end)
+ coroutine.yield()
+ end
+end
+
+return M