Implementation
final nsis = Mode(
refs: {
'~contains~6~contains~4':
Mode(className: "variable", begin: "\\\$+\\([\\w^.:!-]+\\)"),
'~contains~6~contains~3': Mode(
className: "variable",
begin: "\\\$+\\w[\\w\\.]*",
illegal: "\\(\\)\\{\\}"),
'~contains~6~contains~2':
Mode(className: "variable", begin: "\\\$+\\{[\\!\\w.:-]+\\}"),
},
name: "NSIS",
case_insensitive: true,
keywords: {
"keyword": [
"Abort",
"AddBrandingImage",
"AddSize",
"AllowRootDirInstall",
"AllowSkipFiles",
"AutoCloseWindow",
"BGFont",
"BGGradient",
"BrandingText",
"BringToFront",
"Call",
"CallInstDLL",
"Caption",
"ChangeUI",
"CheckBitmap",
"ClearErrors",
"CompletedText",
"ComponentText",
"CopyFiles",
"CRCCheck",
"CreateDirectory",
"CreateFont",
"CreateShortCut",
"Delete",
"DeleteINISec",
"DeleteINIStr",
"DeleteRegKey",
"DeleteRegValue",
"DetailPrint",
"DetailsButtonText",
"DirText",
"DirVar",
"DirVerify",
"EnableWindow",
"EnumRegKey",
"EnumRegValue",
"Exch",
"Exec",
"ExecShell",
"ExecShellWait",
"ExecWait",
"ExpandEnvStrings",
"File",
"FileBufSize",
"FileClose",
"FileErrorText",
"FileOpen",
"FileRead",
"FileReadByte",
"FileReadUTF16LE",
"FileReadWord",
"FileWriteUTF16LE",
"FileSeek",
"FileWrite",
"FileWriteByte",
"FileWriteWord",
"FindClose",
"FindFirst",
"FindNext",
"FindWindow",
"FlushINI",
"GetCurInstType",
"GetCurrentAddress",
"GetDlgItem",
"GetDLLVersion",
"GetDLLVersionLocal",
"GetErrorLevel",
"GetFileTime",
"GetFileTimeLocal",
"GetFullPathName",
"GetFunctionAddress",
"GetInstDirError",
"GetKnownFolderPath",
"GetLabelAddress",
"GetTempFileName",
"GetWinVer",
"Goto",
"HideWindow",
"Icon",
"IfAbort",
"IfErrors",
"IfFileExists",
"IfRebootFlag",
"IfRtlLanguage",
"IfShellVarContextAll",
"IfSilent",
"InitPluginsDir",
"InstallButtonText",
"InstallColors",
"InstallDir",
"InstallDirRegKey",
"InstProgressFlags",
"InstType",
"InstTypeGetText",
"InstTypeSetText",
"Int64Cmp",
"Int64CmpU",
"Int64Fmt",
"IntCmp",
"IntCmpU",
"IntFmt",
"IntOp",
"IntPtrCmp",
"IntPtrCmpU",
"IntPtrOp",
"IsWindow",
"LangString",
"LicenseBkColor",
"LicenseData",
"LicenseForceSelection",
"LicenseLangString",
"LicenseText",
"LoadAndSetImage",
"LoadLanguageFile",
"LockWindow",
"LogSet",
"LogText",
"ManifestDPIAware",
"ManifestLongPathAware",
"ManifestMaxVersionTested",
"ManifestSupportedOS",
"MessageBox",
"MiscButtonText",
"Name|0",
"Nop",
"OutFile",
"Page",
"PageCallbacks",
"PEAddResource",
"PEDllCharacteristics",
"PERemoveResource",
"PESubsysVer",
"Pop",
"Push",
"Quit",
"ReadEnvStr",
"ReadINIStr",
"ReadRegDWORD",
"ReadRegStr",
"Reboot",
"RegDLL",
"Rename",
"RequestExecutionLevel",
"ReserveFile",
"Return",
"RMDir",
"SearchPath",
"SectionGetFlags",
"SectionGetInstTypes",
"SectionGetSize",
"SectionGetText",
"SectionIn",
"SectionSetFlags",
"SectionSetInstTypes",
"SectionSetSize",
"SectionSetText",
"SendMessage",
"SetAutoClose",
"SetBrandingImage",
"SetCompress",
"SetCompressor",
"SetCompressorDictSize",
"SetCtlColors",
"SetCurInstType",
"SetDatablockOptimize",
"SetDateSave",
"SetDetailsPrint",
"SetDetailsView",
"SetErrorLevel",
"SetErrors",
"SetFileAttributes",
"SetFont",
"SetOutPath",
"SetOverwrite",
"SetRebootFlag",
"SetRegView",
"SetShellVarContext",
"SetSilent",
"ShowInstDetails",
"ShowUninstDetails",
"ShowWindow",
"SilentInstall",
"SilentUnInstall",
"Sleep",
"SpaceTexts",
"StrCmp",
"StrCmpS",
"StrCpy",
"StrLen",
"SubCaption",
"Unicode",
"UninstallButtonText",
"UninstallCaption",
"UninstallIcon",
"UninstallSubCaption",
"UninstallText",
"UninstPage",
"UnRegDLL",
"Var",
"VIAddVersionKey",
"VIFileVersion",
"VIProductVersion",
"WindowIcon",
"WriteINIStr",
"WriteRegBin",
"WriteRegDWORD",
"WriteRegExpandStr",
"WriteRegMultiStr",
"WriteRegNone",
"WriteRegStr",
"WriteUninstaller",
"XPStyle"
],
"literal": [
"admin",
"all",
"auto",
"both",
"bottom",
"bzip2",
"colored",
"components",
"current",
"custom",
"directory",
"false",
"force",
"hide",
"highest",
"ifdiff",
"ifnewer",
"instfiles",
"lastused",
"leave",
"left",
"license",
"listonly",
"lzma",
"nevershow",
"none",
"normal",
"notset",
"off",
"on",
"open",
"print",
"right",
"show",
"silent",
"silentlog",
"smooth",
"textonly",
"top",
"true",
"try",
"un.components",
"un.custom",
"un.directory",
"un.instfiles",
"un.license",
"uninstConfirm",
"user",
"Win10",
"Win7",
"Win8",
"WinVista",
"zlib"
]
},
contains: [
HASH_COMMENT_MODE,
C_BLOCK_COMMENT_MODE,
Mode(
scope: "comment",
begin: ";",
end: "\$",
contains: [
Mode(
scope: "doctag",
begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
end: "(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",
excludeBegin: true,
relevance: 0),
Mode(
begin:
"[ ]+((?:I|a|is|so|us|to|at|if|in|it|on|[A-Za-z]+['](d|ve|re|ll|t|s|n)|[A-Za-z]+[-][a-z]+|[A-Za-z][a-z]{2,})[.]?[:]?([.][ ]|[ ])){3}")
],
relevance: 0),
Mode(
match: ["Var", "\\s+", "(?:\\/GLOBAL\\s+)?", "[A-Za-z][\\w.]*"],
scope: {"1": "keyword", "3": "params", "4": "variable"}),
Mode(
match: ["Function", "\\s+", "(\\.)?[a-zA-Z]\\w*"],
scope: {"1": "keyword", "3": "title.function"}),
Mode(
beginKeywords:
"Function PageEx Section SectionGroup FunctionEnd SectionEnd"),
Mode(
className: "string",
variants: [
Mode(begin: "\"", end: "\""),
Mode(begin: "'", end: "'"),
Mode(begin: "`", end: "`")
],
illegal: "\\n",
contains: [
Mode(className: "char.escape", begin: "\\\$(\\\\[nrt]|\\\$)"),
Mode(
className: "variable.constant",
begin:
"\\\$(?:ADMINTOOLS|APPDATA|CDBURN_AREA|CMDLINE|COMMONFILES32|COMMONFILES64|COMMONFILES|COOKIES|DESKTOP|DOCUMENTS|EXEDIR|EXEFILE|EXEPATH|FAVORITES|FONTS|HISTORY|HWNDPARENT|INSTDIR|INTERNET_CACHE|LANGUAGE|LOCALAPPDATA|MUSIC|NETHOOD|OUTDIR|PICTURES|PLUGINSDIR|PRINTHOOD|PROFILE|PROGRAMFILES32|PROGRAMFILES64|PROGRAMFILES|QUICKLAUNCH|RECENT|RESOURCES_LOCALIZED|RESOURCES|SENDTO|SMPROGRAMS|SMSTARTUP|STARTMENU|SYSDIR|TEMP|TEMPLATES|VIDEOS|WINDIR)"),
Mode(ref: '~contains~6~contains~2'),
Mode(ref: '~contains~6~contains~3'),
Mode(ref: '~contains~6~contains~4')
]),
Mode(
className: "keyword",
begin:
"!(?:addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversion|gettlbversion|if|ifdef|ifmacrodef|ifmacrondef|ifndef|include|insertmacro|macro|macroend|makensis|packhdr|searchparse|searchreplace|system|tempfile|undef|uninstfinalize|verbose|warning)"),
Mode(ref: '~contains~6~contains~2'),
Mode(ref: '~contains~6~contains~3'),
Mode(ref: '~contains~6~contains~4'),
Mode(
className: "params",
begin:
"(?:ARCHIVE|FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_NORMAL|FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_TEMPORARY|HKCR|HKCU|HKDD|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_DYN_DATA|HKEY_LOCAL_MACHINE|HKEY_PERFORMANCE_DATA|HKEY_USERS|HKLM|HKPD|HKU|IDABORT|IDCANCEL|IDIGNORE|IDNO|IDOK|IDRETRY|IDYES|MB_ABORTRETRYIGNORE|MB_DEFBUTTON1|MB_DEFBUTTON2|MB_DEFBUTTON3|MB_DEFBUTTON4|MB_ICONEXCLAMATION|MB_ICONINFORMATION|MB_ICONQUESTION|MB_ICONSTOP|MB_OK|MB_OKCANCEL|MB_RETRYCANCEL|MB_RIGHT|MB_RTLREADING|MB_SETFOREGROUND|MB_TOPMOST|MB_USERICON|MB_YESNO|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)"),
Mode(className: "title.function", begin: "\\w+::\\w+"),
NUMBER_MODE
]);