aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorGuilherme Soares <48023091+guilhas07@users.noreply.github.com>2025-01-20 13:00:13 +0000
committerGitHub <noreply@github.com>2025-01-20 05:00:13 -0800
commit8a236c242a76825a6a9266feda45794c7328c807 (patch)
tree2735ed6e22993dbd26290930ada8ac2aa0749fe8 /runtime/lua/vim/lsp/util.lua
parent27c88069538bf64dace1ed39512d914e88615ac1 (diff)
downloadrneovim-8a236c242a76825a6a9266feda45794c7328c807.tar.gz
rneovim-8a236c242a76825a6a9266feda45794c7328c807.tar.bz2
rneovim-8a236c242a76825a6a9266feda45794c7328c807.zip
fix(lsp): set floating window filetype after setup #32112
Problem: The filetype for the floating window buffer is being set before its context is fully initialized. This results in `FileType` events not receiving the correct context. Solution: Set the filetype after the floating preview window and its buffer variables are fully configured to ensure proper context is provided.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 4e0adf3366..b9b53d36a8 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1568,8 +1568,6 @@ function M.open_floating_preview(contents, syntax, opts)
if do_stylize then
local width = M._make_floating_popup_size(contents, opts)
contents = M._normalize_markdown(contents, { width = width })
- vim.bo[floating_bufnr].filetype = 'markdown'
- vim.treesitter.start(floating_bufnr)
else
-- Clean up input: trim empty lines
contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true })
@@ -1635,9 +1633,6 @@ function M.open_floating_preview(contents, syntax, opts)
})
end
- if do_stylize then
- vim.wo[floating_winnr].conceallevel = 2
- end
vim.wo[floating_winnr].foldenable = false -- Disable folding.
vim.wo[floating_winnr].wrap = opts.wrap -- Soft wrapping.
vim.wo[floating_winnr].breakindent = true -- Slightly better list presentation.
@@ -1646,6 +1641,12 @@ function M.open_floating_preview(contents, syntax, opts)
vim.bo[floating_bufnr].modifiable = false
vim.bo[floating_bufnr].bufhidden = 'wipe'
+ if do_stylize then
+ vim.wo[floating_winnr].conceallevel = 2
+ vim.bo[floating_bufnr].filetype = 'markdown'
+ vim.treesitter.start(floating_bufnr)
+ end
+
return floating_bufnr, floating_winnr
end