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

Commit a54e291

Browse files
committed
snippet: use call api instead of nvim_call_function
nivm_call_function returns invalid items when there is no match and no item to return. This causes snippets to always have a true 'item' breaking automatic chain completion. Signed-off-by: Seb Laveze <[email protected]>
1 parent 936bbd1 commit a54e291

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

lua/completion/source/snippet.lua

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local M = {}
77

88
M.getUltisnipItems = function(prefix)
99
if vim.fn.exists("*UltiSnips#SnippetsInCurrentScope") == 0 then return {} end
10-
local snippetsList = api.nvim_call_function('UltiSnips#SnippetsInCurrentScope', {})
10+
local snippetsList = vim.call('UltiSnips#SnippetsInCurrentScope')
1111
local complete_items = {}
1212
if vim.tbl_isempty(snippetsList) then
1313
return {}
@@ -16,10 +16,6 @@ M.getUltisnipItems = function(prefix)
1616
local kind = 'UltiSnips'
1717
kind = opt.get_option('customize_lsp_label')[kind] or kind
1818
for key, val in pairs(snippetsList) do
19-
-- fix lua parsing issue
20-
if key == true then
21-
key = 'true'
22-
end
2319
local item = {}
2420
item.word = key
2521
item.kind = kind
@@ -33,7 +29,7 @@ end
3329

3430
M.getNeosnippetItems = function(prefix)
3531
if vim.fn.exists("*neosnippet#helpers#get_completion_snippets") == 0 then return {} end
36-
local snippetsList = api.nvim_call_function('neosnippet#helpers#get_completion_snippets', {})
32+
local snippetsList = vim.call('neosnippet#helpers#get_completion_snippets')
3733
local complete_items = {}
3834
if vim.tbl_isempty(snippetsList) == 0 then
3935
return {}
@@ -42,9 +38,6 @@ M.getNeosnippetItems = function(prefix)
4238
kind = opt.get_option('customize_lsp_label')[kind] or kind
4339
local priority = vim.g.completion_items_priority['Neosnippet']
4440
for key, val in pairs(snippetsList) do
45-
if key == true then
46-
key = 'true'
47-
end
4841
local description
4942
if val == nil or type(val) ~= "table" then description = nil else description = val.description end
5043
local user_data = {snippet_source = 'Neosnippet', hover = description}

0 commit comments

Comments
 (0)