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 ?



  • @JP-Roy

    Check here to see if ino is still set, maybe? :

    5b91403b-211e-439d-ac69-1dc10e62db08-image.png



  • I verified this and the User ext: box was empty like it is in your comment. I added ino and it made no difference.



  • @JP-Roy

    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.



  • @JP-Roy

    So, with Arduino code (which is just c++, really), you have two choices.

    1. 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:
      1. As @Alan-Kilborn said, add ino (no dot) to the c++ user ext box
      2. 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
      3. 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)
    2. 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:
      1. Make sure the UDL is set up properly:
        1. Languages > User Defined Language > Define your language
        2. Pick Arduino (or whatever you named it) from the user language dropdown
        3. make sure that ext is set to ino (no dot)
          6a0b448c-3f43-417d-99d6-1ade4ee743e2-image.png
        4. If it’s missing, you will have to re-create the UDL to match what you used to have.
        5. Make sure you don’t have ino in the c++ user ext list if you go this route.
      2. Function List: Port the Arduino Function List parser that you implied you had into the v7.9.1 structure:
        1. Close all Notepad++. Open a single new instance of Notepad++.
        2. Open the old %AppData%\Notepad++\functionList.xml 🛈
        3. Copy one of the new %AppData%\Notepad++\functionList\___.xml files to %AppData%\Notepad++\functionList\arduino.xml, and open
        4. Copy the arduino <parser>...</parser> section from the old functionList.xml overtop the <parser>...</parser> section of the new arduino.xml file
        5. open %AppData%\Notepad++\functionList\overrideMap.xml
        6. Copy the <association id=... from the old functionList.xml into the overrideMap.xml; as explained in the official docs, the id should be the name of the XML file, so id="arduino.xml" in my nomenclature.
      3. References:

    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.



  • @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 !!


Log in to reply