diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-11-01 03:14:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-01 03:14:59 -0700 |
commit | 519d8deb08f369c559e7cbd61627c56db88623f1 (patch) | |
tree | f215ba8c220931f08bd2b67660680316df2fea49 /runtime/lua/vim/lsp.lua | |
parent | 7ae86c1d4caffec57e2d4d44e40a9feba91d96dd (diff) | |
download | rneovim-519d8deb08f369c559e7cbd61627c56db88623f1.tar.gz rneovim-519d8deb08f369c559e7cbd61627c56db88623f1.tar.bz2 rneovim-519d8deb08f369c559e7cbd61627c56db88623f1.zip |
feat(lsp): add per-client commands (#16101)
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index a77dc8a13f..01e801415a 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -239,6 +239,7 @@ local function validate_client_config(config) on_exit = { config.on_exit, "f", true }; on_init = { config.on_init, "f", true }; settings = { config.settings, "t", true }; + commands = { config.commands, 't', true }; before_init = { config.before_init, "f", true }; offset_encoding = { config.offset_encoding, "s", true }; flags = { config.flags, "t", true }; @@ -590,6 +591,11 @@ end --- returned to the language server if requested via `workspace/configuration`. --- Keys are case-sensitive. --- +---@param commands table Table that maps string of clientside commands to user-defined functions. +--- Commands passed to start_client take precedence over the global command registry. Each key +--- must be a unique comand name, and the value is a function which is called if any LSP action +--- (code action, code lenses, ...) triggers the command. +--- ---@param init_options Values to pass in the initialization request --- as `initializationOptions`. See `initialize` in the LSP spec. --- @@ -772,8 +778,9 @@ function lsp.start_client(config) attached_buffers = {}; handlers = handlers; - requests = {}; + commands = config.commands or {}; + requests = {}; -- for $/progress report messages = { name = name, messages = {}, progress = {}, status = {} }; } |