Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #331 from hrsh7th/support-vsnip-same-prefix
Browse files Browse the repository at this point in the history
Support vsnip's same prefix items
  • Loading branch information
haorenW1025 authored Jan 15, 2021
2 parents aa5cc61 + 7112121 commit fc9b2fd
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 fc9b2fd

Please sign in to comment.