@@ -76,6 +76,35 @@ M.getVsnipItems = function(prefix)
7676 return complete_items
7777end
7878
79+ -- Cribbed almost wholesale from snippets.lookup_snippet()
80+ M .getSnippetsNvimItems = function (prefix )
81+ local snippets = require ' snippets'
82+ if not snippets then return {} end
83+ local ft = vim .bo .filetype
84+ local snippetsList = vim .tbl_extend (' force' , snippets .snippets ._global , snippets .snippets [ft ] or {})
85+ local complete_items = {}
86+ if vim .tbl_isempty (snippetsList ) == 0 then
87+ return {}
88+ end
89+ local priority = vim .g .completion_items_priority [' snippets.nvim' ] or 1
90+ local kind = ' snippets.nvim'
91+ for short , long in pairs (snippetsList ) do
92+ -- TODO: We cannot put the parsed snippet itself in userdata, since it may
93+ -- contain Lua functions (see
94+ -- https://github.com/norcalli/snippets.nvim#notes-because-this-is-beta-release-software)
95+ local user_data = {}
96+ local item = {}
97+ item .word = short
98+ item .kind = kind
99+ -- TODO: Turn actual snippet text into label/description?
100+ item .menu = short
101+ item .priority = priority
102+ item .user_data = user_data
103+ match .matching (complete_items , prefix , item )
104+ end
105+ return complete_items
106+ end
107+
79108M .getCompletionItems = function (prefix )
80109 local source = vim .g .completion_enable_snippet
81110 local snippet_list = {}
@@ -85,6 +114,8 @@ M.getCompletionItems = function(prefix)
85114 snippet_list = M .getNeosnippetItems (prefix )
86115 elseif source == ' vim-vsnip' then
87116 snippet_list = M .getVsnipItems (prefix )
117+ elseif source == ' snippets.nvim' then
118+ snippet_list = M .getSnippetsNvimItems (prefix )
88119 end
89120 return snippet_list
90121end
0 commit comments