noahgorstein / jqp

A TUI playground to experiment with jq
MIT License
2.19k stars 40 forks source link

RFC: Configurable Chroma theme overrides #27

Closed ktprograms closed 1 year ago

ktprograms commented 2 years ago

I personally like the vulcan theme, except that the KeywordConstant token uses a grey background.

The ability to override specific parts of a theme in the config file would be nice.

There is a map of TokenType to string in chroma, which can be used in combination with a chroma.StyleBuilder to override specific parts.

For the configuration, I propose a subkey to the theme:, like overrides:. For example:

theme: "vulcan"
  overrides:
    - "kc": "#CF5967"
    - "nf": "#FFFFFF bold"

The quick.Highlight function only supports the chroma style name, so it can't be used with customized styles, but the function itself is only about 28 lines of code (less if we hardcode lexer and formatter), so it's feasible to copy it and allow it to take a chroma.Style directly (the change is also just removing 3 lines).

ktprograms commented 2 years ago

If this wasn't clear in my initial comment, I will do the implementing if going forward with this is okay.