Skip to content

Commit

Permalink
add variable support from vscode syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
foxnne authored and emekoi committed Jul 24, 2021
1 parent 7d93378 commit 9c6a89a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Syntaxes/Zig.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,21 @@ repository:
match: '(?<!\w|\)|\?|\}|\]|\*)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>])'
name: constant.language.enum

variables:
name: meta.variable.zig
patterns:
- match: '\b[_A-Z][_A-Z0-9]+\b'
name: variable.constant.zig

- match: '\b[_a-zA-Z][_a-zA-Z0-9]*_t\b'
name: entity.name.type.zig

- match: '\b[A-Z][a-zA-Z0-9]*\b'
name: entity.name.type.zig

- match: '\b[_a-zA-Z][_a-zA-Z0-9]*\b'
name: variable.zig

dummy_main:
patterns:
- include: '#label'
Expand All @@ -366,3 +381,4 @@ repository:
- include: '#function_def'
- include: '#function_call'
- include: '#enum_literal'
- include: '#variables'
14 changes: 14 additions & 0 deletions Syntaxes/Zig.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ contexts:
- include: function_def
- include: function_call
- include: enum_literal
- include: variables
enum_literal:
- match: '(^|\s+)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>])'
scope: constant.language.enum
Expand Down Expand Up @@ -270,3 +271,16 @@ contexts:
support:
- match: '@[^\"\d][a-zA-Z_]\w*\b'
scope: support.function.zig
variables:
- match: '\b[_A-Z][_A-Z0-9]+\b'
scope: variable.constant.zig

- match: '\b[_a-zA-Z][_a-zA-Z0-9]*_t\b'
scope: entity.name.type.zig

- match: '\b[A-Z][a-zA-Z0-9]*\b'
scope: entity.name.type.zig

- match: '\b[_a-zA-Z][_a-zA-Z0-9]*\b'
scope: variable.zig

36 changes: 36 additions & 0 deletions Syntaxes/Zig.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@
<key>include</key>
<string>#enum_literal</string>
</dict>
<dict>
<key>include</key>
<string>#variables</string>
</dict>
</array>
</dict>
<key>enum_literal</key>
Expand Down Expand Up @@ -837,6 +841,38 @@
<key>name</key>
<string>support.function.zig</string>
</dict>
<key>variables</key>
<dict>
<key>name</key>
<string>meta.variable.zig</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\b[_A-Z][_A-Z0-9]+\b</string>
<key>name</key>
<string>variable.constant.zig</string>
</dict>
<dict>
<key>match</key>
<string>\b[_a-zA-Z][_a-zA-Z0-9]*_t\b</string>
<key>name</key>
<string>entity.name.type.zig</string>
</dict>
<dict>
<key>match</key>
<string>\b[A-Z][a-zA-Z0-9]*\b</string>
<key>name</key>
<string>entity.name.type.zig</string>
</dict>
<dict>
<key>match</key>
<string>\b[_a-zA-Z][_a-zA-Z0-9]*\b</string>
<key>name</key>
<string>variable.zig</string>
</dict>
</array>
</dict>
</dict>
<key>scopeName</key>
<string>source.zig</string>
Expand Down

0 comments on commit 9c6a89a

Please sign in to comment.