mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
* feat: add fuzzy matching sorter experimentally * feat: add an option to select matcher logic * feat: separate logic to match: fuzzy, fuzzy_full * Revert "feat: separate logic to match: fuzzy, fuzzy_full" This reverts commit 64c022904871143ab12c7d6ba29c89fbabdbe15e. * feat: use fzy sorter and combine recency scores * feat: enable to change logic to calculate scores * feat: change the view for scores by config.matcher * docs: add note in README * docs: add note for `scoring_function`
27 lines
725 B
Lua
27 lines
725 B
Lua
local config = require "frecency.config"
|
|
local sorters = require "telescope.sorters"
|
|
|
|
---@param opts any options for get_fzy_sorter()
|
|
return function(opts)
|
|
local fzy_sorter = sorters.get_fzy_sorter(opts)
|
|
|
|
return sorters.Sorter:new {
|
|
---@param prompt string
|
|
---@param entry FrecencyEntry
|
|
---@return number
|
|
scoring_function = function(_, prompt, _, entry)
|
|
if #prompt == 0 then
|
|
return 1
|
|
end
|
|
local fzy_score = fzy_sorter:scoring_function(prompt, entry.ordinal)
|
|
if fzy_score <= 0 then
|
|
return -1
|
|
end
|
|
entry.fuzzy_score = config.scoring_function(entry.score, fzy_score)
|
|
return entry.fuzzy_score
|
|
end,
|
|
|
|
highlighter = fzy_sorter.highlighter,
|
|
}
|
|
end
|