Skip to content

Commit

Permalink
fix: respect telescope's path_display
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed May 1, 2024
1 parent 46c5358 commit 086fe9c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,33 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel
timestamps when you open the file. It is reasonable to set this value more
than or equal to the default value: `10`.

- `path_display` (default: `nil`)

Overwrite the `path_display` setting in telescope.nvim itself. See
`:h telescope.defaults.path_display` for acceptable values. This setting will
be used by these priorities below.

1. Option specified with the command or Lua code.
- `:Telescope frecency path_display={"absolute"}`.
- or `:lua require("telescope").extensions.frecency.frecency { path_display = { "absolute" } }`.
2. `opts.extensions.frecency.path_display` in setup.
3. `opts.defaults.path_display` in setup.

```lua
require("telescope").setup {
defaults = {
-- This has the 3rd precedence.
path_display = { "absolute" },
},
extensions = {
frecency = {
-- This has the 2nd precedence.
path_display = { "shorten" },
},
},
}
```

- `recency_values` (default: see below)

Set weighting factors for calculating “frecency”. This option does not affect
Expand Down
2 changes: 2 additions & 0 deletions lua/frecency/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local Config = {}
---@field matcher "default"|"fuzzy" default: "default"
---@field scoring_function fun(recency: integer, fzy_score: number): number default: see lua/frecency/config.lua
---@field max_timestamps integer default: 10
---@field path_display? table default: nil
---@field show_filter_column boolean|string[] default: true
---@field show_scores boolean default: false
---@field show_unindexed boolean default: true
Expand Down Expand Up @@ -75,6 +76,7 @@ Config.new = function()
ignore_patterns = true,
matcher = true,
max_timestamps = true,
path_display = true,
scoring_function = true,
show_filter_column = true,
show_scores = true,
Expand Down
7 changes: 1 addition & 6 deletions lua/frecency/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Picker:start(opts)
path_display = function(picker_opts, path)
return self:default_path_display(picker_opts, path)
end,
}, opts or {}) --[[@as FrecencyPickerOptions]]
}, config_values, opts or {}) --[[@as FrecencyPickerOptions]]
self.workspace = self:get_workspace(opts.cwd, self.config.initial_workspace_tag or config.default_workspace)
log.debug { workspace = self.workspace }

Expand Down Expand Up @@ -272,11 +272,6 @@ function Picker:filepath_formatter(picker_opts)
opts.cwd = workspace or self.fs.os_homedir

return function(filename)
local path_display = config_values.path_display
if type(path_display) == "table" and path_display.filename_first then
opts.path_display = path_display
end

return utils.transform_path(opts, filename)
end
end
Expand Down

0 comments on commit 086fe9c

Please sign in to comment.