summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorPaul Smith <paulsmith@gmail.com>2021-01-02 13:22:31 -0600
committerDavid Peter <sharkdp@users.noreply.github.com>2021-01-02 21:34:25 +0100
commitc76e27851cfea1563ed8ff4b55b989706f433f35 (patch)
tree0662a189179356f9b814fbf1524884f6096d458f /assets
parent8c0dcf3b57b2c656e869dfe88a9b4137fe67f9e5 (diff)
Add support for Zig
Adds syntax support for source code for the Zig programming language. https://ziglang.org/
Diffstat (limited to 'assets')
m---------assets/syntaxes/02_Extra/Zig0
-rw-r--r--assets/syntaxes/02_Extra/Zig.sublime-syntax265
2 files changed, 265 insertions, 0 deletions
diff --git a/assets/syntaxes/02_Extra/Zig b/assets/syntaxes/02_Extra/Zig
new file mode 160000
+Subproject 87ecbcae6fb5718369ce3bb3472ca0b2634e78e
diff --git a/assets/syntaxes/02_Extra/Zig.sublime-syntax b/assets/syntaxes/02_Extra/Zig.sublime-syntax
new file mode 100644
index 00000000..4fbcfc71
--- /dev/null
+++ b/assets/syntaxes/02_Extra/Zig.sublime-syntax
@@ -0,0 +1,265 @@
+%YAML 1.2
+---
+# http://www.sublimetext.com/docs/3/syntax.html
+name: Zig
+file_extensions:
+ - zig
+scope: source.zig
+contexts:
+ main:
+ - include: dummy_main
+ block:
+ - match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(\{)'
+ captures:
+ 1: storage.type.zig
+ 2: punctuation.section.braces.begin.zig
+ push:
+ - match: '(\})'
+ captures:
+ 1: punctuation.section.braces.end.zig
+ pop: true
+ - include: dummy_main
+ character_escapes:
+ - match: \\n
+ scope: constant.character.escape.newline.zig
+ - match: \\r
+ scope: constant.character.escape.carrigereturn.zig
+ - match: \\t
+ scope: constant.character.escape.tabulator.zig
+ - match: \\\\
+ scope: constant.character.escape.backslash.zig
+ - match: \\'
+ scope: constant.character.escape.single-quote.zig
+ - match: \\\"
+ scope: constant.character.escape.double-quote.zig
+ - match: '\\x[a-fA-F\d]{2}'
+ scope: constant.character.escape.hexidecimal.zig
+ - match: '\\u\{[a-fA-F\d]{1,6}\}'
+ scope: constant.character.escape.hexidecimal.zig
+ comments:
+ - match: ///
+ push:
+ - meta_scope: comment.line.documentation.zig
+ - match: $\n?
+ pop: true
+ - match: '//[^/]\s*TODO'
+ push:
+ - meta_scope: comment.line.todo.zig
+ - match: $\n?
+ pop: true
+ - match: "//[^/]*"
+ push:
+ - meta_scope: comment.line.zig
+ - match: $\n?
+ pop: true
+ constants:
+ - match: \b(null|undefined|true|false)\b
+ scope: constant.language.zig
+ - match: '\b(?<!\.)(-?[\d_]+)(?!\.)\b'
+ scope: constant.numeric.integer.zig
+ - match: '\b(?<!\.)(0x[a-fA-F\d_]+)(?!\.)\b'
+ scope: constant.numeric.integer.hexadecimal.zig
+ - match: '\b(?<!\.)(0o[0-7_]+)(?!\.)\b'
+ scope: constant.numeric.integer.octal.zig
+ - match: '\b(?<!\.)(0b[01_]+)(?!\.)\b'
+ scope: constant.numeric.integer.binary.zig
+ - match: '(?<!\.)(-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?)(?!\.)\b'
+ scope: constant.numeric.float.zig
+ - match: '(?<!\.)(-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?)(?!\.)\b'
+ scope: constant.numeric.float.hexadecimal.zig
+ container_decl:
+ - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{])'
+ scope: entity.name.union.zig
+ - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{])'
+ scope: entity.name.struct.zig
+ - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{])'
+ scope: entity.name.enum.zig
+ - match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{])'
+ scope: entity.name.error.zig
+ - match: '\b(error)(\.)([a-zA-Z_]\w*|@\".+\")'
+ captures:
+ 1: storage.type.error.zig
+ 2: punctuation.accessor.zig
+ 3: entity.name.error.zig
+ dummy_main:
+ - include: label
+ - include: function_type
+ - include: punctuation
+ - include: storage_modifier
+ - include: container_decl
+ - include: constants
+ - include: comments
+ - include: strings
+ - include: storage
+ - include: keywords
+ - include: operators
+ - include: support
+ - include: field_decl
+ - include: block
+ - include: function_def
+ - include: function_call
+ - include: enum_literal
+ enum_literal:
+ - match: '(?<!\w|\)|\?|\}|\]|\*)(\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\"))(?!\(|\s*=[^=>])'
+ scope: constant.language.enum
+ field_decl:
+ - match: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
+ captures:
+ 1: variable.other.member.zig
+ 2: punctuation.separator.zig
+ push:
+ - match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$)'
+ captures:
+ 1: storage.type.zig
+ 2: punctuation.separator.zig
+ 3: keyword.operator.assignment.zig
+ pop: true
+ - include: dummy_main
+ function_call:
+ - match: '(?<!fn)\b([a-zA-Z_]\w*|@\".+\")(?=\s*\()'
+ scope: variable.function.zig
+ function_def:
+ - match: '(?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\()'
+ captures:
+ 1: entity.name.function
+ 2: punctuation.section.parens.begin.zig
+ push:
+ - match: '(?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
+ captures:
+ 1: storage.type.zig
+ 2: keyword.operator.zig
+ 3: storage.type.zig
+ pop: true
+ - include: label
+ - include: param_list
+ - match: '([a-zA-Z_][\w.]*|@\".+\")'
+ scope: storage.type.zig
+ - include: dummy_main
+ function_type:
+ - match: \b(fn)\s*(\()
+ captures:
+ 1: storage.type.function.zig
+ 2: punctuation.section.parens.begin.zig
+ push:
+ - meta_content_scope: meta.function.parameters.zig
+ - match: '(?<=\)|\})\s*([a-zA-Z_][\w.]*|@\".+\")?\s*(!)?\s*([a-zA-Z_][\w.]*|@\".+\")'
+ captures:
+ 1: storage.type.zig
+ 2: keyword.operator.zig
+ 3: storage.type.zig
+ pop: true
+ - include: label
+ - include: param_list
+ - match: '([a-zA-Z_][\w.]*|@\".+\")'
+ scope: storage.type.zig
+ - include: dummy_main
+ keywords:
+ - match: \b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\b
+ scope: keyword.control.zig
+ - match: \b(async|await|suspend|nosuspend|resume)\b
+ scope: keyword.control.async.zig
+ - match: \b(if|else|switch|try|catch|orelse)\b
+ scope: keyword.control.conditional.zig
+ - match: (?<!\w)(@import|@cImport|@cInclude)\b
+ scope: keyword.control.import.zig
+ - match: \b(usingnamespace)\b
+ scope: keyword.other.usingnamespace.zig
+ label:
+ - match: '\b(break|continue)\s*:\s*([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b))'
+ captures:
+ 1: keyword.control.zig
+ 2: entity.name.label.zig
+ 3: entity.name.label.zig
+ operators:
+ - match: \b!\b
+ scope: keyword.operator.zig
+ - match: (==|(?:!|>|<)=?)
+ scope: keyword.operator.logical.zig
+ - match: \b(and|or)\b
+ scope: keyword.operator.word.zig
+ - match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=)'
+ scope: keyword.operator.assignment.zig
+ - match: ((?:\+|-|\*)\%?|/(?!/)|%)
+ scope: keyword.operator.arithmetic.zig
+ - match: '(<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~)'
+ scope: keyword.operator.bitwise.zig
+ - match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3})'
+ scope: keyword.operator.other.zig
+ param_list:
+ - match: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
+ captures:
+ 1: variable.parameter.zig
+ 2: punctuation.separator.zig
+ push:
+ - match: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\)))'
+ captures:
+ 1: storage.type.zig
+ 2: punctuation.separator.zig
+ 3: punctuation.section.parens.end.zig
+ pop: true
+ - include: dummy_main
+ - match: '([a-zA-Z_][\w.]*|@\".+\")'
+ scope: storage.type.zig
+ punctuation:
+ - match: ","
+ scope: punctuation.separator.zig
+ - match: ;
+ scope: punctuation.terminator.zig
+ - match: (\()
+ scope: punctuation.section.parens.begin.zig
+ - match: (\))
+ scope: punctuation.section.parens.end.zig
+ storage:
+ - match: \b(bool|void|noreturn|type|anyerror|anytype)\b
+ scope: storage.type.zig
+ - match: '\b(?<!\.)([iu]\d+|[iu]size|comptime_int)\b'
+ scope: storage.type.integer.zig
+ - match: \b(f16|f32|f64|f128|comptime_float)\b
+ scope: storage.type.float.zig
+ - match: \b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b
+ scope: storage.type.c_compat.zig
+ - match: '\b(anyframe)\b\s*(->)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
+ captures:
+ 1: storage.type.zig
+ 2: keyword.operator.zig
+ 3: storage.type.zig
+ - match: \bfn\b
+ scope: storage.type.function.zig
+ - match: \btest\b
+ scope: storage.type.test.zig
+ - match: \bstruct\b
+ scope: storage.type.struct.zig
+ - match: \benum\b
+ scope: storage.type.enum.zig
+ - match: \bunion\b
+ scope: storage.type.union.zig
+ - match: \berror\b
+ scope: storage.type.error.zig
+ storage_modifier:
+ - match: \b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b
+ scope: storage.modifier.zig
+ strings:
+ - match: \'
+ push:
+ - meta_scope: string.quoted.single.zig
+ - match: \'
+ pop: true
+ - include: character_escapes
+ - match: '\\[^\''][^\'']*?'
+ scope: invalid.illegal.character.zig
+ - match: c?\"
+ push:
+ - meta_scope: string.quoted.double.zig
+ - match: \"
+ pop: true
+ - include: character_escapes
+ - match: '\\[^\''][^\'']*?'
+ scope: invalid.illegal.character.zig
+ - match: c?\\\\
+ push:
+ - meta_scope: string.quoted.other.zig
+ - match: $\n?
+ pop: true
+ support:
+ - match: '(?<!\w)@[^\"\d][a-zA-Z_]\w*\b'
+ scope: support.function.zig