diff --git a/README.md b/README.md index 57e5a5c..c0cf9de 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,20 @@ least, it matches against exact the same as you input. See [default configuration](https://github.com/nvim-telescope/telescope.nvim#telescope-defaults) for full details on configuring Telescope. +- `recency_values` (default: see follow) + + ```lua + -- recency_values default: + recency_values = { + { age = 240, value = 100 }, -- past 4 hours + { age = 1440, value = 80 }, -- past day + { age = 4320, value = 60 }, -- past 3 days + { age = 10080, value = 40 }, -- past week + { age = 43200, value = 20 }, -- past month + { age = 129600, value = 10 }, -- past 90 days + } + ``` + - `auto_validate` (default: `true`) If `true`, it removes stale entries count over than `db_validate_threshold`. See diff --git a/lua/frecency/config.lua b/lua/frecency/config.lua index a458cf9..cec8f2a 100644 --- a/lua/frecency/config.lua +++ b/lua/frecency/config.lua @@ -5,6 +5,7 @@ local os_util = require "frecency.os_util" local Config = {} ---@class FrecencyRawConfig +---@field recency_values table default: {} ---@field auto_validate boolean default: true ---@field db_root string default: vim.fn.stdpath "data" ---@field db_safe_mode boolean default: true @@ -24,6 +25,14 @@ local Config = {} ---@return FrecencyConfig Config.new = function() local default_values = { + recency_values = { + { age = 240, value = 100 }, -- past 4 hours + { age = 1440, value = 80 }, -- past day + { age = 4320, value = 60 }, -- past 3 days + { age = 10080, value = 40 }, -- past week + { age = 43200, value = 20 }, -- past month + { age = 129600, value = 10 }, -- past 90 days + }, auto_validate = true, db_root = vim.fn.stdpath "data", db_safe_mode = true, @@ -43,6 +52,7 @@ Config.new = function() } ---@type table local keys = { + recency_values = true, auto_validate = true, db_root = true, db_safe_mode = true, @@ -85,6 +95,7 @@ end Config.setup = function(ext_config) local opts = vim.tbl_extend("force", config.values, ext_config or {}) vim.validate { + recency_values = { opts.recency_values, "t" }, auto_validate = { opts.auto_validate, "b" }, db_root = { opts.db_root, "s" }, db_safe_mode = { opts.db_safe_mode, "b" }, diff --git a/lua/frecency/recency.lua b/lua/frecency/recency.lua index 3bada04..8f4edd5 100644 --- a/lua/frecency/recency.lua +++ b/lua/frecency/recency.lua @@ -7,14 +7,7 @@ local Recency = {} ---@return FrecencyRecency Recency.new = function() return setmetatable({ - modifier = { - { age = 240, value = 100 }, -- past 4 hours - { age = 1440, value = 80 }, -- past day - { age = 4320, value = 60 }, -- past 3 days - { age = 10080, value = 40 }, -- past week - { age = 43200, value = 20 }, -- past month - { age = 129600, value = 10 }, -- past 90 days - }, + modifier = config.recency_values, }, { __index = Recency }) end