From ef5d683ce0bf6798d773a9c57f630b1f3d81b7af Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 2 Aug 2024 11:48:04 +0200 Subject: [PATCH] feat: support source priority fixes https://github.com/max397574/care.nvim/issues/30 --- lua/care/sorter.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/care/sorter.lua b/lua/care/sorter.lua index ecc6efb..3fbbb3f 100644 --- a/lua/care/sorter.lua +++ b/lua/care/sorter.lua @@ -26,7 +26,9 @@ function sorter.sort(entries, prefix) for _, res in ipairs(fzy.filter(prefix, filter_texts)) do -- res is a table like `{2, {1, 5, 9}, 2.63}` {, {}, } + -- priority * 10 because fzy scores aren't always between 0 and 1 but quire likely between 0 and 10 entries[res[1]].score = res[3] + + (entries[res[1]].source.config.priority and (entries[res[1]].source.config.priority * 10) or 0) entries[res[1]].matches = res[2] end entries = vim.iter(entries)