@@ -531,29 +531,27 @@ function Snippet:get_completions(prefix)
531531 if not self .cache [ft ] then
532532 return results
533533 end
534+ prefix = prefix :lower ()
534535
535536 local snippet_prefix_match = function (p )
536537 for _ , item in ipairs (p ) do
537- if vim .startswith (item :lower (), prefix :lower ()) then
538+ if
539+ vim .startswith (item :lower (), prefix :lower ())
540+ or (vim .o .completeopt :find (' fuzzy' ) and next (vim .fn .matchfuzzy ({ item }, prefix )) ~= nil )
541+ then
538542 return item
539543 end
540544 end
541545 return nil
542546 end
543547
544548 local snippets = self .cache [ft ]
545- for trigger , snippet_data in pairs (snippets ) do
549+ for _ , snippet_data in pairs (snippets ) do
546550 local snippet_prefix = type (snippet_data .prefix ) == ' string' and { snippet_data .prefix }
547551 or snippet_data .prefix
548552 local matched_label = snippet_prefix_match (snippet_prefix )
549553
550- if
551- matched_label
552- or (
553- vim .o .completeopt :find (' fuzzy' )
554- and next (vim .fn .matchfuzzy ({ snippet_prefix }, prefix :lower ())) ~= nil
555- )
556- then
554+ if matched_label then
557555 local body = snippet_data .body
558556 local insert_text = body
559557
@@ -562,9 +560,9 @@ function Snippet:get_completions(prefix)
562560 end
563561
564562 table.insert (results , {
565- label = matched_label or snippet_prefix ,
563+ label = matched_label ,
566564 kind = 15 ,
567- filterText = snippet_prefix ,
565+ filterText = matched_label ,
568566 insertText = insert_text ,
569567 documentation = {
570568 kind = ' markdown' ,
@@ -576,8 +574,8 @@ function Snippet:get_completions(prefix)
576574 .. ' \n ```' ,
577575 },
578576 detail = ' Snippet: ' .. (snippet_data .description or ' ' ),
579- sortText = string.format (' 000%s' , trigger ),
580- insertTextFormat = 2 ,
577+ sortText = string.format (' 000%s' , matched_label ),
578+ insertTextFormat = vim . lsp . protocol . InsertTextFormat . Snippet ,
581579 })
582580 end
583581 end
0 commit comments