mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
27c8806953
commit
8a236c242a
@ -1568,8 +1568,6 @@ function M.open_floating_preview(contents, syntax, opts)
|
|||||||
if do_stylize then
|
if do_stylize then
|
||||||
local width = M._make_floating_popup_size(contents, opts)
|
local width = M._make_floating_popup_size(contents, opts)
|
||||||
contents = M._normalize_markdown(contents, { width = width })
|
contents = M._normalize_markdown(contents, { width = width })
|
||||||
vim.bo[floating_bufnr].filetype = 'markdown'
|
|
||||||
vim.treesitter.start(floating_bufnr)
|
|
||||||
else
|
else
|
||||||
-- Clean up input: trim empty lines
|
-- Clean up input: trim empty lines
|
||||||
contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true })
|
contents = vim.split(table.concat(contents, '\n'), '\n', { trimempty = true })
|
||||||
@ -1635,9 +1633,6 @@ function M.open_floating_preview(contents, syntax, opts)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if do_stylize then
|
|
||||||
vim.wo[floating_winnr].conceallevel = 2
|
|
||||||
end
|
|
||||||
vim.wo[floating_winnr].foldenable = false -- Disable folding.
|
vim.wo[floating_winnr].foldenable = false -- Disable folding.
|
||||||
vim.wo[floating_winnr].wrap = opts.wrap -- Soft wrapping.
|
vim.wo[floating_winnr].wrap = opts.wrap -- Soft wrapping.
|
||||||
vim.wo[floating_winnr].breakindent = true -- Slightly better list presentation.
|
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].modifiable = false
|
||||||
vim.bo[floating_bufnr].bufhidden = 'wipe'
|
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
|
return floating_bufnr, floating_winnr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user