feat: add max_timestamps option (#145)

To set recency count. Fix #144
This commit is contained in:
JINNOUCHI Yasushi 2023-09-17 17:02:58 +09:00 committed by GitHub
parent 767fbf074f
commit 2119da4e3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 17 deletions

View File

@ -16,7 +16,7 @@ As the extension learns your editing habits over time, the sorting of the list i
A timestamp is recorded once per session when a file is first loaded into a buffer.
The score is calculated using the age of the 10 most recent timestamps and the total amount of times that the file has been loaded:
The score is calculated using the age of the 10 (customizable) most recent timestamps and the total amount of times that the file has been loaded:
### Recency values (per timestamp)
@ -135,27 +135,19 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel
Default workspace tag to filter by e.g. `'CWD'` to filter by default to the current directory. Can be overridden at query time by specifying another filter like `':*:'`.
- `disable_devicons` (default: `false`)
Disable devicons (if available)
- `ignore_patterns` (default: `{ "*.git/*", "*/tmp/*", "term://*" }`)
Patterns in this table control which files are indexed (and subsequently which you'll see in the finder results).
- `show_scores` (default : `false`)
- `max_timestamps` (default: `10`)
To see the scores generated by the algorithm in the results, set this to `true`.
Set the max count of timestamps DB keeps when you open files. It ignores the value and use `10` if you set less than or equal to `0`.
- `workspaces` (default: `{}`)
This table contains mappings of `workspace_tag` -> `workspace_directory`
The key corresponds to the `:tag_name` used to select the filter in queries.
The value corresponds to the top level directory by which results will be filtered.
- `show_unindexed` (default: `true`)
Determines if non-indexed files are included in workspace filter results.
- `disable_devicons` (default: `false`)
Disable devicons (if available)
**CAUTION** When you reduce the value of this option, it removes old timestamps when you open the file. It is reasonable to set this value more than or equal to the default value: `10`.
- `show_filter_column` (default: `true`)
@ -166,10 +158,24 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel
show_filter_column = { "LSP", "CWD", "FOO" }
```
- `show_scores` (default : `false`)
To see the scores generated by the algorithm in the results, set this to `true`.
- `show_unindexed` (default: `true`)
Determines if non-indexed files are included in workspace filter results.
- `use_sqlite` (default: `true`) ***experimental feature***
Use [sqlite.lua] `true` or native code `false`. See [*Remove dependency for sqlite.lua*](#user-content-remove-dependency-for-sqlitelua) for the detail.
- `workspaces` (default: `{}`)
This table contains mappings of `workspace_tag` -> `workspace_directory`
The key corresponds to the `:tag_name` used to select the filter in queries.
The value corresponds to the top level directory by which results will be filtered.
### Example Configuration:
```lua

View File

@ -29,6 +29,7 @@ local Frecency = {}
---@field disable_devicons boolean? default: false
---@field filter_delimiter string? default: ":"
---@field ignore_patterns string[]? default: { "*.git/*", "*/tmp/*", "term://*" }
---@field max_timestamps integer? default: 10
---@field show_filter_column boolean|string[]|nil default: true
---@field show_scores boolean? default: false
---@field show_unindexed boolean? default: true
@ -48,6 +49,7 @@ Frecency.new = function(opts)
disable_devicons = false,
filter_delimiter = ":",
ignore_patterns = { "*.git/*", "*/tmp/*", "term://*" },
max_timestamps = 10,
show_filter_column = true,
show_scores = false,
show_unindexed = true,
@ -72,7 +74,8 @@ Frecency.new = function(opts)
show_filter_column = config.show_filter_column,
show_scores = config.show_scores,
})
self.recency = Recency.new()
local max_count = config.max_timestamps > 0 and config.max_timestamps or 10
self.recency = Recency.new { max_count = max_count }
self.migrator = Migrator.new(self.fs, self.recency, self.config.db_root)
return self
end