Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lua/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ local function hasConfirmedCompletion()
local completed_item = api.nvim_get_vvar('completed_item')
if completed_item.user_data.lsp ~= nil then
applyAddtionalTextEdits(completed_item)
if vim.g.completion_enable_snippet == "snippets.nvim" then
require 'snippets'.expand_at_cursor(completed_item.user_data.actual_item, completed_item.word)
end
end
if opt.get_option('enable_auto_paren') == 1 then
autoAddParens(completed_item)
Expand Down
11 changes: 9 additions & 2 deletions lua/completion/source/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ local function get_completion_word(item, prefix, suffix)
else
newText = item.textEdit.newText
end
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText"
or vim.g.completion_enable_snippet == "snippets.nvim" then
return newText
else
return vim.lsp.util.parse_snippet(newText)
end
elseif item.insertText ~= nil and item.insertText ~= vim.NIL then
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then
if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText"
or vim.g.completion_enable_snippet == "snippets.nvim" then
return item.insertText
else
return vim.lsp.util.parse_snippet(item.insertText)
Expand Down Expand Up @@ -95,6 +97,11 @@ local function text_document_completion_list_to_complete_items(result, params)
completion_item = completion_item,
}
}
if protocol.InsertTextFormat[completion_item.insertTextFormat] == 'Snippet'
and vim.g.completion_enable_snippet == "snippets.nvim" then
item.user_data.actual_item = item.word
item.word = completion_item.label
end
local kind = protocol.CompletionItemKind[completion_item.kind]
item.kind = customize_label[kind] or kind
item.abbr = completion_item.label
Expand Down