Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: keywords and direcives highlight #354

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion language/ahk.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ repository:
'2':
name: comment.line.semicolon.directive.ahk
match: >-
#\b(?i:allowsamelinecomments|clipboardtimeout|commentflag|errorstdout|escapechar|hotkeyinterval|hotkeymodifiertimeout|hotstring|iftimeout|ifwinactive|ifwinexist|ifwinnotactive|ifwinnotexist|inputlevel|installkeybdhook|installmousehook|keyhistory|ltrim|maxhotkeysperinterval|maxmem|maxthreads|maxthreadsbuffer|maxthreadsperhotkey|menumaskkey|noenv|notrayicon|persistent|requires|singleinstance|usehook|warn|winactivateforce)\b(.*?)(\s+;.*)?$
#\b(?i:allowsamelinecomments|clipboardtimeout|commentflag|delimiter|derefchar|errorstdout|escapechar|hotkeyinterval|hotkeymodifiertimeout|hotstring|iftimeout|ifwinactive|ifwinexist|ifwinnotactive|ifwinnotexist|inputlevel|installkeybdhook|installmousehook|keyhistory|ltrim|maxhotkeysperinterval|maxmem|maxthreads|maxthreadsbuffer|maxthreadsperhotkey|menumaskkey|noenv|notrayicon|persistent|requires|singleinstance|usehook|warn|winactivateforce)\b(.*?)(\s+;.*)?$
name: keyword.control.directives.ahk
example: '#persistent'
- match: >-
Expand Down Expand Up @@ -173,6 +173,8 @@ repository:
name: keyword.other.ahk
- match: (?i)\b(?<=\bFormatTime\b\s*,?[^,]+,[^,]*,\s*)(Time|ShortDate|LongDate|YearMonth|YDay|YDay0|WDay|YWeek)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bGetKeyState\b\s*,?[^,]+,[^,]+,\s*)(P|T)\b
name: keyword.other.ahk
# GUI Sub-Commands
- match: (?i)\b(?<=\bGui\b\s*,?\s*((\w+|%\w+%):\s*)?)(New|Add|Show|Submit|Cancel|Hide|Destroy|Font|Color|Margin|Menu|Minimize|Maximize|Restore|Flash|Default|ListView)\b
name: keyword.other.ahk
Expand Down Expand Up @@ -249,8 +251,14 @@ repository:
name: keyword.other.ahk
- match: (?i)\b(?<=\bIfMsgBox\s*,?\s*)(Yes|No|OK|Cancel|Abort|Ignore|Retry|Continue|TryAgain|Timeout)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bInputBox\b\s*,?[^,]+,[^,]+,[^,]+,\s*)(HIDE)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bLoop\b\s*,?\s*)(Files|Parse|Read|Reg)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bLoop\b\s*,?\s*Files\s*,[^,]+,\s*)(DF?R?|DR?F?|FD?R?|FR?D?|RD?F?|RF?D?)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bLoop\b\s*,?\s*Parse\s*,[^,]+,\s*)(CSV)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bLoop\b\s*,?\s*Reg\s*,\s*)(HKEY_LOCAL_MACHINE|HKEY_USERS|HKEY_CURRENT_USER|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKLM|HKU|HKCU|HKCR|HKCC)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bLoop\b\s*,?\s*Reg\s*,[^,]+,\s*)(KV?R?|KR?V?|VK?R?|VR?K?|RK?V?|RV?K?)\b
Expand Down Expand Up @@ -301,6 +309,8 @@ repository:
name: keyword.other.ahk
- match: (?i)\b(?<=\bSetTimer\b\s*,?[^,]*,\s*)(On|Off|Delete)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bSetTitleMatchMode\b\s*,?\s*)(RegEx|Fast|Slow)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bSoundSet\b\s*,?[^,]+,\s*)(MASTER|SPEAKERS|DIGITAL|LINE|MICROPHONE|SYNTH|CD|TELEPHONE|PCSPEAKER|WAVE|AUX|ANALOG|HEADPHONES|N/A)\b
name: keyword.other.ahk
- match: (?i)\b(?<=\bSoundSet\b\s*,?[^,]+,[^,]*,\s*)(VOLUME|VOL|ONOFF|MUTE|MONO|LOUDNESS|STEREOENH|BASSBOOST|PAN|QSOUNDPAN|BASS|TREBLE|EQUALIZER)\b
Expand Down
6 changes: 5 additions & 1 deletion src/test/suite/grammar/samples/318-keyword-in-command.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ For Key in Expression
For Key, Value in Expression
FormatTime, TimeString, T12, Time
FormatTime, TimeString,, LongDate
GetKeyState, OutputVar, WhichKey, P
Gui, Show, Center NoActivate, Title
Gui, GuiName:Show, Options, Title
Gui, %GuiName%:Show, Options, Title
Expand Down Expand Up @@ -64,7 +65,9 @@ If var not in exe,bat
If var is Float
If var is not Float
IfMsgBox, Timeout
Loop, Files, *.jpg
InputBox, OutputVar, Title, Prompt, HIDE
Loop, Files, *.jpg, DFR
Loop, Parse, InputVar, CSV
Loop, Reg, HKEY_CURRENT_USER\Software, KVR
Menu, MyMenu, Add
Menu, Tray, Add
Expand All @@ -85,6 +88,7 @@ SetMouseDelay, 0, Play
SetKeyDelay, 0, 0, Play
SetRegView, 32
SetTimer, Label, Delete
SetTitleMatchMode, Fast
SoundSet, +20, Master, Bass
SoundSet, +1,, Mute
SplashImage, Image.png, CWRed CTRed
Expand Down
46 changes: 45 additions & 1 deletion src/test/suite/grammar/samples/318-keyword-in-command.ahk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^^ source.ahk keyword.other.ahk
>GetKeyState, OutputVar, WhichKey, P
#^^^^^^^^^^^ source.ahk support.function.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^ source.ahk keyword.other.ahk
>Gui, Show, Center NoActivate, Title
#^^^ source.ahk support.function.ahk
# ^ source.ahk punctuation.ahk
Expand Down Expand Up @@ -753,7 +764,21 @@
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^ source.ahk keyword.other.ahk
>Loop, Files, *.jpg
>InputBox, OutputVar, Title, Prompt, HIDE
#^^^^^^^^ source.ahk support.function.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^ source.ahk keyword.other.ahk
>Loop, Files, *.jpg, DFR
#^^^^ source.ahk keyword.control.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
Expand All @@ -763,6 +788,20 @@
# ^ source.ahk keyword.operator.arithmetic.ahk
# ^ source.ahk
# ^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^ source.ahk keyword.other.ahk
>Loop, Parse, InputVar, CSV
#^^^^ source.ahk keyword.control.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^ source.ahk keyword.other.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^^^ source.ahk variable.def.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^ source.ahk keyword.other.ahk
>Loop, Reg, HKEY_CURRENT_USER\Software, KVR
#^^^^ source.ahk keyword.control.ahk
# ^ source.ahk punctuation.ahk
Expand Down Expand Up @@ -973,6 +1012,11 @@
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^^^ source.ahk keyword.keys.ahk
>SetTitleMatchMode, Fast
#^^^^^^^^^^^^^^^^^ source.ahk support.function.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^^^ source.ahk keyword.other.ahk
>SoundSet, +20, Master, Bass
#^^^^^^^^ source.ahk support.function.ahk
# ^ source.ahk punctuation.ahk
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/grammar/samples/ahk-explorer.ahk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20820,7 +20820,7 @@
# ^ source.ahk string.quoted.double.ahk punctuation.definition.string.end.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^^ source.ahk variable.def.ahk
# ^^ source.ahk keyword.other.ahk
>{
#^ source.ahk punctuation.bracket.ahk
>stuffByName%whichSide%[A_LoopFileName]:={date:A_LoopFileTimeModified,attri:A_LoopFileAttrib,size:A_LoopFileSize}
Expand Down Expand Up @@ -21127,7 +21127,7 @@
# ^ source.ahk string.quoted.double.ahk punctuation.definition.string.end.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^ source.ahk variable.def.ahk
# ^ source.ahk keyword.other.ahk
>{
#^ source.ahk punctuation.bracket.ahk
>if (A_LoopFileLongPath!=EcurrentDir%whichSide%) {
Expand Down Expand Up @@ -21331,7 +21331,7 @@
# ^ source.ahk string.quoted.double.ahk punctuation.definition.string.end.ahk
# ^ source.ahk punctuation.ahk
# ^ source.ahk
# ^ source.ahk variable.def.ahk
# ^ source.ahk keyword.other.ahk
>{
#^ source.ahk punctuation.bracket.ahk
>if (A_LoopFileLongPath!=parent1Dir%whichSide%) {
Expand Down