aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 })