Skip to content

Commit f8c1769

Browse files
committed
snippet prefix can be a table
1 parent 589c896 commit f8c1769

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lua/phoenix/init.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,21 @@ function Snippet:get_completions(prefix)
532532
return results
533533
end
534534

535+
local snippet_prefix_match = function(p)
536+
for _, item in ipairs(p) do
537+
if vim.startswith(item:lower(), prefix:lower()) then
538+
return true
539+
end
540+
end
541+
return false
542+
end
543+
535544
local snippets = self.cache[ft]
536545
for trigger, snippet_data in pairs(snippets) do
537-
local snippet_prefix = snippet_data.prefix
546+
local snippet_prefix = type(snippet_data.prefix) == 'string' and { snippet_data.prefix }
547+
or snippet_data.prefix
538548
if
539-
vim.startswith(snippet_prefix:lower(), prefix:lower())
549+
snippet_prefix_match(snippet_data.prefix)
540550
or (
541551
vim.o.completeopt:find('fuzzy')
542552
and next(vim.fn.matchfuzzy({ snippet_prefix }, prefix:lower())) ~= nil

0 commit comments

Comments
 (0)