mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(picker.smart): better frecency bonus
This commit is contained in:
parent
2cb5c5bac7
commit
74feefc522
1 changed files with 6 additions and 2 deletions
|
@ -3,6 +3,9 @@ local M = {}
|
|||
---@class snacks.picker
|
||||
---@field smart fun(opts?: snacks.picker.smart.Config): snacks.picker.finder
|
||||
|
||||
local BONUS_FRECENCY = 8
|
||||
local BONUS_CWD = 10
|
||||
|
||||
---@param opts snacks.picker.smart.Config
|
||||
---@type snacks.picker.finder
|
||||
function M.smart(opts, filter)
|
||||
|
@ -16,9 +19,10 @@ function M.smart(opts, filter)
|
|||
return false
|
||||
end
|
||||
done[path] = true
|
||||
local score = freceny:get(item)
|
||||
local score = (1 - 1 / (1 + freceny:get(item))) * BONUS_FRECENCY
|
||||
item.frecency = score
|
||||
if path:find(cwd, 1, true) then
|
||||
score = score + 20
|
||||
score = score + BONUS_CWD
|
||||
end
|
||||
item.score_add = score
|
||||
end)(opts, filter)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue