aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Segundo2024-12-08 13:14:40 +0100
committerChristian Segundo2024-12-08 13:14:40 +0100
commit852b30bfe4497a08e6acd2127e18f43b122f8aee (patch)
treec3d30950645ade13d20c769384aaa3419d5e589b
parentf79581f4bfe027836d9ec06be23d2006d7301f9a (diff)
downloadcmp-abook-master.tar.gz
remove nil resultsHEADmaster
-rw-r--r--lua/cmp_abook/init.lua22
1 files changed, 12 insertions, 10 deletions
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 })