From d230c502db193ee81da116386d1cdff5c5ac3e37 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. successfully initialized and when a new file is opened by the editor. --- init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 90e7ddc..befc0dc 100644 --- a/init.lua +++ b/init.lua @@ -889,6 +889,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 @@ -1175,6 +1180,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