diff options
-rw-r--r-- | contrib/flake.nix | 2 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 4 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 36 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/protocol.lua | 10 | ||||
-rw-r--r-- | test/functional/ui/searchhl_spec.lua | 5 |
5 files changed, 53 insertions, 4 deletions
diff --git a/contrib/flake.nix b/contrib/flake.nix index a75e584075..86e4b37cfa 100644 --- a/contrib/flake.nix +++ b/contrib/flake.nix @@ -44,7 +44,7 @@ pythonEnv = legacyPkgs.python3; luacheck = legacyPkgs.luaPackages.luacheck; in - neovim-debug.overrideAttrs(oa: { + (neovim-debug.override({doCheck = true;})).overrideAttrs(oa: { cmakeFlags = oa.cmakeFlags ++ [ "-DLUACHECK_PRG=${luacheck}/bin/luacheck" "-DMIN_LOG_LEVEL=0" diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 67e2815715..8e93b188e9 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -118,7 +118,7 @@ FAQ *lsp-faq* < *vim.lsp.callbacks* - Q: What happened to `vim.lsp.callbacks`? - A: After better defining the interface of |lsp-hander|s, we thought it best + A: After better defining the interface of |lsp-handler|s, we thought it best to remove the generic usage of `callbacks` and transform to `handlers`. Due to this, `vim.lsp.callbacks` was renamed to |vim.lsp.handlers|. @@ -257,7 +257,7 @@ For |lsp-notification|, each |lsp-handler| has this signature: > *lsp-handler-configuration* -To configure the behavior of a builtin |lsp-handler|, the conenvience method +To configure the behavior of a builtin |lsp-handler|, the convenient method |vim.lsp.with()| is provided for users. To configure the behavior of |vim.lsp.diagnostic.on_publish_diagnostics()|, diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 359573beb1..fd23a6a547 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -63,8 +63,44 @@ local function progress_callback(_, _, params, client_id) vim.api.nvim_command("doautocmd <nomodeline> User LspProgressUpdate") end +--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress M['$/progress'] = progress_callback +--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_workDoneProgress_create +M['window/workDoneProgress/create'] = function(_, _, params, client_id) + local client = vim.lsp.get_client_by_id(client_id) + local token = params.token -- string or number + if not client then + err_message("LSP[", client_id, "] client has shut down after sending the message") + end + client.messages.progress[token] = {} + return vim.NIL +end + +--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest +M['window/showMessageRequest'] = function(_, _, params) + + local actions = params.actions + print(params.message) + local option_strings = {params.message, "\nRequest Actions:"} + for i, action in ipairs(actions) do + local title = action.title:gsub('\r\n', '\\r\\n') + title = title:gsub('\n', '\\n') + table.insert(option_strings, string.format("%d. %s", i, title)) + end + + -- window/showMessageRequest can return either MessageActionItem[] or null. + local choice = vim.fn.inputlist(option_strings) + if choice < 1 or choice > #actions then + return vim.NIL + else + local action_chosen = actions[choice] + return { + title = action_chosen; + } + end +end + --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction M['textDocument/codeAction'] = function(_, _, actions) if actions == nil or vim.tbl_isempty(actions) then diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index b785d2f586..b2d3d0641c 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -730,7 +730,15 @@ function protocol.make_client_capabilities() experimental = nil; window = { workDoneProgress = true; - } + showMessage = { + messageActionItem = { + additionalPropertiesSupport = false; + }; + }; + showDocument = { + support = false; + }; + }; } end diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index 3bb72303bf..740126df31 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -480,6 +480,11 @@ describe('search highlighting', function() {4:search hit BOTTOM, continuing at TOP} | ]]) + -- check hilights work also in folds + feed("zf4j") + command("%foldopen") + screen:expect_unchanged() + feed_command("call clearmatches()") screen:expect([[ very spec{2:^ial te}xt | |