norcalli / nvim-colorizer.lua

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

Make partial matches for names and #RGB configurable? #14

Closed norcalli closed 4 years ago

norcalli commented 4 years ago

The Blue in Blueberry will be highlighted right now. This is a bug or a feature depending on the user. It's very easy to fix, but is it something that someone might want left in?

resolritter commented 4 years ago

I'm against the behavior you're describing because

  1. It's a unpleasant surprise when it's not wanted
  2. In some cases it will be distracting (e.g. say you're writing a paper about "Blueberry" and this blue highlight suddenly appears in the middle of your text).

I think you could have a lookup table that maps keywords to specific colors if someone comes up with an use-case for it. As I understand it currently, I'd just remove the behavior you're describing and wait for a real need to implement the thing I mentioned.

If you want to keep it, there should at least be a way to turn it off. It makes more sense to turn it off completely, then.

norcalli commented 4 years ago

@resolritter I agree, and I'm actually working on a fix for that right now which I'll be pushing soon. If someone desires the old behaviour, they can ask for it and then I will add it as a configurable option. Prematurely adding features has already bitten me with this plugin by allowing each highlighter to be configurable, which greatly increased the complexity. On average, most people will probably just use css = true rather than the individual options.

norcalli commented 4 years ago

It's kind of hard to implement, though, because it requires looking ahead. Blueberry is fine, but what about BlueGray. Should that be two highlights for Blue Gray or not highlighted?

resolritter commented 4 years ago

IMO only highlight if the whole word (or keyword if there are edge cases?) is a specific match, so only

\<non-word>Blue\<non-word>

would be highlighted.

norcalli commented 4 years ago

Fair enough. I implemented it. I'll release it today.