aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/handlers.lua
diff options
context:
space:
mode:
authorMaria José Solano <majosolano99@gmail.com>2024-10-15 02:36:04 -0700
committerGitHub <noreply@github.com>2024-10-15 02:36:04 -0700
commite0a5c3bb581752569df4490b48cb54e7c1ab0613 (patch)
tree97e6936d443d2cb7f4da14a04a285ac16034f1dd /runtime/lua/vim/lsp/handlers.lua
parent74a161477266b3c131076ac572c5d4b577593ec4 (diff)
downloadrneovim-e0a5c3bb581752569df4490b48cb54e7c1ab0613.tar.gz
rneovim-e0a5c3bb581752569df4490b48cb54e7c1ab0613.tar.bz2
rneovim-e0a5c3bb581752569df4490b48cb54e7c1ab0613.zip
fix(lsp): handle multiline signature help labels #30460
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r--runtime/lua/vim/lsp/handlers.lua15
1 files changed, 11 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 44548fec92..8e538242d9 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -462,6 +462,8 @@ M[ms.textDocument_typeDefinition] = location_handler
--- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation
M[ms.textDocument_implementation] = location_handler
+local sig_help_ns = api.nvim_create_namespace('vim_lsp_signature_help')
+
--- |lsp-handler| for the method "textDocument/signatureHelp".
---
--- The active parameter is highlighted with |hl-LspSignatureActiveParameter|.
@@ -476,7 +478,7 @@ M[ms.textDocument_implementation] = location_handler
--- ```
---
---@param _ lsp.ResponseError?
----@param result lsp.SignatureHelp Response from the language server
+---@param result lsp.SignatureHelp? Response from the language server
---@param ctx lsp.HandlerContext Client context
---@param config table Configuration table.
--- - border: (default=nil)
@@ -509,10 +511,15 @@ function M.signature_help(_, result, ctx, config)
return
end
local fbuf, fwin = util.open_floating_preview(lines, 'markdown', config)
+ -- Highlight the active parameter.
if hl then
- -- Highlight the second line if the signature is wrapped in a Markdown code block.
- local line = vim.startswith(lines[1], '```') and 1 or 0
- api.nvim_buf_add_highlight(fbuf, -1, 'LspSignatureActiveParameter', line, unpack(hl))
+ vim.highlight.range(
+ fbuf,
+ sig_help_ns,
+ 'LspSignatureActiveParameter',
+ { hl[1], hl[2] },
+ { hl[3], hl[4] }
+ )
end
return fbuf, fwin
end