telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

telescope results line color / highlight

Open sand4rt opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. The ability to change the color of the line next to the line numbers (the red one in the screenshot) without effecting the normal text.

Describe the solution you'd like A new highlight group to change the color.

Describe alternatives you've considered I changed TelescopeResultsNormal, but that also affects other text.

Additional context Screenshot 2024-05-18 at 20 39 49

sand4rt avatar May 18 '24 18:05 sand4rt

There technically is a separator_hl option deep inside the results entry creation mechanism that you could take advantage of but it's pretty inaccessible at the moment and none of the builtin pickers utilize it so I'm an agreement that it's probably better to just have a hl group for the separator.

But this is pretty low priority for me personally. If someone wants to have a go at it, I'd be willing to offer some help.

jamestrew avatar May 23 '24 02:05 jamestrew

@jamestrew, do you mean this piece of code?: image By creating a new hl_group, do you mean to make it and add it as default like the others? Also, how did you configure the line next to the number? By default, I have only the line number and not the separator @sand4rt

MovieMaker93 avatar May 23 '24 22:05 MovieMaker93

@MovieMaker93 that's right. https://github.com/nvim-telescope/telescope.nvim/blob/5665d93988acfbb0747bdbf4f4cb583bcebc8930/lua/telescope/make_entry.lua#L925-L932 We could technically make current_buffer_fuzzy_find and other pickers using entry_display take a separator_hl option but I feel like just adding a new hl group, something like TelescopeResultsSeparator would be a cleaner way.

jamestrew avatar May 25 '24 01:05 jamestrew

@MovieMaker93 that's right.

https://github.com/nvim-telescope/telescope.nvim/blob/5665d93988acfbb0747bdbf4f4cb583bcebc8930/lua/telescope/make_entry.lua#L925-L932

We could technically make current_buffer_fuzzy_find and other pickers using entry_display take a separator_hl option, but I feel like just adding a new hl group, something like TelescopeResultsSeparator would be a cleaner way.

Thanks for the answer. I'm trying to understand how the highlighters work for the pickers, but I haven't fully grasped it yet.
I've added the new hlgroup here: https://github.com/nvim-telescope/telescope.nvim/blob/5665d93988acfbb0747bdbf4f4cb583bcebc8930/lua/telescope/pickers.lua#L73-L84 image and as default here: https://github.com/nvim-telescope/telescope.nvim/blob/5665d93988acfbb0747bdbf4f4cb583bcebc8930/plugin/telescope.lua#L18-L22 image However, I don't know where to specify this hlgroup option. I didn't understand where the popup_opts has been defined or how to define the new hlgroup besides the one place specified above. Could you guide me further on how to do it?

MovieMaker93 avatar May 25 '24 13:05 MovieMaker93

On second thought, maybe TelescopeResultsEntrySeparator might be clearer.

However, I don't know where to specify this hlgroup option.

I think you could just do something like

configuration.separator_hl = vim.F.if_nil(configuration.separator_hl, "TelescopeResultsEntrySeparator")

at the top of the entry_display.create function. This should add the highlight group to a table of highlights for the entry. The actual setting of the entry highlights happens closer to here: https://github.com/nvim-telescope/telescope.nvim/blob/c2ce039188e22288449e43b77710036e69a45a70/lua/telescope/pickers.lua#L1264-L1300

The hi_display function will loop over the table of highlights and call nvim_buf_add_highlight

jamestrew avatar May 26 '24 01:05 jamestrew