Skip to content

Commit

Permalink
check for nil
Browse files Browse the repository at this point in the history
  • Loading branch information
kentookura committed Oct 21, 2024
1 parent f81147f commit 088a9d6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lua/forester/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function source:complete(params, callback)
else
local items = {}
local prefix_items = {}
local prefix_random_items = {}
if vim.g.forester_current_config.prefixes ~= nil then
prefix_items = map(vim.g.forester_current_config.prefixes, function(pfx)
return {
Expand All @@ -108,17 +109,17 @@ function source:complete(params, callback)
data = { isPrefix = true },
}
end)
end

local prefix_random_items = map(vim.g.forester_current_config.prefixes, function(pfx)
return {
label = pfx,
filterText = pfx .. " " .. "random",
documentation = "create a new tree with prefix `" .. pfx .. "` (randomized id)",
labelDetails = { description = "random" },
data = { isPrefix = true, isRandom = true, closingDelim = source:closing_delim(text_before_cursor) },
}
end)
prefix_random_items = map(vim.g.forester_current_config.prefixes, function(pfx)
return {
label = pfx,
filterText = pfx .. " " .. "random",
documentation = "create a new tree with prefix `" .. pfx .. "` (randomized id)",
labelDetails = { description = "random" },
data = { isPrefix = true, isRandom = true, closingDelim = source:closing_delim(text_before_cursor) },
}
end)
end
for _, v in pairs(prefix_items) do
table.insert(items, v)
end
Expand Down

0 comments on commit 088a9d6

Please sign in to comment.