• Login
Community
  • Login

Cannot get Autocompletion to work for my own language

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 130 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    Paul Cobben
    last edited by Paul Cobben Jun 18, 2025, 1:32 PM Jun 18, 2025, 12:21 PM

    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)

    aeffb5e7-258f-4de8-95ae-9aeebf6c7dbe-image.png

    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="&quot;" end="&quot;" />
        </Delimiters>
      </UserLang>
    </NotepadPlus>
    
    

    What am I doing wrong?

    Kind Regards,
    Paul Cobben

    P 1 Reply Last reply Jun 18, 2025, 3:16 PM Reply Quote 0
    • P
      PeterJones @Paul Cobben
      last edited by PeterJones Jun 18, 2025, 3:17 PM Jun 18, 2025, 3:16 PM

      @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, digits 0-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:

      6c680cbc-5b88-4169-b76d-affbf204618e-image.png

      However, the parameter hint portion has two more problems:

      1. 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.
      2. 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_SETTEXT which has the : as the prefix but does not include the hyphen, like:
        <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>
        
        then when I type :FUNCT_SETTEXT(, it will prompt with the parameter hints as well: bf355c03-a51b-45ad-b0a3-47534ee92e2d-image.png
        • 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,
          <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>
          
          This will allow Notepad++ to see the - as a boundary and then the SETTEXT as a separate function, which then allows for the function parameter completion, as in this screenshot: d52f6232-de08-4b85-89cc-e2b852801a90-image.png
          (notice that it thinks the function is SETTEXT, 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.

      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 the func="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).

      1 Reply Last reply Reply Quote 3
      1 out of 2
      • First post
        1/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors