Arduino language support
-
Just updated N++ to 7.9.1 and having problems with Arduino as a User defined Language. Before the update, I could see highlighted arduino keywords like Pinmode and a Function list was visible. Any idea what may have happened ?
-
Check here to see if
ino
is still set, maybe? : -
I verified this and the User ext: box was empty like it is in your comment. I added ino and it made no difference.
-
Oh, wait, I missed the part about you doing this as a UDL.
I don’t use any UDLs so I’m not familiar with.
Maybe someone else can help with that part.“Function List” has changed how it works in 7.9.1.
But again, we are talking about using it with a UDL, so someone else will have to chime in with help. -
So, with Arduino code (which is just c++, really), you have two choices.
- If you want it to inherit all the features of the c++ lexer (including complex syntax highlighting and folding customized for c++ rules, plus builtin function list support), but just add the automatic association and a few keywords:
- As @Alan-Kilborn said, add
ino
(no dot) to thec++
user ext box - Go into the INSTRUCTION WORD and/or TYPE WORD entries shown in the same screen that Alan showed, and fill in the user-defined keywords list with the Arduino-specific keywords
- If you don’t feel there are enough different colors (like you want to highlight Arduino keywords a different color than c++ keywords), you can add extra highlighting to a builtin lexer (like the C++ lexer) using regexes via the script
EnhanceAnyLexer.py
that @Ekopalypse shares in his github repo (his script works with a UDL, too)
- As @Alan-Kilborn said, add
- If, instead, you want to leverage the UDL you created in an older version of Notepad++ and is still in your list for NPP v7.9.1:
- Make sure the UDL is set up properly:
- Languages > User Defined Language > Define your language
- Pick
Arduino
(or whatever you named it) from the user language dropdown - make sure that ext is set to
ino
(no dot)
- If it’s missing, you will have to re-create the UDL to match what you used to have.
- Make sure you don’t have
ino
in the c++ user ext list if you go this route.
- Function List: Port the Arduino Function List parser that you implied you had into the v7.9.1 structure:
- Close all Notepad++. Open a single new instance of Notepad++.
- Open the old
%AppData%\Notepad++\functionList.xml
🛈 - Copy one of the new
%AppData%\Notepad++\functionList\___.xml
files to%AppData%\Notepad++\functionList\arduino.xml
, and open - Copy the arduino
<parser>...</parser>
section from the old functionList.xml overtop the<parser>...</parser>
section of the newarduino.xml
file - open
%AppData%\Notepad++\functionList\overrideMap.xml
- Copy the
<association id=...
from the old functionList.xml into theoverrideMap.xml
; as explained in the official docs, theid
should be the name of the XML file, soid="arduino.xml"
in my nomenclature.
- References:
- This post gives the overview of the UDL+FunctionList process
- This post had some interim links, but has the useful summary (similar to my section 2.2 here):
To move your customized
functionList.xml
settings to the new format, you move the<association id=...>
from functionList.xml into functionList\overrideMap.xml. And you move the<parser>
section for your individual language into the XML file in the folder. - official UDL overview => https://npp-user-manual.org/docs/user-defined-language-system/
- official Function List overview => https://npp-user-manual.org/docs/function-list/
- official v7.9.1 Function List config file details => https://npp-user-manual.org/docs/config-files/#v7-9-1-and-later-versions
- Make sure the UDL is set up properly:
Since Arduino adds only keywords, and not brand new syntax, to c++, I don’t see a good reason for using UDL; I think the end result would be a lot more usable. But either one will work.
- If you want it to inherit all the features of the c++ lexer (including complex syntax highlighting and folding customized for c++ rules, plus builtin function list support), but just add the automatic association and a few keywords:
-
@PeterJones I went with the 2nd option of keeping the Arduino UDL and creating the arduino.xml and modifying the overrideMap.xml and it worked !
Thank you very much for your awesome support !!