fix completions

This commit is contained in:
nicknase27 committed 2026-10-03 21:04:34 +02:00
1 parent 9700278b5f
commit c8e4b090d5
6 files changed
+71 -15

No files matched your search

+41 -12
View File
@@ -5,12 +5,12 @@ require('mini.icons').setup()
-- Notifications
require('mini.notify').setup({
-- only show messages
content = {
format = function(notif)
return notif.msg
end,
},
-- only show messages
content = {
format = function(notif)
return notif.msg
end,
},
})
-- Commandline
@@ -20,22 +20,51 @@ require('mini.cmdline').setup({
-- Autocompletion
local MiniCompletion = require('mini.completion')
-- Priority
local kind_priority = {
[5] = 1, -- Field (Struct fields)
[10] = 1, -- Property
[2] = 2, -- Method
[3] = 3, -- Function
[6] = 4, -- Variable
}
MiniCompletion.setup({
lsp_completion = {
auto_setup = true,
process_items = function(items, base)
return MiniCompletion.default_process_items(items, base, {
-- 1. Apply standard fuzzy matching and basic sorting first
items = MiniCompletion.default_process_items(items, base, {
filtersort = "fuzzy",
})
-- 2. Sort by custom kind priority (Fields -> Methods -> Functions -> Others -> Snippets/Text)
table.sort(items, function(a, b)
local prio_a = kind_priority[a.kind] or 100
local prio_b = kind_priority[b.kind] or 100
-- Push Snippets (15) and Text (1) to the absolute bottom
if a.kind == 15 or a.kind == 1 then prio_a = 999 end
if b.kind == 15 or b.kind == 1 then prio_b = 999 end
if prio_a ~= prio_b then
return prio_a < prio_b
end
-- Fallback to default sortText or label when kinds match
return (a.sortText or a.label) < (b.sortText or b.label)
end)
return items
end,
}
})
local MiniSnipets = require('mini.snippets')
MiniSnipets.setup({
local MiniSnippets = require('mini.snippets')
MiniSnippets.setup({
snippets = {
MiniSnipets.gen_loader.from_lang(),
MiniSnippets.gen_loader.from_lang(),
},
})
MiniSnipets.start_lsp_server({ match = false })
MiniSnippets.start_lsp_server({ match = MiniSnippets.default_match })