Notepad++ provides a function list.
I'm currently using Notepad++ 6.5
functionList.xml defines parsers for function names using regular expressions.
The following code defines the parser for c functions
<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
<function
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
displayMode="$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_~]+"/>
</functionName> </function>
</parser>
I tried my regex online and everything was fine. But it does not work for the functionList.xml somehow. The function list stays empty.
How would this look like for a Lua function?
Here's my try:
<parser id="lua_function" displayName="Lua Function" commentExpr="((--\[\[\*.*?\*)/|(--.*[\n\s\w\t]*\]\]))">
<function
mainExpr="^[\t\s]*(function)[\s]+[\w]+\("
displayMode="$functionName">
<functionName>
<nameExpr expr="(?:(function[\s]+))[\w]+"/>
</functionName>
</function>
</parser>
I use my own definition for Notepad++. It's main difference is supporting of functions like:local SomeFunction = function() end
and function SomeObject:Func() end
. Also it has some basic lua table view compatibilitites.
<!-- Basic lua parser for functionList.xml in Notepad++ 6.5.3 -->
<!-- See http://notepad-plus-plus.org/features/function-list.html -->
<parser id="lua_function" displayName="Lua" commentExpr="--.*?$">
<!-- Basic lua table view, nested lua table not supported -->
<classRange
mainExpr="[.\w]+[\s]*=[\s]*\{"
openSymbole="\{"
closeSymbole="\}"
displayMode="node">
<className>
<nameExpr expr="[.\w]+"/>
</className>
<function
mainExpr="[.\w]+[\s]*=[\s]*['"]?[\w]+['"]?">
<functionName>
<funcNameExpr expr=".*"/>
</functionName>
</function>
</classRange>
<!-- Basic lua functions support -->
<function
mainExpr="(function[\s]+[.\w]+(:[\w]+)?)|([.\w]+[\s]*=[\s]*function)"
displayMode="$className->$functionName">
<functionName>
<nameExpr expr="((?<=function)[\s]+[.:\w]+)|(([.\w]+)(?=([\s]*=[\s]*function)))"/>
</functionName>
<className>
<nameExpr expr="[.\w]+(?=:)"/>
</className>
</function>
</parser>
Also add association
<association id="lua_function" langID="23" />
Two things i have experienced with lua and functions list is that i first have to use functionList.xml inside %appdata%\Notepad++ for it to work, but that could be my installation second is that whats missing from your configruations is 2 things. First the association langID = "23"
<associationMap>
<association langID = "23" id="lua_function"/>
</associationMap>
second being regexp will miss local functions, mine currently looks like this
<parser id="lua_function" displayName="Lua">
<function mainExpr="^[\t|local\s]*function\s+[^0-9][_A-Za-z0-9]+\s*\("
displayMode="$functionName">
<functionName>
<nameExpr expr="[^0-9][_A-Za-z0-9]+\s*\("/>
<nameExpr expr="[^0-9][_A-Za-z0-9]+"/>
</functionName>
</function>
</parser>
adding both to functionList.xml (depending on installation, program files or %appdata%) will make functionlist work for lua language inside Notepad++ 6.5.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With