Skip to content

Commit

Permalink
Revert "Remove textmate language files"
Browse files Browse the repository at this point in the history
This reverts commit 592332d.
  • Loading branch information
aidenfoxivey committed Aug 11, 2024
1 parent 696eae0 commit b8d9c95
Show file tree
Hide file tree
Showing 5 changed files with 3,099 additions and 0 deletions.
384 changes: 384 additions & 0 deletions Syntaxes/Zig.YAML-tmLanguage
Original file line number Diff line number Diff line change
@@ -0,0 +1,384 @@
# [PackageDev] target_format: plist, ext: tmLanguage
# [PackageDev] target_format: json, ext: tmLanguage.json

name: Zig
uuid: 06C2FF99-3080-441A-9019-460C51E93116
scopeName: source.zig
fileTypes:
- zig

patterns:
- include: '#dummy_main'

repository:
character_escapes:
patterns:
- name: constant.character.escape.newline.zig
match: \\n
- name: constant.character.escape.carrigereturn.zig
match: \\r
- name: constant.character.escape.tabulator.zig
match: \\t
- name: constant.character.escape.backslash.zig
match: \\\\
- name: constant.character.escape.single-quote.zig
match: \\'
- name: constant.character.escape.double-quote.zig
match: \\\"
- name: constant.character.escape.hexidecimal.zig
match: \\x[a-fA-F\d]{2}
- name: constant.character.escape.hexidecimal.zig
match: \\u\{[a-fA-F\d]{1,6}\}

param_list:
begin: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
beginCaptures:
'1':
name: variable.parameter.zig
'2':
name: punctuation.separator.zig

end: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(\)))'
endCaptures:
'1':
name: storage.type.zig
'2':
name: punctuation.separator.zig
'3':
name: punctuation.section.parens.end.zig

patterns:
- include: '#dummy_main'

- match: '([a-zA-Z_][\w.]*|@\".+\")'
name: storage.type.zig

field_decl:
begin: '([a-zA-Z_]\w*|@\".+\")\s*(:)\s*'
beginCaptures:
'1':
name: variable.other.member.zig
'2':
name: punctuation.separator.zig

end: '([a-zA-Z_][\w.]*|@\".+\")?\s*(?:(,)|(=)|$)'
endCaptures:
'1':
name: storage.type.zig
'2':
name: punctuation.separator.zig
'3':
name: keyword.operator.assignment.zig

patterns:
- include: '#dummy_main'

storage_modifier:
name: storage.modifier.zig
match: '\b(const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b'

container_decl:
patterns:
- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:union)\s*[(\{])'
name: entity.name.union.zig

- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:struct)\s*[(\{])'
name: entity.name.struct.zig

- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*(?:enum)\s*[(\{])'
name: entity.name.enum.zig

- match: '\b(?!\d)([a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:error)\s*[(\{])'
name: entity.name.error.zig

- match: '\b(error)(\.)([a-zA-Z_]\w*|@\".+\")'
captures:
'1':
name: storage.type.error.zig
'2':
name: punctuation.accessor.zig
'3':
name: entity.name.error.zig

constants:
patterns:
- name: constant.language.zig
match: '\b(null|undefined|true|false)\b'

- name: constant.numeric.integer.zig
match: '\b(?<!\.)(-?[\d_]+)(?!\.)\b'

- name: constant.numeric.integer.hexadecimal.zig
match: '\b(?<!\.)(0x[a-fA-F\d_]+)(?!\.)\b'

- name: constant.numeric.integer.octal.zig
match: '\b(?<!\.)(0o[0-7_]+)(?!\.)\b'

- name: constant.numeric.integer.binary.zig
match: '\b(?<!\.)(0b[01_]+)(?!\.)\b'

- name: constant.numeric.float.zig
match: '(?<!\.)(-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?)(?!\.)\b'

- name: constant.numeric.float.hexadecimal.zig
match: '(?<!\.)(-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?)(?!\.)\b'

comments:
patterns:
- name: comment.line.documentation.zig
begin: '///'
end: '$\n?'

- name: comment.line.todo.zig
begin: '//[^/]\s*TODO'
end: '$\n?'

- name: comment.line.zig
begin: '//[^/]*'
end: '$\n?'


strings:
patterns:
- name: string.quoted.single.zig
begin: \'
end: \'
patterns:
- include: '#character_escapes'
- name: invalid.illegal.character.zig
match: \\[^\'][^\']*?

- name: string.quoted.double.zig
begin: c?\"
end: \"
patterns:
- include: '#character_escapes'
- name: invalid.illegal.character.zig
match: \\[^\'][^\']*?

- name: string.quoted.other.zig
begin: c?\\\\
end: $\n?

keywords:
patterns:
- name: keyword.control.zig
match: '\b(while|for|break|return|continue|asm|defer|errdefer|unreachable)\b'

- name: keyword.control.async.zig
match: '\b(async|await|suspend|nosuspend|resume)\b'

- name: keyword.control.conditional.zig
match: '\b(if|else|switch|try|catch|orelse)\b'

- name: keyword.control.import.zig
match: '(?<!\w)(@import|@cImport|@cInclude)\b'

- name: keyword.other.usingnamespace.zig
match: '\b(usingnamespace)\b'

operators:
patterns:
- name: keyword.operator.zig
match: '\b!\b'

- name: keyword.operator.logical.zig
match: '(==|(?:!|>|<)=?)'

- name: keyword.operator.word.zig
match: '\b(and|or)\b'

- name: keyword.operator.assignment.zig
match: '((?:(?:\+|-|\*)\%?|/|%|<<|>>|&|\|(?=[^\|])|\^)?=)'

- name: keyword.operator.arithmetic.zig
match: '((?:\+|-|\*)\%?|/(?!/)|%)'

- name: keyword.operator.bitwise.zig
match: '(<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~)'

- name: keyword.operator.other.zig
match: '(\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3})'

support:
name: support.function.zig
match: '(?<!\w)@[^\"\d][a-zA-Z_]\w*\b'

storage:
patterns:
- name: storage.type.zig
match: '\b(bool|void|noreturn|type|anyerror|anytype)\b'

- name: storage.type.integer.zig
match: '\b(?<!\.)([iu]\d+|[iu]size|comptime_int)\b'

- name: storage.type.float.zig
match: '\b(f16|f32|f64|f128|comptime_float)\b'

- name: storage.type.c_compat.zig
match: '\b(c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b'

- match: '\b(anyframe)\b\s*(->)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
captures:
'1':
name: storage.type.zig
'2':
name: keyword.operator.zig
'3':
name: storage.type.zig

- name: storage.type.function.zig
match: '\bfn\b'

- name: storage.type.test.zig
match: '\btest\b'

- name: storage.type.struct.zig
match: '\bstruct\b'

- name: storage.type.enum.zig
match: '\benum\b'

- name: storage.type.union.zig
match: '\bunion\b'

- name: storage.type.error.zig
match: '\berror\b'

punctuation:
patterns:
- name: punctuation.separator.zig
match: ','

- name: punctuation.terminator.zig
match: ';'

- match: '(\()'
name: punctuation.section.parens.begin.zig

- match: '(\))'
name: punctuation.section.parens.end.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':
name: keyword.control.zig
'2':
name: entity.name.label.zig
'3':
name: entity.name.label.zig

block:
begin: '([a-zA-Z_][\w.]*|@\".+\")?\s*(\{)'
beginCaptures:
'1':
name: storage.type.zig
'2':
name: punctuation.section.braces.begin.zig

end: '(\})'
endCaptures:
'1':
name: punctuation.section.braces.end.zig

patterns:
- include: '#dummy_main'

function_def:
begin: '(?<=fn)\s+([a-zA-Z_]\w*|@\".+\")(\()'
beginCaptures:
'1':
name: entity.name.function
'2':
name: punctuation.section.parens.begin.zig

end: '(?<=\)[^\)])\s*([a-zA-Z_][\w.]*|@\".+\")?(!)?\s*(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?'
endCaptures:
'1':
name: storage.type.zig
'2':
name: keyword.operator.zig
'3':
name: storage.type.zig

patterns:
- include: '#label'
- include: '#param_list'

- match: '([a-zA-Z_][\w.]*|@\".+\")'
name: storage.type.zig

- include: '#dummy_main'

function_call:
name: variable.function.zig
match: '(?<!fn)\b([a-zA-Z_]\w*|@\".+\")(?=\s*\()'

function_type:
begin: '\b(fn)\s*(\()'
beginCaptures:
'1':
name: storage.type.function.zig
'2':
name: punctuation.section.parens.begin.zig

contentName: meta.function.parameters.zig

end: '(?<=\)|\})\s*([a-zA-Z_][\w.]*|@\".+\")?\s*(!)?\s*([a-zA-Z_][\w.]*|@\".+\")'
endCaptures:
'1':
name: storage.type.zig
'2':
name: keyword.operator.zig
'3':
name: storage.type.zig

patterns:
- include: '#label'
- include: '#param_list'

- match: '([a-zA-Z_][\w.]*|@\".+\")'
name: storage.type.zig

- include: '#dummy_main'

enum_literal:
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'
- 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'
- include: '#variables'
Loading

0 comments on commit b8d9c95

Please sign in to comment.