From 47aaddfa0dda27d290e83bda3359577d257a7c56 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Mon, 24 Feb 2025 09:20:55 +0100 Subject: 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. --- runtime/lua/vim/lsp/util.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime/lua/vim/lsp/util.lua') 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 -- cgit