bmalehorn / vscode-fish

Fish syntax highlighting and formatting
MIT License
62 stars 6 forks source link

Add color highlighting #15

Closed IlanCosman closed 3 years ago

IlanCosman commented 3 years ago

https://marketplace.visualstudio.com/items?itemName=naumovs.color-highlight is a very popular and useful extension.

This extension only activates when using a # before the hexcode or optionally on color words like red, blue, etc.

nocolorfoo

redfoo

#foo

Since fish uses # as it's comment delimiter, obviously this last function wouldn't work correctly.

I propose that color codes and color words be highlighted after a set_color. If you're feeling very adventurous you could mimic exactly what set_color would do, for example underlining the next word when using set_color --underline, bolding the next work when using set_color --bold etc. Perhaps more easily you could bold the --bold option and underline the --underline option. Just highlighting based on color would be lovely however.

bmalehorn commented 3 years ago

Ah, that's a neat extension! I tried installing this extension and experimenting with it. While fish won't parse set_color #00AFAF as you'd hope, it looks like I can get the behavior you're looking for by writing set_color '#00AFAF':

image

@IlanCosman does that work well enough for you?

I'm apprehensive to add it to the fish extension, as:

  1. it's not an official part of the fish language
  2. it would require properly parsing the fish document, which I currently do with a bunch of gnarly regexes
  3. I've encountered poor performance from coloring extensions in the past, since they parse the whole document at each keystroke

However the above workaround seems pretty reasonable and still useful.

IlanCosman commented 3 years ago

Thanks for the reply 😄 I suppose I didn't play around enough, I hadn't even considered that set_color would accept that; thanks for the tip. The workaround is reasonable but makes the whole thing feel rather clunky. Rather, I think I will make a fish issue to have set_color colorize its arguments, as that would solve this problem and be a nice feature regardless.