diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | init.lua | 12 | ||||
| -rw-r--r-- | lspc.lua | 5 |
4 files changed, 16 insertions, 14 deletions
@@ -1,6 +1,6 @@ .PHONY: check format check-luacheck check-format -LUA_FILES := $(shell find -name "*.lua" -not -path "./json.lua") +LUA_FILES := $(shell find -name "*.lua" -not -path "./json.lua" -and -not -path "./tests/*") TEST_FILES := $(shell find -name "*_test.lua") @@ -161,8 +161,6 @@ Additional fields are: * `settings` - a table of arbitrary possibly nested data. It is sent in a `workspace/didChangeConfiguration` to the language server after initialization. It is also used to lookup configuration for the `workspace/configuratio` method call. * `init_options` - table of arbitrary possibly nested data. It will be sent to the server as `initializationOptions` in the parameters of the `initialize` method call. * `formatting_options` - table of configuration data as found in [the LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting). `tabSize` and `insertSpaces` are required. -* `initialized_hook` - function called after sending the `initialized` notification. The first parameter is the language server. -* `file_open_hook` - function called after sending the `textDocument/didOpen` notification. The first parameter is the language server. **Example:** The language server configuration entry in the `ls_map` for `lua-language-server` @@ -179,6 +177,15 @@ ls_map.lua = { Language servers configured in `vis-lspc` can be found in `supported_servers.lua`. +### Events + +vis-lspc extends vis' event system with its own set of events: + +* `lspc.event.LS_INITIALIZED` - emitted after sending the `initialized` notification +* `lspc.event.LS_DID_OPEN` - emitted after sending the `textDocument/didOpen` notification + +All events receive the language server as first argument. + ### Extensibility The returned module table also includes functions you can use in your own `vis` @@ -965,10 +965,7 @@ 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 + vis.events.emit(lspc.events.LS_INITIALIZED, ls) -- According to nvim-lspconfig sendig the lsp server settings shortly after -- initialization is a undocumented convention. @@ -978,8 +975,6 @@ local function lspc_handle_initialize_response(ls, result) settings = ls.settings, }) end - - vis.events.emit(lspc.events.LS_INITIALIZED, ls) end -- method response dispatcher @@ -1255,10 +1250,7 @@ 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 + vis.events.emit(lspc.events.LS_DID_OPEN, ls) end -- Initiate the shutdown of a language server @@ -58,7 +58,10 @@ local lspc = { show_message = 'message', -- events - events = {LS_INITIALIZED = 'LspcEvent::LS_INITIALIZED'}, + events = { + LS_INITIALIZED = 'LspcEvent::LS_INITIALIZED', + LS_DID_OPEN = 'LspcEvent::LS_DID_OPEN', + }, } -- |
