nvim: after/plugin/snipcomp: Sync with upstream

This commit is contained in:
Sanchayan Maity 2022-04-19 17:36:35 +05:30
parent 686fec51d6
commit cc2fcffc56

View file

@ -33,12 +33,14 @@ end
-- Set 'completefunc' or 'omnifunc' to 'v:lua.vim.luasnip.completefunc' to get
-- completion.
function vim.luasnip.completefunc(findstart, base)
local line_to_cursor = vim.fn.getline("."):sub(1, vim.fn.col("."))
local line, col = vim.api.nvim_get_current_line(), vim.api.nvim_win_get_cursor(0)[2]
local line_to_cursor = line:sub(1, col)
if findstart == 1 then
return vim.fn.match(line_to_cursor, '\\k*$')
end
local snippets = vim.list_extend(vim.list_slice(luasnip.snippets.all), luasnip.snippets[vim.bo.filetype] or {})
local snippets = vim.list_extend(vim.list_slice(luasnip.get_snippets("all")), luasnip.get_snippets(vim.bo.filetype))
snippets = vim.tbl_filter(snippetfilter(line_to_cursor, base), snippets)
snippets = vim.tbl_map(snippet2completion, snippets)
table.sort(snippets, function(s1, s2) return s1.word < s2.word end)