norcalli / nvim-colorizer.lua

The fastest Neovim colorizer.
Other
2.23k stars 117 forks source link

[Feature request] Support user defined color patterns #93

Open pelegs opened 1 year ago

pelegs commented 1 year ago

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.).

XVilka commented 1 year ago

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

alex-ross commented 1 year ago

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

leana8959 commented 1 year ago

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

naiveai commented 1 year ago

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.