From e0a66ca4c541a72b24c6fb5ad9d55be79ce1bc93 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 21 Nov 2023 20:12:17 +0100 Subject: call the new hooks The two new hooks allow to execute user code after certain events. They are called with the language server table as first argument. * initialized_hook is called after the initialized notification was sent. * file_open_hook is called after sending a textDocument/didOpen notification. --- init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index ee86489..015ae60 100644 --- a/init.lua +++ b/init.lua @@ -965,6 +965,11 @@ local function lspc_handle_initialize_response(ls, result) setmetatable(params, {__jsontype = 'object'}) ls_send_notification(ls, 'initialized', params) + if ls.initialized_hook then + lspc.log('executing initialize hook of ' .. ls.name) + ls:initialized_hook() + end + -- According to nvim-lspconfig sendig the lsp server settings shortly after -- initialization is a undocumented convention. -- See https://github.com/neovim/nvim-lspconfig/blob/ed88435764d8b00442e66d39ec3d9c360e560783/CONTRIBUTING.md @@ -1248,6 +1253,10 @@ local function lspc_open(ls, win, file) end) end + if ls.file_open_hook then + lspc.log('Executing file_open_hook of' .. ls.name .. ' and ' .. file.path) + ls:file_open_hook(file) + end end -- Initiate the shutdown of a language server -- cgit v1.2.3