Cannot get Autocompletion to work for my own language
-
Debug Info:
Notepad++ v8.8.1 (64-bit)
Build time : May 3 2025 - 18:41:09
Scintilla/Lexilla included : 5.5.6/5.4.4
Boost Regex included : 1_85
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
Scintilla Rendering Mode : SC_TECHNOLOGY_DIRECTWRITE (1)
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Pro (64-bit)
OS Version : 24H2
OS Build : 26100.2605
Current ANSI codepage : 1252
Plugins :
mimeTools (3.1)
NppConverter (4.6)
NppExport (0.4)
I cannot get Autocompletion to work for my own language “SparkleFlow”
I have the SparkleFlow.xml in directory C:\Program Files\NotePad++\autoCompletion with the following code:
They are not complete yet, but I am trying the basic autocomplete functionality.<?xml version="1.0" encoding="Windows-1252" ?> <NotepadPlus> <AutoComplete> <Environment ignoreCase="yes" startFunc="(" stopFunc=")" paramSeparator="," terminal=";" additionalWordChar=":" /> <KeyWord name=":FUNCT-SETTEXT"> <Overload retVal="void" descr="Set a value in the STATUS.DAT file."> <Param name="Section" /> <Param name="Key" /> <Param name="Value" /> </Overload> </KeyWord> <KeyWord name=":FUNCT-DISPLAYMESSAGE"> <Overload retVal="void" descr="Display a message."> <Param name="Message" /> </Overload> </KeyWord> <KeyWord name=":FUNCT-GETAPPLICATIONDETAILSVALUE"> <Overload retVal="string" descr="Read Application Details into a variable."> <Param name="TabNumber" /> <Param name="ItemNumber" /> <Param name="TargetVariable" /> </Overload> </KeyWord> <KeyWord name=":FUNCT-REPLACETEXT"> <Overload retVal="string" descr="Replace text in a string."> <Param name="TargetVariable" /> <Param name="SourceVariable" /> <Param name="SearchString" /> <Param name="ReplaceString" /> </Overload> </KeyWord> </AutoComplete> </NotepadPlus>I have the SparkleFlow.xml in directory %APPDATA%\Notepad++\userDefineLangs with the following code:
<?xml version="1.0" encoding="Windows-1252"?> <NotepadPlus> <UserLang name="SparkleFlow" ext="dat ini" udlVersion="2.1"> <Settings> <Global caseIgnored="yes" allowFoldOfComments="yes" foldCompact="yes" forcePureLC="2" decimalSeparator="0" /> <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="yes" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments">00; 01//</Keywords> <Keywords name="Keywords1">:FUNCT-DISPLAYMESSAGE :GOTO :IF :SET :COPY :WAIT :SAVE :LOAD :EXECUTE</Keywords> <Keywords name="Keywords2">[CONSTANTS] [STATUSNAMES] [FASENAMES] [FASE2STATUSOK] [FASE2STATUSREJECT] [STATUS2FASE] [ACTIONFASE] [FASECONTROLSETTINGS] [STARTSTATUSFASE] [NEWPACKAGENAME] [SF-DATA_NEWPACKAGENAME_EDITFIELDS] [RESETPASSWORD]</Keywords> <Keywords name="Keywords3">COUNT STARTDESCRIPTION ACCEPTDESCRIPTION REJECTDESCRIPTION ADJUSTPACKAGENAME ACTIVE SEPARATOR REPLACE ORDER DELETELEADINGANDTRAILINGSPACES</Keywords> <Keywords name="Keywords4">PROJECTPATH ARCHIVEPATH COMMENTSPATH DOCPATH HISTORYPATH LOGGINGPATH STATUSPATH</Keywords> </KeywordLists> <Styles> <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" /> <WordsStyle name="COMMENTS" fgColor="008000" bgColor="FFFFFF" fontStyle="2" /> <WordsStyle name="LINE COMMENTS" fgColor="008000" bgColor="FFFFFF" fontStyle="2" /> <WordsStyle name="KEYWORDS1" fgColor="000080" bgColor="FFFFFF" fontStyle="1" /> <WordsStyle name="KEYWORDS2" fgColor="800000" bgColor="FFFFFF" fontStyle="1" /> <WordsStyle name="KEYWORDS3" fgColor="008080" bgColor="FFFFFF" fontStyle="0" /> <WordsStyle name="KEYWORDS4" fgColor="800080" bgColor="FFFFFF" fontStyle="0" /> </Styles> <CommentPattern open=";" close="" /> <CommentPattern open="//" close="" /> <Delimiters> <Delimiter begin="[" end="]" fold="yes" /> <Delimiter begin=""" end=""" /> </Delimiters> </UserLang> </NotepadPlus>What am I doing wrong?
Kind Regards,
Paul Cobben -
@Paul-Cobben said in Cannot get Autocompletion to work for my own language:
What am I doing wrong?
Per the User Manual section on the autoCompletion definition file syntax (https://npp-user-manual.org/docs/auto-completion/#create-auto-completion-definition-files), with emphasis added:
The basic character set used to recognize keywords is made of letters
a-z,A-Z, digits0-9, and the underscore_. Punctuation might work for auto-completion; however, if you want to use the parameter hints, you should not use punctuation in the keyword name.You are relying on the
:at the start of the keyword and the-in the middle. This is a double-whammy against you. However, if you go to Settings > Preferences > Delimiter and set ⦿ Add your character as part of word to:-so that those two characters are more “word-like”, then restart Notepad++, it will be able to show up in the function-name autoCompletion:
However, the parameter hint portion has two more problems:
- The easy one is you need
func="yes"in the<KeyWord name="..." func="yes">tags, otherwise Notepad++ doesn’t pay attention to the overload/param elements nested in the KeyWord. - This might not ever work, because the internal regex that Notepad++ uses to determine if it’s valid to prompt for function parameters refuses to work because of the
-in the keyword. If I have the delimiter setting as above, and added a keyword:FUNCT_SETTEXTwhich has the:as the prefix but does not include the hyphen, like:
then when I type<KeyWord name=":FUNCT_SETTEXT" func="yes"> <Overload retVal="void" descr="Set a value in the STATUS.DAT file."> <Param name="Section" /> <Param name="Key" /> <Param name="Value" /> </Overload> <KeyWord>:FUNCT_SETTEXT(, it will prompt with the parameter hints as well:
- As a workaround, you could “cheat” the
-limitation by defining a second keyword which includes just the stuff that comes after the-in the keyword, like,
This will allow Notepad++ to see the<KeyWord name="SETTEXT" func="yes"> <Overload retVal="void" descr="Set a value in the STATUS.DAT file."> <Param name="Section" /> <Param name="Key" /> <Param name="Value" /> </Overload> </KeyWord>-as a boundary and then theSETTEXTas a separate function, which then allows for the function parameter completion, as in this screenshot:
(notice that it thinks the function isSETTEXT, not:FUNCT-SETTEXT, when doing the parameter prompting) - Since punctuation isn’t guaranteed in function/parameter autoCompletion, that’s likely not going to be “fixed”, as it’s already relying on an unspecified edge case.
- As a workaround, you could “cheat” the
In conclusion, if you just want the function autocompletion for the names with leading
:and embedded-, you can do that by setting the Delimiter setting to:-, and it will work as in my first screenshot. If you want parameter hints when there are not hyphens in your function name, you can get that by setting thefunc="yes"in your<KeyWord...>tags, and that will work as in my second screenshot. Unfortunately, you cannot get the parameter hints directly if your keyword has the-because of a limitation in the internal processing that decides when parameter hints can be shown (though you can trick it as shown in item3). - The easy one is you need
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login