@@ -22,10 +22,7 @@ local default = {
22
22
recency = 0.3 , -- 30% weight to recent usage
23
23
frequency = 0.7 , -- 70% weight to frequency
24
24
},
25
- priority = {
26
- base = 100 , -- Base priority score (0-999)
27
- position = ' after' , -- Position relative to other LSP results: 'before' or 'after'
28
- },
25
+ priority = 500 ,
29
26
},
30
27
31
28
-- Cleanup settings control dictionary maintenance
@@ -46,7 +43,10 @@ local default = {
46
43
throttle_delay_ms = 300 , -- Wait 300ms between updates
47
44
ignore_patterns = {}, -- No ignore patterns by default
48
45
},
49
- snippet = ' ' ,
46
+ snippet = {
47
+ path = ' ' ,
48
+ priority = 200 ,
49
+ },
50
50
}
51
51
52
52
-- @type PhoenixConfig
@@ -498,7 +498,7 @@ function Snippet:preload()
498
498
if self .cache [ft ] or self .loading [ft ] then
499
499
return
500
500
end
501
- local path = vim .fs .joinpath (Config .snippet , (' %s.json' ):format (ft ))
501
+ local path = vim .fs .joinpath (Config .snippet . path , (' %s.json' ):format (ft ))
502
502
if vim .fn .filereadable (path ) == 1 then
503
503
self .loading [ft ] = true
504
504
async .read_file (path , function (data )
@@ -525,6 +525,8 @@ local function parse_snippet(input)
525
525
return ok and tostring (parsed ) or input
526
526
end
527
527
528
+ local special = { ' c' , ' cpp' }
529
+
528
530
function Snippet :get_completions (prefix )
529
531
local ft = vim .bo .filetype
530
532
local results = {}
@@ -544,7 +546,7 @@ function Snippet:get_completions(prefix)
544
546
end
545
547
546
548
table.insert (results , {
547
- label = trigger ,
549
+ label = vim . list_contains ( special , vim . bo [ 0 ]. filetype ) and ' • ' .. trigger or trigger ,
548
550
kind = 15 ,
549
551
insertText = insert_text ,
550
552
documentation = {
@@ -557,7 +559,7 @@ function Snippet:get_completions(prefix)
557
559
.. ' \n ```' ,
558
560
},
559
561
detail = ' Snippet: ' .. (snippet_data .description or ' ' ),
560
- sortText = string.format (' 001%s ' , trigger ),
562
+ sortText = string.format (' %03d%s ' , Config . snippet . priority or 200 , trigger ),
561
563
insertTextFormat = 2 ,
562
564
})
563
565
end
@@ -574,7 +576,7 @@ local function collect_completions(prefix)
574
576
local results = Trie .search_prefix (dict .trie , prefix )
575
577
local now = vim .uv .now ()
576
578
local decay_time = Config .completion .decay_minutes * 60 * 1000
577
- local priority_config = Config .completion .priority
579
+ local word_priority = Config .completion .priority or 500
578
580
579
581
local max_freq = 0
580
582
for _ , result in ipairs (results ) do
@@ -590,21 +592,14 @@ local function collect_completions(prefix)
590
592
return score_a > score_b
591
593
end )
592
594
593
- -- Calculate sort prefix based on priority configuration
594
- local sort_prefix = priority_config .position == ' before'
595
- and string.format (' %03d' , priority_config .base )
596
- or string.format (' %03d' , priority_config .base + 100 )
597
-
598
- local special = { ' c' , ' cpp' }
599
-
600
595
return vim
601
596
.iter (ipairs (results ))
602
597
:map (function (idx , node )
603
598
local t = {
604
599
label = node .word ,
605
600
filterText = node .word ,
606
601
kind = 1 ,
607
- sortText = string.format (' %s %09d%s' , sort_prefix , idx , node .word ),
602
+ sortText = string.format (' %03d %09d%s' , word_priority , idx , node .word ),
608
603
}
609
604
610
605
if vim .list_contains (special , vim .bo [0 ].filetype ) then
@@ -843,7 +838,7 @@ return {
843
838
end ,
844
839
})
845
840
846
- if # Config .snippet > 0 then
841
+ if # Config .snippet . path > 0 then
847
842
Snippet :preload ()
848
843
end
849
844
end ,
0 commit comments