Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dinkumoil
Last active November 13, 2020 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinkumoil/ef6acc8601cb0ef139d418c87c2b828f to your computer and use it in GitHub Desktop.
Save dinkumoil/ef6acc8601cb0ef139d418c87c2b828f to your computer and use it in GitHub Desktop.
Notepad++ FunctionList parser for NppExec plugin scripting language
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==========================================================================\
|
| To learn how to make your own language parser, please check the following
| link:
| https://npp-user-manual.org/docs/function-list/
|
\=========================================================================== -->
<NotepadPlus>
<functionList>
<!-- ===================================================== [ NppExec ] -->
<parser
displayName="NppExec"
id ="nppexec_syntax"
>
<!-- Define NppExec script as the range started by a pair of colons
and ending right before the next pair of colons or the file's
end, respectively
-->
<classRange
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
(?ims) # ignore case, ^ and $ match start/end of line, dot matches newline
^\h*
::
.*?
(?=::|\Z)
"
>
<className>
<!-- The script's name is shown without its preceding pair
of colons
-->
<nameExpr expr="(?im-s)^\h*::\K(?:(.+?)(?=\h*\/{2}|$))" />
</className>
<!-- Define jump labels as functions. Names are starting with one
or two colons (thus the script's name itself is shown as a
function) and terminated by a line comment, the line's end
or the file's end
-->
<function
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`)
(?im-s) # ignore case, ^ and $ match start/end of line, dot doesn't match newline
^\h*
:{1,2}.+?
\h*(?=\/{2}|$|\Z)
"
>
<functionName>
<!-- The script name is shown including its preceding pair
of colons, jump labels are shown without the preceding
single colon
-->
<funcNameExpr expr="(?im-s)\h*(?(?=::)(.+)|(?::\K(.+)))" />
</functionName>
</function>
</classRange>
</parser>
</functionList>
</NotepadPlus>
@dinkumoil
Copy link
Author

dinkumoil commented Nov 13, 2020

Prerequisites

To get a working function list for NppExec scripts you also need a user defined language (UDL) for syntax highlighting NppExec scripts. You can obtain a ready-made UDL file here.

Installation

  1. Download the ZIP file with the code above.
  2. Unzip the downloaded file to a folder on your harddisk where you have write permissons.

The following steps depend on the version of Notepad++ you use.

Notepad++ versions prior to v7.9.1

  1. Open the XML file you unzipped in the steps above with Notepad++.
  2. a) If you use an installed version of Notepad++: Open your user profile folder and navigate to folder AppData\Roaming\Notepad++. If the AppData folder is not shown in your user profile folder, you need to go to the Windows Explorer folder options and enable the display of hidden files and folders..
    b) If you use a portable version of Notepad++: Open the folder where your notepad++.exe resides.
  3. Open file functionList.xml from that folder with Notepad++.
  4. From the downloaded XML file, copy the whole /NotepadPlus/functionList/parser XML node into the file functionList.xml as a child node of the /NotepadPlus/functionList/parsers XML node.
  5. In file functionList.xml go to the XML node /NotepadPlus/functionList/associationMap. There you will find XML nodes like <association id="xxx" userDefinedLangName="xxx" />.
  6. Add a new node like this: <association id="nppexec_syntax" userDefinedLangName="NppExec" />. Please note: The value of the userDefinedLangName attribute has to be the same like in the UDL file's /NotepadPlus/UserLang XML node's name attribute. In case you downloaded the UDL file from the link given above, everything is already set up the right way.

Notepad++ version v7.9.1 and above

  1. a) If you use an installed version of Notepad++: Open your user profile folder and navigate to folder AppData\Roaming\Notepad++. If the AppData folder is not shown in your user profile folder, you need to go to the Windows Explorer folder options and enable the display of hidden files and folders.
    b) If you use a portable version of Notepad++: Open the folder where your notepad++.exe resides.
  2. Open folder functionList and move the XML file you downloaded and unzipped in the steps above to this folder.
  3. Open file overrideMap.xml from the folder functionList and go to the XML node /NotepadPlus/functionList/associationMap. There you will find XML nodes like <association id="xxx.xml" userDefinedLangName="xxx" />.
  4. Add a new node like this: <association id="nppexec.xml" userDefinedLangName="NppExec" />. Please note: The value of the userDefinedLangName attribute has to be the same like in the UDL file's /NotepadPlus/UserLang XML node's name attribute. In case you downloaded the UDL file from the link given above, everything is already set up the right way. Additionally, the value of the id attribute has to be the file name of the XML file you moved to the functionList folder in step 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment