From 852b30bfe4497a08e6acd2127e18f43b122f8aee Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sun, 8 Dec 2024 13:14:40 +0100 Subject: remove nil results --- lua/cmp_abook/init.lua | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lua/cmp_abook') diff --git a/lua/cmp_abook/init.lua b/lua/cmp_abook/init.lua index fa8e088..adcfbc8 100644 --- a/lua/cmp_abook/init.lua +++ b/lua/cmp_abook/init.lua @@ -78,16 +78,18 @@ function source:complete(params, callback) local items = {} for _, item in ipairs(result) do local item_parts = vim.split(item, "\t", { trimempty = true }) - local label = string.format( - "%s <%s>", - item_parts[2], - item_parts[1] - ) or item_parts[1] - table.insert(items, { - label = label, - filterText = label:gsub(" ", params.option.space_filter), - kind = cmp.lsp.CompletionItemKind.Text, - }) + if item_parts[1] then + local label = string.format( + "%s <%s>", + item_parts[2], + item_parts[1] + ) or item_parts[1] + table.insert(items, { + label = label, + filterText = label:gsub(" ", params.option.space_filter), + kind = cmp.lsp.CompletionItemKind.Text, + }) + end end callback({ items = items, isIncomplete = false }) -- cgit v1.2.3