Dim common path prefixes between adjacent Telescope results so the unique tail stands out.
- Highlights shared path prefixes between neighbors in the results list
- Compare direction can be
prevornext
nvim-telescope/telescope.nvim
{
"todesking/telescope-highlight-common-prefix.nvim",
}Run this as part of your Telescope configuration setup.
local telescope = require("telescope")
local hl = require("telescope_highlight_common_prefix")
local on_complete = hl.new_complete_handler({
-- options here
})
telescope.setup({
pickers = {
find_files = {
-- Add this to pickers where you want common-prefix highlighting.
on_complete = { on_complete },
},
},
})
-- Keep highlights when using `telescope.builtin.resume()`.
local aug = vim.api.nvim_create_augroup("telescope-highlight-common-prefix", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = aug,
pattern = "TelescopeResumePost",
callback = hl.on_resume,
})These keys are options passed to new_complete_handler().
"prev": compare each entry to the previous visible entry"next": compare each entry to the next visible entry
default: "prev"
Override how the common prefix length is computed (return a byte length). The default checks path segments (split by /).
- Highlighting uses
TelescopeResultsComment. Adjust that highlight group to change the dim color. - Comparison uses
config.values.path_display(and pickeropts.path_displaywhen set), so customize it via Telescope'spath_displayoptions.
MIT