chrisgrieser / nvim-rip-substitute

Perform search and replace operations in the current buffer using a modern user interface and contemporary regex syntax.
MIT License
127 stars 7 forks source link

Feature Request: Alternative Styling for range backdrop #12

Closed Muizzyranking closed 1 month ago

Muizzyranking commented 1 month ago

Checklist

Feature Requested

I want to request for catpuccin intergration to make the rest of the code grey like when a section of code is highlighted just like when you use flash or leap. The selected part should retain the color while the rest of the code turn grey rather than the code code turning black. Check the image I uploaded. Sorry my description is not straightforward.

I want to try this but I am thinking I need to fork catppuccin repo and add the integration but I decided to put this here because I think it would be cool if catpuccin has integration for this plugin, thanks.

Relevant Screenshot

image

chrisgrieser commented 1 month ago

Creating features for one specific theme is a bit too niche to add to a plugin, sorry.

Muizzyranking commented 1 month ago

Thank you for your response but do you know how I can achieve this? I know I would have to fork catppuccin and add the integration myself, but how do I know the hlgroup so I can do this myself?

chrisgrieser commented 1 month ago

The backdrop is actually a bit more complicated than just a highlight group. Basically, I achieve the effect by creating two dummy-windows that are fully black with transparency. Here is the function implementing it: https://github.com/chrisgrieser/nvim-rip-substitute/blob/014368a9cde67941170965235e97e73332b23d29/lua/rip-substitute/popup-win.lua#L144-L210

What you suggested is definitely possible, though that would require a very different logic applying highlights on all lines outside the range. I personally do not think that a slightly different aesthetic is worth writing all that code (though it's shorter than the current implementation), but if you are interested in writing that code, I'd be open to a PR (so you do not have to maintain a fork for this)

chrisgrieser commented 1 month ago

Oh, and I just remembered: One non-aesthetic reason why I decided against creating a backdrop with the look you proposed is that it actually creates ambiguity in some edge cases.

While leap and flash can simply paint the whole viewport in a comment color, using such a color for the area outside a range can be problematic when you have a fully commented line at the edge of the range. Since both, the outside-area and the commented line would then have the same appearance, it could become hard to distinguish between the two. Using the backdrop with the dummy-windows creates a "unique" appearance that does not leave such an ambiguity.

Muizzyranking commented 1 month ago

Thank you. Appreciate your response.