nvim-colorizer.lua icon indicating copy to clipboard operation
nvim-colorizer.lua copied to clipboard

[Feature request] Support user defined color patterns

Open pelegs opened this issue 3 years ago • 4 comments
trafficstars

Could look something like this:

require 'colorizer'.setup {
  '*';
  user_patterns = {
    'LaTeXHTML' = {
        'type' = 'RRGGBB',
        'pattern' = '\\{HTML\\}\\{([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})\\}',
    },
  }
}

In the above example we add a list of user-defined patterns. Each pattern gets a name (in this case there's only one, namely "LaTeXHTML") and a regex to match, where the specification for the regex is given by the type (e.g. RBG, RRGGBB, RRGGBBAAm etc.).

pelegs avatar Oct 12 '22 18:10 pelegs

This would be really awesome e.g. also to have rgb:XXX shortened or fullrgb:XXXXXX pattern.

XVilka avatar Dec 16 '22 03:12 XVilka

I would like this as well. Perfect to highlight tailwind or bootstrap-colors, or some other internal color set.

alex-ross avatar Feb 26 '23 15:02 alex-ross

Agree on this, fish configurations uses RRGGBB without the hash sign (it becomes a comment otherwise).
Adding custom regex support would make configuring my shell colorscheme so much easier!

Update:

For my purpose of visualizing colour codes in .fish files, I noticed that by simply commenting out these two early returns, it would work the specific way I want it to. Do note that this might reduce the performance for it has to check more strings. hack result

leana8959 avatar Apr 06 '23 16:04 leana8959

I would also like this feature a lot, for Tailwind colors in my case, and I'm willing to try to work on it if someone could point me in the right direction, I'm a bit new to Lua Neovim plugins in general. Theoretically the idea seems simple enough, though I'm sure complications will come up in practice.

naiveai avatar Aug 25 '23 03:08 naiveai