mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
feat: hide_current_buffer option (#176)
* feat: `hide_current_buffer` option * docs: add `hide_current_buffer` option
This commit is contained in:
parent
5c5302372b
commit
4f3e007ec2
@ -175,6 +175,10 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel
|
||||
|
||||
Disable devicons (if available)
|
||||
|
||||
- `hide_current_buffer` (default: `false`)
|
||||
|
||||
If `true`, it does not show the current buffer in candidates.
|
||||
|
||||
- `filter_delimiter` (default: `":"`)
|
||||
|
||||
Delimiters to indicate the filter like `:CWD:`.
|
||||
|
||||
@ -26,6 +26,7 @@ local Finder = {}
|
||||
|
||||
---@class FrecencyFinderConfig
|
||||
---@field chunk_size integer? default: 1000
|
||||
---@field ignore_filenames string[]? default: {}
|
||||
---@field sleep_interval integer? default: 50
|
||||
---@field workspace_scan_cmd "LUA"|string[]|nil default: nil
|
||||
|
||||
@ -41,7 +42,7 @@ local Finder = {}
|
||||
Finder.new = function(database, entry_maker, fs, need_scandir, path, recency, state, config)
|
||||
local tx, rx = async.control.channel.mpsc()
|
||||
local scan_tx, scan_rx = async.control.channel.mpsc()
|
||||
return setmetatable({
|
||||
local self = setmetatable({
|
||||
config = vim.tbl_extend("force", { chunk_size = 1000, sleep_interval = 50 }, config or {}),
|
||||
closed = false,
|
||||
database = database,
|
||||
@ -67,6 +68,12 @@ Finder.new = function(database, entry_maker, fs, need_scandir, path, recency, st
|
||||
return self:find(...)
|
||||
end,
|
||||
})
|
||||
if self.config.ignore_filenames then
|
||||
for _, name in ipairs(self.config.ignore_filenames or {}) do
|
||||
self.seen[name] = true
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
---@param datetime string?
|
||||
|
||||
@ -25,6 +25,7 @@ local Frecency = {}
|
||||
---@field default_workspace string? default: nil
|
||||
---@field disable_devicons boolean? default: false
|
||||
---@field filter_delimiter string? default: ":"
|
||||
---@field hide_current_buffer boolean default: false
|
||||
---@field ignore_patterns string[]? default: { "*.git/*", "*/tmp/*", "term://*" }
|
||||
---@field max_timestamps integer? default: 10
|
||||
---@field show_filter_column boolean|string[]|nil default: true
|
||||
@ -45,6 +46,7 @@ Frecency.new = function(opts)
|
||||
default_workspace = nil,
|
||||
disable_devicons = false,
|
||||
filter_delimiter = ":",
|
||||
hide_current_buffer = false,
|
||||
ignore_patterns = os_util.is_windows and { [[*.git\*]], [[*\tmp\*]], "term://*" }
|
||||
or { "*.git/*", "*/tmp/*", "term://*" },
|
||||
max_timestamps = 10,
|
||||
@ -113,10 +115,15 @@ function Frecency:start(opts)
|
||||
if opts.cwd then
|
||||
opts.cwd = vim.fn.expand(opts.cwd)
|
||||
end
|
||||
local ignore_filenames
|
||||
if opts.hide_current_buffer or self.config.hide_current_buffer then
|
||||
ignore_filenames = { vim.api.nvim_buf_get_name(0) }
|
||||
end
|
||||
self.picker = Picker.new(self.database, self.entry_maker, self.fs, self.recency, {
|
||||
default_workspace_tag = self.config.default_workspace,
|
||||
editing_bufnr = vim.api.nvim_get_current_buf(),
|
||||
filter_delimiter = self.config.filter_delimiter,
|
||||
ignore_filenames = ignore_filenames,
|
||||
initial_workspace_tag = opts.workspace,
|
||||
show_unindexed = self.config.show_unindexed,
|
||||
workspace_scan_cmd = self.config.workspace_scan_cmd,
|
||||
|
||||
@ -26,6 +26,7 @@ local Picker = {}
|
||||
---@field default_workspace_tag string?
|
||||
---@field editing_bufnr integer
|
||||
---@field filter_delimiter string
|
||||
---@field ignore_filenames string[]?
|
||||
---@field initial_workspace_tag string?
|
||||
---@field show_unindexed boolean
|
||||
---@field workspace_scan_cmd "LUA"|string[]|nil
|
||||
@ -61,6 +62,7 @@ end
|
||||
|
||||
---@class FrecencyPickerOptions
|
||||
---@field cwd string
|
||||
---@field hide_current_buffer boolean?
|
||||
---@field path_display
|
||||
---| "hidden"
|
||||
---| "tail"
|
||||
@ -86,7 +88,7 @@ function Picker:finder(opts, workspace, workspace_tag)
|
||||
workspace,
|
||||
self.recency,
|
||||
self.state,
|
||||
{ workspace_scan_cmd = self.config.workspace_scan_cmd }
|
||||
{ ignore_filenames = self.config.ignore_filenames, workspace_scan_cmd = self.config.workspace_scan_cmd }
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user