aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer.lua')
-rw-r--r--lua/nvim-lsp-installer.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua
index eae7363e..881db323 100644
--- a/lua/nvim-lsp-installer.lua
+++ b/lua/nvim-lsp-installer.lua
@@ -1,4 +1,5 @@
local notify = require "nvim-lsp-installer.notify"
+local dispatcher = require "nvim-lsp-installer.dispatcher"
local M = {}
@@ -103,4 +104,20 @@ function M.register(server)
_SERVERS[server.name] = server
end
+function M.on_server_ready(cb)
+ dispatcher.register_server_ready_callback(cb)
+ for _, server in pairs(M.get_installed_servers()) do
+ dispatcher.dispatch_server_ready(server)
+ end
+end
+
+-- "Proxy" function for triggering attachment of LSP servers to all buffers (useful when just installed a new server
+-- that wasn't installed at launch)
+function M.lsp_attach_proxy()
+ -- As of writing, if the lspconfig server provides a filetypes setting, it uses FileType as trigger, otherwise it uses BufReadPost
+ local cur_bufnr = vim.fn.bufnr "%"
+ vim.cmd [[ bufdo do FileType | do BufReadPost ]]
+ vim.cmd(("buffer %s"):format(cur_bufnr)) -- restore buffer
+end
+
return M