Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to specify tags to show the tails #77

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel

Disable devicons (if available)

- `show_filter_column` (default: `true`)

Show the path of the active filter before file paths. In default, it uses the tail of paths for `'LSP'` and `'CWD'` tags. You can configure this by setting a table for this option.

```lua
-- show the tail for "LSP", "CWD" and "FOO"
show_filter_column = { "LSP", "CWD", "FOO" }
```


### Example Configuration:

Expand Down
9 changes: 7 additions & 2 deletions lua/telescope/_extensions/frecency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ local frecency = function(opts)

fetch_lsp_workspaces(state.previous_buffer)

local function should_show_tail()
local filters = type(state.show_filter_column) == "table" and state.show_filter_column or { "LSP", "CWD" }
return vim.tbl_contains(filters, state.active_filter_tag)
end

local function get_display_cols()
local directory_col_width = 0
if state.active_filter then
if state.active_filter_tag == "LSP" or state.active_filter_tag == "CWD" then
if should_show_tail() then
-- TODO: Only add +1 if opts.show_filter_thing is true, +1 is for the trailing slash
directory_col_width = #(utils.path_tail(state.active_filter)) + 1
else
Expand Down Expand Up @@ -147,7 +152,7 @@ local frecency = function(opts)
if state.show_filter_column then
local filter_path = ""
if state.active_filter then
if state.active_filter_tag == "LSP" or state.active_filter_tag == "CWD" then
if should_show_tail() then
filter_path = utils.path_tail(state.active_filter) .. os_path_sep
else
filter_path = Path:new(state.active_filter):make_relative(os_home) .. os_path_sep
Expand Down