@@ -531,29 +531,27 @@ function Snippet:get_completions(prefix)
531
531
if not self .cache [ft ] then
532
532
return results
533
533
end
534
+ prefix = prefix :lower ()
534
535
535
536
local snippet_prefix_match = function (p )
536
537
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
538
542
return item
539
543
end
540
544
end
541
545
return nil
542
546
end
543
547
544
548
local snippets = self .cache [ft ]
545
- for trigger , snippet_data in pairs (snippets ) do
549
+ for _ , snippet_data in pairs (snippets ) do
546
550
local snippet_prefix = type (snippet_data .prefix ) == ' string' and { snippet_data .prefix }
547
551
or snippet_data .prefix
548
552
local matched_label = snippet_prefix_match (snippet_prefix )
549
553
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
557
555
local body = snippet_data .body
558
556
local insert_text = body
559
557
@@ -562,9 +560,9 @@ function Snippet:get_completions(prefix)
562
560
end
563
561
564
562
table.insert (results , {
565
- label = matched_label or snippet_prefix ,
563
+ label = matched_label ,
566
564
kind = 15 ,
567
- filterText = snippet_prefix ,
565
+ filterText = matched_label ,
568
566
insertText = insert_text ,
569
567
documentation = {
570
568
kind = ' markdown' ,
@@ -576,8 +574,8 @@ function Snippet:get_completions(prefix)
576
574
.. ' \n ```' ,
577
575
},
578
576
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 ,
581
579
})
582
580
end
583
581
end
0 commit comments