Skip to content

Commit

Permalink
Support vsnip's same prefix items
Browse files Browse the repository at this point in the history
  • Loading branch information
hrsh7th committed Jan 15, 2021
1 parent aa5cc61 commit 7112121
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lua/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ local function hasConfirmedCompletion()
elseif completed_item.user_data.snippet_source == 'Neosnippet' then
api.nvim_input("<c-r>".."=neosnippet#expand('"..completed_item.word.."')".."<CR>")
elseif completed_item.user_data.snippet_source == 'vim-vsnip' then
api.nvim_call_function('vsnip#expand', {})
api.nvim_call_function('vsnip#anonymous', {
table.concat(completed_item.user_data.snippet_body, "\n"),
{
prefix = completed_item.word
}
})
elseif completed_item.user_data.snippet_source == 'snippets.nvim' then
require'snippets'.expand_at_cursor()
end
Expand Down
2 changes: 1 addition & 1 deletion lua/completion/source/snippet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ M.getVsnipItems = function(prefix)
for _, source in pairs(snippetsList) do
for _, snippet in pairs(source) do
for _, word in pairs(snippet.prefix) do
local user_data = {snippet_source = 'vim-vsnip', hover = snippet.description}
local user_data = {snippet_source = 'vim-vsnip', snippet_body = snippet.body, hover = snippet.description}
local item = {}
item.word = word
item.kind = kind
Expand Down

0 comments on commit 7112121

Please sign in to comment.