mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(picker.frecency): cleanup old entries from sqlite3 database
This commit is contained in:
parent
bd2da45c38
commit
320a4a62a1
3 changed files with 92 additions and 37 deletions
|
@ -9,7 +9,7 @@ local BONUS_CWD = 10
|
|||
---@param opts snacks.picker.smart.Config
|
||||
---@type snacks.picker.finder
|
||||
function M.smart(opts, filter)
|
||||
local freceny = require("snacks.picker.core.frecency").new()
|
||||
local frecency = require("snacks.picker.core.frecency").new()
|
||||
local done = {} ---@type table<string, boolean>
|
||||
local cwd = vim.fs.normalize(opts.cwd or (vim.uv or vim.loop).cwd() or ".")
|
||||
local finder = Snacks.picker.config.finder(opts.finders or { "files", "buffers", "recent" })
|
||||
|
@ -19,7 +19,7 @@ function M.smart(opts, filter)
|
|||
return false
|
||||
end
|
||||
done[path] = true
|
||||
local score = (1 - 1 / (1 + freceny:get(item))) * BONUS_FRECENCY
|
||||
local score = (1 - 1 / (1 + frecency:get(item))) * BONUS_FRECENCY
|
||||
item.frecency = score
|
||||
if path:find(cwd, 1, true) then
|
||||
score = score + BONUS_CWD
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue