diff options
author | Maria José Solano <majosolano99@gmail.com> | 2023-09-12 20:51:21 -0700 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2023-09-19 14:47:37 +0100 |
commit | cfd4a9dfaf5fd900264a946ca33c4a4f26f66a49 (patch) | |
tree | 730979e74d568ef3b874b91b86a5c1a20c8c7ba1 /runtime/lua/vim/lsp/handlers.lua | |
parent | c5abf487f19e45fe96a001b28b9e7981f43eed7d (diff) | |
download | rneovim-cfd4a9dfaf5fd900264a946ca33c4a4f26f66a49.tar.gz rneovim-cfd4a9dfaf5fd900264a946ca33c4a4f26f66a49.tar.bz2 rneovim-cfd4a9dfaf5fd900264a946ca33c4a4f26f66a49.zip |
feat(lsp): use treesitter for stylize markdown
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 4ea3dde81c..f8407be159 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -371,15 +371,22 @@ function M.hover(_, result, ctx, config) end return end - local markdown_lines = util.convert_input_to_markdown_lines(result.contents) - markdown_lines = util.trim_empty_lines(markdown_lines) - if vim.tbl_isempty(markdown_lines) then + local format = 'markdown' + local contents ---@type string[] + if type(result.contents) == 'table' and result.contents.kind == 'plaintext' then + format = 'plaintext' + contents = { result.contents.value or '' } + else + contents = util.convert_input_to_markdown_lines(result.contents) + end + contents = util.trim_empty_lines(contents) + if vim.tbl_isempty(contents) then if config.silent ~= true then vim.notify('No information available') end return end - return util.open_floating_preview(markdown_lines, 'markdown', config) + return util.open_floating_preview(contents, format, config) end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover |