Colorized entries in picker
Is your feature request related to a problem? Please describe.
Hi! I was unable to find anything related to specifying colors of a picker entry in search window.
Actually, I just have an interest if it is possible to colorize file names in find_files, live_grep, buffers, etc by their git status (e.g. yellow for modified, green for new, and so on) . For me, it's simpler to navigate on files not only by their name, but also by their git status. I can just filter out if a file was modified and prefer it instead of other similar file. I understand there is a git_status picker, but it's only limited with modified files and does not have colors.
Probably such colorizing function could be a part of API and be used not only for git.
Describe the solution you'd like It's suggested to have API for colorizing entries in a picker in common sense and have an ability to enable files color in a picker by their git status.
Describe alternatives you've considered I don't know if any alternative is appropriate here, because this feature is an orthogonal highlighting mechanism.
Additional context I don't know if telescope already has mechanics for such thing I ask, so if it has, please, let me know.
How might it look like:
I would like this feature to make the background of the entry green for tests like IntelliJ IDEA.
See getWorkspaceId() in the following image:
@dee-tree It looks like this is possible, but not easy or straight-forward.
See telescope.make_entry and telescope.pickers.entry_display in the help docs:
https://github.com/nvim-telescope/telescope.nvim/blob/f06e7a887185796e0d37088237572f8ce03a1553/doc/telescope.txt#L2505-L2597
They suggest reading the source code in make_entry.lua.
You can override the entry_maker for live_grep. See:
https://github.com/nvim-telescope/telescope.nvim/blob/b4da76be54691e854d3e0e02c36b0245f945c2c7/lua/telescope/builtin/__files.lua#L173
I would copy make_entry.gen_from_vimgrep from here:
https://github.com/nvim-telescope/telescope.nvim/blob/b4da76be54691e854d3e0e02c36b0245f945c2c7/lua/telescope/make_entry.lua#L264-L374
And then you can control the highlight groups.
@dee-tree As an alternative to colorizing the entire entry.
It's much more straight-forward to apply a highlight to just the path via path_display.
For example, the following code sets the Comment highlight-group for the path in the live_grep builtin picker:
telescope.setup({
live_grep = {
-- Add custom highlighting to path
path_display = function(opts, path)
local highlights = {
{
{
0, -- highlight start position
#path, -- highlight end position
},
"Comment", -- highlight group name
},
}
return path, highlights
end
}
},
})
You could use the GitSignsAdd or Added highlight groups, but need logic based on the path to look up if it's added by git.