Skip to content

Instantly share code, notes, and snippets.

@vhanla
Last active February 6, 2020 13:25
Show Gist options
  • Save vhanla/79a60213cb3b4f99ef341b020551a158 to your computer and use it in GitHub Desktop.
Save vhanla/79a60213cb3b4f99ef341b020551a158 to your computer and use it in GitHub Desktop.
Aardio Syntax Highlighter for SublimeText 3, place it inside Data/Packages/User directory
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Aardio
file_extensions: [aardio, aau]
scope: source.aardio
contexts:
main:
- match: '^\s*(import)\s+([^ ;]*);'
scope: meta.keyword.using.source.aardio
captures:
1: keyword.other.using.source.aardio
- match: '^\s*((namespace)\s+([\w.]+))'
captures:
1: meta.namespace.identifier.source.aardio
2: keyword.other.namespace.source.aardio
3: entity.name.type.namespace.source.aardio
push:
- meta_scope: meta.namespace.source.aardio
- match: "}"
scope: punctuation.section.namespace.end.source.aardio
pop: true
- match: "{"
scope: punctuation.section.namespace.begin.source.aardio
push:
- meta_scope: meta.namespace.body.source.aardio
- match: "(?=})"
pop: true
- include: code
- include: code
block:
- match: "{"
scope: punctuation.section.block.begin.source.aardio
push:
- meta_scope: meta.block.source.aardio
- match: "}"
scope: punctuation.section.block.end.source.aardio
pop: true
- include: code
builtinTypes:
- match: \b(bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|class|struct|enum|interface)\b
scope: storage.type.source.aardio
class:
- match: '(?=\w?[\w\s]*(?:class|struct|interface|enum)\s+\w+)'
push:
- meta_scope: meta.class.source.aardio
- match: "}"
scope: punctuation.section.class.end.source.aardio
pop: true
- include: storage-modifiers
- include: comments
- match: (class|struct|interface|enum)\s+(\w+)
scope: meta.class.identifier.source.aardio
captures:
1: storage.modifier.source.aardio
2: entity.name.type.class.source.aardio
- match: ":"
push:
- match: "(?={)"
pop: true
- match: '\s*,?([A-Za-z_]\w*)\b'
captures:
1: storage.type.source.aardio
- match: "{"
scope: punctuation.section.class.begin.source.aardio
push:
- meta_scope: meta.class.body.source.aardio
- match: "(?=})"
pop: true
- include: method
- match: '='
scope: keyword.operator.assignment.aardio
push:
- match: ';'
pop: true
- include: code
- include: code
code:
- include: block
- include: comments
- include: class
- include: constants
- include: storage-modifiers
- include: keywords
- include: preprocessor
- include: method-call
- include: builtinTypes
comments:
- match: ///
scope: punctuation.definition.comment.source.aardio
push:
- meta_scope: comment.block.documentation.source.aardio
- match: $\n?
scope: punctuation.definition.comment.source.aardio
pop: true
- include: scope:text.xml
- match: /\*\*\s*intellisense
scope: punctuation.definition.comment.intellisense.source.aardio
push:
- meta_scope: comment.intellisense.block.source.aardio
- match: \*\*/\n?
scope: punctuation.definition.comment.intellisense.source.aardio
pop: true
- match: /\*
scope: punctuation.definition.comment.source.aardio
push:
- meta_scope: comment.block.source.aardio
- match: \*/\n?
scope: punctuation.definition.comment.source.aardio
pop: true
- match: //
scope: punctuation.definition.comment.source.aardio
push:
- meta_scope: comment.line.double-slash.source.aardio
- match: $\n?
pop: true
constants:
- match: \b(true|false|null|this|base)\b
scope: constant.language.source.aardio
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b'
scope: constant.numeric.source.aardio
- match: '@"'
scope: punctuation.definition.string.begin.source.aardio
push:
- meta_scope: string.quoted.double.literal.source.aardio
- match: '""'
scope: constant.character.escape.source.aardio
- match: '"'
scope: punctuation.definition.string.end.source.aardio
pop: true
- match: '"'
scope: punctuation.definition.string.begin.source.aardio
push:
- meta_scope: string.quoted.double.source.aardio
- match: '"'
scope: punctuation.definition.string.end.source.aardio
pop: true
- match: "'"
scope: punctuation.definition.string.begin.source.aardio
push:
- meta_scope: string.quoted.single.source.aardio
- match: "'"
scope: punctuation.definition.string.end.source.aardio
pop: true
keywords:
- match: \b(if|else|elseif|while|for|foreach|in|do|return|continue|break|switch|case|default|goto|throw|try|catch|finally|lock|yield)\b
scope: keyword.control.source.aardio
- match: \b(from|where|select|group|into|orderby|join|let|on|equals|by|ascending|descending)\b
scope: keyword.linq.source.aardio
- match: \b(new|is|as|using|checked|unchecked|typeof|sizeof|override|readonly|stackalloc)\b
scope: keyword.operator.source.aardio
- match: \b(var|ctor|_object|def|event|delegate|add|remove|set|get|value)\b
scope: keyword.other.source.aardio
method:
- include: attributes
- match: '(?=\bnew\s+)(?=[\w<].*\s+)(?=[^=]+\()'
push:
- meta_scope: meta.new-object.source.aardio
- match: "(?={|;)"
pop: true
- include: code
- match: '(?!new)(?=[\w<].*\s+)(?=[^=]+\()'
push:
- meta_scope: meta.method.source.aardio
- match: "(})|(?=;)"
scope: punctuation.section.method.end.source.aardio
pop: true
- include: storage-modifiers
- match: '([\w.]+)\s*\('
captures:
1: entity.name.function.source.aardio
push:
- meta_scope: meta.method.identifier.source.aardio
- match: \)
pop: true
- include: parameters
- match: '(?=\w.*\s+[\w.]+\s*\()'
push:
- meta_scope: meta.method.return-type.source.aardio
- match: '(?=[\w.]+\s*\()'
pop: true
- include: builtinTypes
- match: ':\s*(this|base)\s*\('
captures:
1: constant.language.source.cs
push:
- meta_scope: meta.method.base-call.source.aardio
- match: \)
pop: true
- include: builtinTypes
- include: comments
- match: "{"
scope: punctuation.section.method.begin.source.aardio
push:
- meta_scope: meta.method.body.source.aardio
- match: "(?=})"
pop: true
- include: code
- match: '(?!new)(?=[\w<].*\s+)(?=[^=]+\{)'
push:
- meta_scope: meta.property.source.aardio
- match: "}"
scope: punctuation.section.property.end.source.aardio
pop: true
- include: storage-modifiers
- match: '([\w.]+)\s*(?={)'
captures:
1: entity.name.function.source.aardio
push:
- meta_scope: meta.method.identifier.source.aardio
- match: "(?={)"
pop: true
- match: '(?=\w.*\s+[\w.]+\s*\{)'
push:
- meta_scope: meta.method.return-type.source.aardio
- match: '(?=[\w.]+\s*\{)'
pop: true
- include: builtinTypes
- match: "{"
scope: punctuation.section.property.begin.source.aardio
push:
- meta_scope: meta.method.body.source.aardio
- match: "(?=})"
pop: true
- include: code
method-call:
- match: '([\w$]+)(\()'
captures:
1: meta.method.source.aardio
2: punctuation.definition.method-parameters.begin.source.aardio
push:
- meta_scope: meta.method-call.source.aardio
- match: \)
scope: punctuation.definition.method-parameters.end.source.aardio
pop: true
- match: ","
scope: punctuation.definition.separator.parameter.source.aardio
- include: code
attributes:
- match: '\['
push:
- meta_scope: meta.method.attribute.source.aardio
- match: '\]'
pop: true
- include: constants
- include: preprocessor
- include: builtinTypes
parameters:
- include: attributes
- match: '\b(ref|params|out)?\s*\b([\w.\[\]]+)\s+(\w+)\s*(=)?'
captures:
1: storage.type.modifier.source.aardio
2: storage.type.generic.source.aardio
3: variable.parameter.function.source.aardio
4: keyword.operator.assignment.source.aardio
push:
- match: '(,)|(?=[\)])'
scope: punctuation.definition.separator.parameter.source.aardio
pop: true
- include: constants
- include: block
preprocessor:
- match: ^\s*#\s*(region)\b(.*)$
scope: meta.preprocessor.source.aardio
captures:
2: meta.toc-list.region.source.aardio
- match: ^\s*#\s*(define)\b\s*(\S*)
scope: meta.preprocessor.source.aardio
captures:
2: entity.name.function.preprocessor.source.aardio
- match: ^\s*#\s*(if|else|elif|endif|define|undef|warning|error|line|pragma|region|endregion)\b
scope: meta.preprocessor.source.aardio
captures:
2: keyword.control.import.source.aardio
storage-modifiers:
- match: \b(event|delegate|internal|public|protected|private|static|const|new|sealed|abstract|virtual|override|extern|unsafe|readonly|volatile|implicit|explicit|operator|partial)\b
scope: storage.modifier.source.aardio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment