aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2025-02-24 09:20:55 +0100
committerChristian Clason <ch.clason+github@icloud.com>2025-02-25 14:26:58 +0100
commit47aaddfa0dda27d290e83bda3359577d257a7c56 (patch)
tree81a0f6fa57f25a58cc6795e06b0bad9ab78f4b85 /runtime/lua/vim/lsp/util.lua
parent8ba047e33fe3a10765c593c810d54b5e3bb906e9 (diff)
downloadrneovim-47aaddfa0dda27d290e83bda3359577d257a7c56.tar.gz
rneovim-47aaddfa0dda27d290e83bda3359577d257a7c56.tar.bz2
rneovim-47aaddfa0dda27d290e83bda3359577d257a7c56.zip
fix(lsp): resize hover window for concealed lines
Problem: Height of a (markdown) `vim.lsp.util.open_floating_preview()` window can be reduced to account for concealed lines (after #31324). Solution: Set the window height to the text height of the preview window. Set 'concealcursor' to avoid unconcealing the cursorline when entering the hover window.
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 905b9822ba..cacf7824c4 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1649,8 +1649,14 @@ function M.open_floating_preview(contents, syntax, opts)
if do_stylize then
vim.wo[floating_winnr].conceallevel = 2
+ vim.wo[floating_winnr].concealcursor = 'n'
vim.bo[floating_bufnr].filetype = 'markdown'
vim.treesitter.start(floating_bufnr)
+ if not opts.height then
+ -- Reduce window height if TS highlighter conceals code block backticks.
+ local conceal_height = api.nvim_win_text_height(floating_winnr, {}).all
+ api.nvim_win_set_height(floating_winnr, conceal_height)
+ end
end
return floating_bufnr, floating_winnr