aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorChristoph Hasse <hassec@users.noreply.github.com>2023-07-25 08:40:13 -0400
committerGitHub <noreply@github.com>2023-07-25 05:40:13 -0700
commit20c331915f4e317c615c7cfea469a9baedd2e4f7 (patch)
tree630a1a0b66f62efd97588296023d432173644062 /runtime/lua/vim/lsp/util.lua
parent898384ac6900aa5cb8ef84d53ad586ecf424a25c (diff)
downloadrneovim-20c331915f4e317c615c7cfea469a9baedd2e4f7.tar.gz
rneovim-20c331915f4e317c615c7cfea469a9baedd2e4f7.tar.bz2
rneovim-20c331915f4e317c615c7cfea469a9baedd2e4f7.zip
fix(lsp): SignatureHelp docstring is not escaped #16702
Problem: Nvim LSP client always treats signature.documentation as markdown, even if the server returns a plain string. Per https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#signatureInformation in a SignatureInformation response, the documentation field can be either "string" or "MarkupContent". Solution: If signature.documentation is a string, treat it as "plaintext". Closes #16563
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua6
1 files changed, 6 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 4d3071fd68..738e23ff28 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1002,6 +1002,12 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers
end
list_extend(contents, split(label, '\n', { plain = true }))
if signature.documentation then
+ -- if LSP returns plain string, we treat it as plaintext. This avoids
+ -- special characters like underscore or similar from being interpreted
+ -- as markdown font modifiers
+ if type(signature.documentation) == 'string' then
+ signature.documentation = { kind = 'plaintext', value = signature.documentation }
+ end
M.convert_input_to_markdown_lines(signature.documentation, contents)
end
if signature.parameters and #signature.parameters > 0 then