aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer')
-rw-r--r--lua/nvim-lsp-installer/dispatcher.lua21
-rw-r--r--lua/nvim-lsp-installer/server.lua2
2 files changed, 23 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/dispatcher.lua b/lua/nvim-lsp-installer/dispatcher.lua
new file mode 100644
index 00000000..c8ec34a7
--- /dev/null
+++ b/lua/nvim-lsp-installer/dispatcher.lua
@@ -0,0 +1,21 @@
+local M = {}
+
+local registered_callbacks = {}
+
+function M.dispatch_server_ready(server)
+ for _, callback in pairs(registered_callbacks) do
+ callback(server)
+ end
+end
+
+local idx = 0
+function M.register_server_ready_callback(callback)
+ local key = idx + 1
+ registered_callbacks[("%d"):format(key)] = callback
+ return function ()
+ table.remove(registered_callbacks, key)
+ end
+end
+
+
+return M
diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua
index 8b72ce53..edc80253 100644
--- a/lua/nvim-lsp-installer/server.lua
+++ b/lua/nvim-lsp-installer/server.lua
@@ -1,4 +1,5 @@
local notify = require "nvim-lsp-installer.notify"
+local dispatcher = require "nvim-lsp-installer.dispatcher"
local fs = require "nvim-lsp-installer.fs"
local path = require "nvim-lsp-installer.path"
@@ -83,6 +84,7 @@ function M.Server:install()
pcall(self.uninstall, self)
else
notify(("Successfully installed %s."):format(self.name))
+ dispatcher.dispatch_server_ready(self)
end
end)
end