mirror of
https://github.com/neovim/neovim.git
synced 2026-03-28 03:12:00 +00:00
feat(lsp): show snippet preview if completeopt=popup #32553
Problem: LSP completion does not show snippet preview. Solution: Show snippet preview if 'completeopt' includes popup.
This commit is contained in:
@@ -243,6 +243,18 @@ end
|
||||
---@param item lsp.CompletionItem
|
||||
---@return string
|
||||
local function get_doc(item)
|
||||
if
|
||||
vim.o.completeopt:find('popup')
|
||||
and item.insertTextFormat == protocol.InsertTextFormat.Snippet
|
||||
and #(item.documentation or '') == 0
|
||||
and vim.bo.filetype ~= ''
|
||||
and (item.textEdit or (item.insertText and item.insertText ~= ''))
|
||||
then
|
||||
-- Shows snippet preview in doc popup if completeopt=popup.
|
||||
local text = parse_snippet(item.insertText or item.textEdit.newText)
|
||||
return ('```%s\n%s\n```'):format(vim.bo.filetype, text)
|
||||
end
|
||||
|
||||
local doc = item.documentation
|
||||
if not doc then
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user