How to add custom color to a tag in json language
-
Is it possible to add a custom tag and color to the default json language? For example, if the tag would be ‘MyCustomError’ it would be red, ‘MyCustomComment’ green and so on…
I tried to add it to langs.model.xml and/or stylers.model.xml, but so far couldn’t figure it out yet.
Thanks!
-
Sorry, builtin languages don’t work that way. The syntaxes that they highlight are compiled into the Notepad++ executable, and you cannot add an extra style to the list just by editing the config file, because the compiled code doesn’t know what to do with that extra data (and just ignores it).
Your next choice is to use a User Defined Language (UDL), which would mean starting from scratch and not inheriting the existing highlighting from the builtin JSON lexer. You probably wouldn’t be able to replicate the existing behavior exactly, so that’s not likely what you want.
Finally, you can add extra highlighting to a builtin lexer (like the JSON lexer) or to a User Defined Language (UDL) using regexes via the PythonScript plugin in conjunction with the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo – that script has the documentation of how to use it. -
@peterjones Thanks, I’ll check it out.