php additional syntax highlighting
First of all, big thanks for this great editor !
I’m trying to add a WordsStyle named KEYWORD to distinguish between PHP functions and keywords like “class”, “function”, “break”, “return” etc.
To start of with just a few keywords, I’ve added <Keywords name=“type1”>break class function</Keywords> to langs.xml and removed those keywords from <Keywords name=“instre1”> and added <WordsStyle name=“KEYWORD” styleID=“16” fgColor=“FFFF00” bgColor=“FEFCF5” fontName="" fontStyle=“7” fontSize="" keywordClass=“type1” /> to stylers.xml.
The WordStyle KEYWORD is now visible in np++ (Settings > Style Configurator -> php) but the syntax coloring isn’t applied to the keywords, in fact, they have no syntax coloring at all now, just the default black color. When I add more keywords in np++, they get added to stylers.xml but they also don’t get highlighted. I’ve also tried keywordClass=“instre2” and tried a few different styleIDs, but nothing happens to the highlighting.
Please advice ! Is it at all possible to add to php syntax highlighting, i.e. some combination of keywordClass and styleID that will work, or am I waisting time ?
What categories there are available for a given language are defined by that language’s lexer; unfortunately, you cannot add new categories. (Well, like you saw, you can add anything you like to stylers.xml… but if the php lexer isn’t programmed to match words in that category, and to pass on the category to scintilla to mark it with a particular style, nothing will happen.)
Many of the languages allow adding new keywords to a given category; in
php, if you wait long enough on the
WORDstyle, it pops up the default and user-defined keyword lists, so you could add words to that category – however, I don’t see that it’s implemented any other
styles of keywords.
So, with the builtin lexer, I don’t think you’re going to be able to add a separate style/category of keywords, sorry.
You might be able to come up with a UDL to highlight the words as you desire (but UDL highlighting often falls short in areas that the custom lexers excel in, so you may have to give up something in order to get the two different categories of keywords).