@@ -51,13 +51,39 @@ local getNeosnippetItems = function(prefix)
5151 return complete_items
5252end
5353
54+ local getVsnipItems = function (prefix )
55+ if vim .fn .exists (" *vsnip#source#find" ) == 0 then return {} end
56+ local snippetsList = api .nvim_call_function (' vsnip#source#find' , {api .nvim_buf_get_option (0 , ' filetype' )})
57+ local complete_items = {}
58+ if vim .tbl_isempty (snippetsList ) == 0 then
59+ return {}
60+ end
61+ local priority = vim .g .completion_items_priority [' Vsnip' ]
62+ for sourceIdx , source in pairs (snippetsList ) do
63+ for snippetIdx , snippet in pairs (source ) do
64+ for prefixIdx , word in pairs (snippet .prefix ) do
65+ local user_data = {hover = snippet .description }
66+ local item = {}
67+ item .word = word
68+ item .kind = ' Vsnip'
69+ item .priority = priority
70+ item .user_data = user_data
71+ match .matching (complete_items , prefix , item )
72+ end
73+ end
74+ end
75+ return complete_items
76+ end
77+
5478M .getCompletionItems = function (prefix , score_func , _ )
5579 local source = vim .g .completion_enable_snippet
5680 local snippet_list = {}
5781 if source == ' UltiSnips' then
5882 snippet_list = getUltisnipItems (prefix , score_func )
5983 elseif source == ' Neosnippet' then
6084 snippet_list = getNeosnippetItems (prefix , score_func )
85+ elseif source == ' Vsnip' then
86+ snippet_list = getVsnipItems (prefix , source_func )
6187 end
6288 return snippet_list
6389end
0 commit comments