Lua: cannot add additional styles
-
Hello, I am trying to add new styles for syntax highlighting, and I can see them in the Style Configurator, but they do not work. I can change the colors, add more words, but they are never highlighted.
I added these lines to test : (in DarkModeDefault.xml, from %appdata%)
The style id’s I found here : https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/lexilla/lexers/LexLua.cxx(can’t post links, sorry :(<WordsStyle name="FUNC4" styleID="16" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type3">Test4</WordsStyle> <WordsStyle name="FUNC5" styleID="17" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type4">Test5</WordsStyle> <WordsStyle name="FUNC6" styleID="18" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type5">Test6</WordsStyle> <WordsStyle name="FUNC7" styleID="19" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type6">Test7</WordsStyle>
And in langs.xml (also from appdata)
<Keywords name="type3">Lang3</Keywords> <Keywords name="type4">Lang4</Keywords> <Keywords name="type5">Lang5</Keywords> <Keywords name="type6">Lang6</Keywords>
From what I’ve checked, this should work, the code from the lexer even seems to suggest that it is correct, but when I type one of the words I added, it does not get highlighted.
I only tried with Lua, not with another language.
Any idea ?
Thanks in advance,
Thaoky----
moderator linkified for you -
@Thaoky said in Lua: cannot add additional styles:
From what I’ve checked, this should work, the code from the lexer even seems to suggest that it is correct, but when I type one of the words I added, it does not get highlighted.
Notepad++ also would be needed to be compiled to send the other four lists.
As of the most recent commit, ScintillaEditView.h only passes four keyword lists to the Lua lexer, not all 8:void setLuaLexer() { setLexer(L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3); };
Thus, defining them in the XML files isn’t sufficient; Notepad++ would have to be recompiled to send all 8 lists.
void setLuaLexer() { setLexer(L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6 | LIST_7); };
Once recompiled, then Notepad++ would be able to see the additional keywords, and be able to apply any stylings that were put into the XML.
I only tried with Lua, not with another language.
Notepad++ decides on a language-by-language basis how many keyword lists to send to the lexer; sometimes, the number of lists has kept up with improvements in the Lexilla source; other times, it lags behind. (Based on the blame for that section of code, it looks like Notepad++ has only sent four keyword lists to the Lua lexer for at least 15 years)
If I have time this weekend, I will try to do a test build to see if I can get that working. Unfortunately, since v8.6.6 is in RC, even if you created an issue and I had the time to do a PR right way, it wouldn’t likely be added – because once a release is in RC-status, “new feature” PR generally wait until after the release before being merged. But if you wanted to put in an issue now, I would claim it… and hopefully it would be able to be in v8.6.7. (When I do a PR, I would also put in entries for
stylers.xml
,themes\*.xml
, andlangs.xml
so that people with fresh installs would be able to see those new styles and empty keyword lists in the GUI, and be able to add their own keywords.) -
@PeterJones Thanks for the reply, I understand your point. No worry about not getting it in the next release, as long as this is looked at and sorted out in the future, I am already happy :)
Much appreciated !
-
Here is the link to the issue : https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15081
-
@Thaoky ,
If you want to try out my attempt, you can go to https://github.com/pryrt/notepad-plus-plus/actions/runs/8953221473 and download the appropriate build. Most likely, you will want the “Notepad++.MSVC.x64.Release”, which is the normal 64bit build – you will have to scroll to the bottom of that page to see the download links for each build.
That set of builds has the four remaining Lua keyword lists enabled;
langs.model.xml
comes prepopulated with one dummy keyword per list; andstylers.model.xml
is updated similarly to your excerpt earlier (for the default style, not the DarkModeDefault theme). I will be getting to the other themes eventually (and removing the dummy keywords), but I wanted to share this as soon as I had success.To future readers: GitHub will only keep those artifacts for about a month, so if it’s June 2024 or later, they will likely not be available for download; hopefully by then, the updated Lua keyword lists will at least be queued for the next release, or maybe even be in the released app already.
-
@PeterJones Very nice. Seems to be working OK in my testing with
USER KEYWORD 1
.Here is a compare for others to see the changes and to possibly copy some of the theme files changes as I did to existing xml files for testing.
-
@PeterJones Same here, just tested, and it works as intended !
Huge thanks :)
-