Skip to content

Commit

Permalink
highlight io keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
serkonda7 committed Nov 28, 2023
1 parent 3ca763d commit 33305c3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
_unreleased_

- Highlight `Implements` keyword
- Highlight all I/O-related keywords


## 0.9.3
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "VBA",
"description": "VBA tooling, syntax highlighting and snippets for VS Code.",
"icon": "images/icon_256x256.png",
"version": "0.9.3",
"version": "0.9.4-dev",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
17 changes: 17 additions & 0 deletions syntaxes/tests/vba/io.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
' SYNTAX TEST "source.vba" "I/O related keywords"

Open "file" For Input As #f
' <--- keyword.io.vba
' ^^^^^ keyword.io.vba
Input #f myVar
' ^^^^^ keyword.io.vba

Line Input #f myLineVar
' ^^^^^^^^^^ keyword.io.vba
Close #f
' <---- keyword.io.vba

Open "file2" For Output As #2
Print #2 "a"
' ^^^^^ keyword.io.vba
Close #2
12 changes: 7 additions & 5 deletions syntaxes/vba.tmGrammar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ repository:

keywords:
patterns:
- name: keyword.other.option.vba
match: (?i)\bOption (Base [01]|Compare (Binary|Text)|Explicit|Private Module)\b
- name: keyword.conditional.vba
match: (?i:\b(Do(( While)|( Until))?|While|Case( Else)?|Else(If)?|For( Each)?|(I)?If|In|New|(Select )?Case|Then|To|Step|With)\b)
- name: keyword.conditional.end.vba
match: (?i:\b(End( )?If|End (Select|With)|Next|Wend|Loop(( While)|( Until))?|Exit (For|Do|While))\b)
- name: keyword.control.vba
match: (?i:(\b(Exit (Function|Property|Sub)|As|And|By(Ref|Val)|Goto|Is|Like|Mod|Not|On Error|Optional|Or|Resume Next|Stop|Xor|Eqv|Imp|TypeOf|AddressOf)\b)|(\b(End)\b(?=\n)))
- name: keyword.io.vba
match: (?i:\b(Open|Close|(Line )?Input|Lock|Unlock|Print|Seek|Width|Get|Put|Write)\b)
- name: keyword.other.vba
match: (?i:\b(Attribute|Call|End (Function|Property|Sub|Type|Enum)|(Const|Function|Property|Sub|Type|Enum)|Declare|PtrSafe|WithEvents|Event|RaiseEvent|Implements)\b)
- name: keyword.other.option.vba
match: (?i)\bOption (Base [01]|Compare (Binary|Text)|Explicit|Private Module)\b
- name: keyword.other.visibility.vba
match: (?i:\b(Private|Public|Friend)\b)
- name: constant.language.vba
Expand All @@ -63,13 +65,13 @@ repository:
begin: "(?i)^\\s*(BEGIN)\\b"
beginCaptures:
'1':
name: "keyword.metadata.vba"
name: "keyword.metadata.vba"
end: "(?i)^\\s*(END)\\b"
endCaptures:
'0':
name: "keyword.metadata.vba"
patterns:
- include: "source.vba"
patterns:
- include: "source.vba"

numbers:
patterns:
Expand Down

0 comments on commit 33305c3

Please sign in to comment.