mirror of
https://github.com/danbulant/mdsvexrs
synced 2026-05-19 04:08:47 +00:00
more languages
This commit is contained in:
parent
3a782fbfa1
commit
30dbf37ada
7 changed files with 8177 additions and 0 deletions
1367
assets/asm.x86.sublime-syntax
Normal file
1367
assets/asm.x86.sublime-syntax
Normal file
File diff suppressed because it is too large
Load diff
595
assets/graphql.sublime-syntax
Normal file
595
assets/graphql.sublime-syntax
Normal file
|
|
@ -0,0 +1,595 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# See http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: GraphQL
|
||||||
|
file_extensions:
|
||||||
|
- graphql
|
||||||
|
- graphqls
|
||||||
|
- gql
|
||||||
|
scope: source.graphql
|
||||||
|
variables:
|
||||||
|
name_begin: (?:[_A-Za-z])
|
||||||
|
name_continue: (?:[_0-9A-Za-z])
|
||||||
|
name_break: (?!{{name_continue}})
|
||||||
|
name: (?:{{name_begin}}{{name_continue}}*{{name_break}})
|
||||||
|
|
||||||
|
integer_part: (?:-?(?:0|[1-9]\d*))
|
||||||
|
fractional_part: (?:\.\d*)
|
||||||
|
exponent_part: (?:[Ee][-+]?\d*)
|
||||||
|
contexts:
|
||||||
|
else-pop:
|
||||||
|
- match: (?=\S)
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
immediately-pop:
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
prototype:
|
||||||
|
- match: '#'
|
||||||
|
scope: punctuation.definition.comment.graphql
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.line.graphql
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- match: ','
|
||||||
|
scope: punctuation.separator.sequence.graphql
|
||||||
|
|
||||||
|
main:
|
||||||
|
- match: (?=")
|
||||||
|
push: description
|
||||||
|
|
||||||
|
- include: executable-declaration
|
||||||
|
- include: type-declarations
|
||||||
|
|
||||||
|
- match: directive{{name_break}}
|
||||||
|
scope: keyword.declaration.directive.graphql
|
||||||
|
push:
|
||||||
|
- - match: on{{name_break}}
|
||||||
|
scope: keyword.declaration.directive.graphql
|
||||||
|
set:
|
||||||
|
- - match: '\|'
|
||||||
|
scope: keyword.operator.graphql
|
||||||
|
push: directive-location
|
||||||
|
- include: else-pop
|
||||||
|
- directive-location
|
||||||
|
- include: else-pop
|
||||||
|
- arguments-definition
|
||||||
|
- directive-definition-name
|
||||||
|
|
||||||
|
executable-declaration:
|
||||||
|
- match: query{{name_break}}
|
||||||
|
scope: keyword.declaration.query.graphql
|
||||||
|
push:
|
||||||
|
- selection-set
|
||||||
|
- directives
|
||||||
|
- variable-definitions
|
||||||
|
- query-name
|
||||||
|
|
||||||
|
- match: (?=\{)
|
||||||
|
push: selection-set
|
||||||
|
|
||||||
|
- match: mutation{{name_break}}
|
||||||
|
scope: keyword.declaration.mutation.graphql
|
||||||
|
push:
|
||||||
|
- selection-set
|
||||||
|
- directives
|
||||||
|
- variable-definitions
|
||||||
|
- mutation-name
|
||||||
|
|
||||||
|
- match: subscription{{name_break}}
|
||||||
|
scope: keyword.declaration.subscription.graphql
|
||||||
|
push:
|
||||||
|
- selection-set
|
||||||
|
- directives
|
||||||
|
- variable-definitions
|
||||||
|
- subscription-name
|
||||||
|
|
||||||
|
- match: fragment{{name_break}}
|
||||||
|
scope: keyword.declaration.fragment.graphql
|
||||||
|
push:
|
||||||
|
- selection-set
|
||||||
|
- directives
|
||||||
|
- type-condition
|
||||||
|
- fragment-name
|
||||||
|
|
||||||
|
type-declarations:
|
||||||
|
- match: schema{{name_break}}
|
||||||
|
scope: keyword.declaration.schema.graphql
|
||||||
|
push:
|
||||||
|
- schema-definition
|
||||||
|
- directives
|
||||||
|
|
||||||
|
- match: scalar{{name_break}}
|
||||||
|
scope: keyword.declaration.scalar.graphql
|
||||||
|
push:
|
||||||
|
- directives
|
||||||
|
- scalar-name
|
||||||
|
|
||||||
|
- match: type{{name_break}}
|
||||||
|
scope: keyword.declaration.type.graphql
|
||||||
|
push:
|
||||||
|
- type-definition
|
||||||
|
- directives
|
||||||
|
- implements
|
||||||
|
- type-name
|
||||||
|
|
||||||
|
- match: interface{{name_break}}
|
||||||
|
scope: keyword.declaration.type.interface.graphql
|
||||||
|
push:
|
||||||
|
- type-definition
|
||||||
|
- directives
|
||||||
|
- implements
|
||||||
|
- interface-name
|
||||||
|
|
||||||
|
- match: union{{name_break}}
|
||||||
|
scope: keyword.declaration.type.interface.graphql
|
||||||
|
push:
|
||||||
|
- - match: '='
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set:
|
||||||
|
- - match: '\|'
|
||||||
|
scope: keyword.operator.graphql
|
||||||
|
push: type-named
|
||||||
|
- include: else-pop
|
||||||
|
- - include: type-named
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
- directives
|
||||||
|
- union-name
|
||||||
|
|
||||||
|
- match: enum{{name_break}}
|
||||||
|
scope: keyword.declaration.type.enum.graphql
|
||||||
|
push:
|
||||||
|
- enum-definition
|
||||||
|
- directives
|
||||||
|
- enum-name
|
||||||
|
|
||||||
|
- match: input{{name_break}}
|
||||||
|
scope: keyword.declaration.type.input.graphql
|
||||||
|
push:
|
||||||
|
- input-definition
|
||||||
|
- directives
|
||||||
|
- input-name
|
||||||
|
|
||||||
|
description:
|
||||||
|
- match: '"""'
|
||||||
|
scope: string.quoted.multiline.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_include_prototype: false
|
||||||
|
- meta_scope: string.quoted.multiline.graphql
|
||||||
|
- match: '\\"""'
|
||||||
|
scope: constant.character.escape.graphql
|
||||||
|
- match: '"""'
|
||||||
|
scope: string.quoted.multiline.end.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '"'
|
||||||
|
scope: string.quoted.double.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_include_prototype: false
|
||||||
|
- meta_scope: string.quoted.double.graphql
|
||||||
|
- match: '"'
|
||||||
|
scope: string.quoted.double.end.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '\\u\h{4}'
|
||||||
|
scope: constant.character.escape.hex.graphql
|
||||||
|
- match: '\\u\h{,3}'
|
||||||
|
scope: invalid.illegal.escape.hex.graphql
|
||||||
|
|
||||||
|
- match: '\\["\\/bfnrt]'
|
||||||
|
scope: constant.character.escape.graphql
|
||||||
|
- match: '\\.'
|
||||||
|
scope: invalid.illegal.escape.graphql
|
||||||
|
|
||||||
|
query-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.query.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
mutation-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.mutation.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
subscription-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.subscription.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
fragment-name:
|
||||||
|
- match: (?=on{{name_break}})
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.fragment.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
scalar-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.scalar.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
type-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.object.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
interface-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.interface.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
union-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.union.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
enum-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.enum.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
input-name:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.type.input.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
directive-definition-name:
|
||||||
|
- match: '(@)({{name}})'
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.annotation.graphql
|
||||||
|
2: entity.name.definition.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
type-condition:
|
||||||
|
- match: on{{name_break}}
|
||||||
|
scope: keyword.other.graphql
|
||||||
|
set: type-named
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
default-value:
|
||||||
|
- match: '='
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set: value
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
variable-definitions:
|
||||||
|
- match: \(
|
||||||
|
scope: punctuation.section.group.begin.graphql
|
||||||
|
set:
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.group.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '(\$)({{name}})'
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.variable.graphql
|
||||||
|
2: variable.parameter.graphql
|
||||||
|
push:
|
||||||
|
- - include: default-value
|
||||||
|
- - match: ':'
|
||||||
|
scope: punctuation.separator.type.graphql
|
||||||
|
set: type
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
directives:
|
||||||
|
- match: '@'
|
||||||
|
scope: punctuation.definition.annotation.graphql
|
||||||
|
push:
|
||||||
|
- arguments
|
||||||
|
- directive-name
|
||||||
|
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
directive-name:
|
||||||
|
- match: (?:skip|include|deprecated){{name_break}}
|
||||||
|
scope: variable.function.annotation.graphql support.function.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.function.annotation.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
selection-set:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.field.graphql
|
||||||
|
push:
|
||||||
|
- selection-set
|
||||||
|
- directives
|
||||||
|
- field-arguments
|
||||||
|
- aliased-field-name
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
aliased-field-name:
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.parameter.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
field-arguments:
|
||||||
|
- match: \(
|
||||||
|
scope: punctuation.section.group.begin.graphql
|
||||||
|
set:
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.group.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.parameter.graphql
|
||||||
|
push:
|
||||||
|
- - match: ':'
|
||||||
|
scope: punctuation.separator.type.graphql
|
||||||
|
set: value
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
schema-definition:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '(?:query|mutation|subscription)'
|
||||||
|
scope: keyword.other.graphql
|
||||||
|
push:
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set: type-named
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
implements:
|
||||||
|
- match: implements{{name_break}}
|
||||||
|
scope: keyword.declaration.implements.graphql
|
||||||
|
set:
|
||||||
|
- - match: '&'
|
||||||
|
scope: keyword.operator.graphql
|
||||||
|
push: type-named
|
||||||
|
- include: else-pop
|
||||||
|
- - include: type-named
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
type-definition:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: (?=")
|
||||||
|
push: description
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.field.graphql
|
||||||
|
push:
|
||||||
|
- - match: ':'
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set:
|
||||||
|
- directives
|
||||||
|
- type
|
||||||
|
- include: else-pop
|
||||||
|
- arguments-definition
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
enum-definition:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: (?=")
|
||||||
|
push: description
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: entity.name.constant.graphql
|
||||||
|
push: directives
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
input-definition:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.graphql
|
||||||
|
pop: true
|
||||||
|
- include: input-value-definition
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
arguments-definition:
|
||||||
|
- match: \(
|
||||||
|
scope: punctuation.section.group.begin.graphql
|
||||||
|
set:
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.group.end.graphql
|
||||||
|
pop: true
|
||||||
|
- include: input-value-definition
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
input-value-definition:
|
||||||
|
- match: (?=")
|
||||||
|
push: description
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.parameter.graphql
|
||||||
|
push:
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.key-value
|
||||||
|
set:
|
||||||
|
- directives
|
||||||
|
- default-value
|
||||||
|
- type
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
type:
|
||||||
|
- meta_include_prototype: false
|
||||||
|
- match: ''
|
||||||
|
set:
|
||||||
|
- type-non-null
|
||||||
|
- type-value
|
||||||
|
|
||||||
|
type-value:
|
||||||
|
- include: type-named
|
||||||
|
- match: \[
|
||||||
|
scope: storage.modifier.list.graphql
|
||||||
|
set:
|
||||||
|
- - match: \]
|
||||||
|
scope: storage.modifier.list.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
- type
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
type-named:
|
||||||
|
- match: (?:Int|Float|String|Boolean|ID){{name_break}}
|
||||||
|
scope: variable.type.graphql support.type.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.type.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
type-non-null:
|
||||||
|
- match: '!'
|
||||||
|
scope: storage.modifier.required.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
directive-location:
|
||||||
|
- match: |
|
||||||
|
(?x)(?:
|
||||||
|
QUERY|MUTATION|SUBSCRIPTION|FIELD|FRAGMENT_DEFINITION|FRAGMENT_SPREAD|INLINE_FRAGMENT
|
||||||
|
|SCHEMA|SCALAR|OBJECT|FIELD_DEFINITION|ARGUMENT_DEFINITION|INTERFACE|UNION|ENUM|ENUM_VALUE|INPUT_OBJECT|INPUT_FIELD_DEFINITION
|
||||||
|
){{name_break}}
|
||||||
|
scope: constant.language.graphql
|
||||||
|
pop: true
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
- match: \(
|
||||||
|
scope: punctuation.section.group.begin.graphql
|
||||||
|
set:
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.group.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.parameter.graphql
|
||||||
|
push:
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set: value
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
value:
|
||||||
|
- match: \$
|
||||||
|
scope: punctuation.definition.variable.graphql
|
||||||
|
set:
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: variable.other.graphql
|
||||||
|
pop: true
|
||||||
|
- include: ''
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '{{integer_part}}(?:{{fractional_part}}{{exponent_part}}?|{{exponent_part}}){{name_break}}'
|
||||||
|
scope: constant.numeric.float.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{integer_part}}{{name_break}}'
|
||||||
|
scope: constant.numeric.integer.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: null{{name_break}}
|
||||||
|
scope: constant.language.null.graphql
|
||||||
|
pop: true
|
||||||
|
- match: true{{name_break}}
|
||||||
|
scope: constant.language.boolean.true.graphql
|
||||||
|
pop: true
|
||||||
|
- match: false{{name_break}}
|
||||||
|
scope: constant.language.boolean.false.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: constant.other.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '"""'
|
||||||
|
scope: punctuation.definition.string.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_include_prototype: false
|
||||||
|
- meta_scope: string.quoted.triple.graphql
|
||||||
|
- match: '\\"""'
|
||||||
|
scope: constant.character.escape.graphql
|
||||||
|
- match: '"""'
|
||||||
|
scope: punctuation.definition.string.end.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '"'
|
||||||
|
scope: punctuation.definition.string.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_include_prototype: false
|
||||||
|
- meta_scope: string.quoted.double.graphql
|
||||||
|
- match: '"'
|
||||||
|
scope: punctuation.definition.string.end.graphql
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
- match: '\\u\h{4}'
|
||||||
|
scope: constant.character.escape.hex.graphql
|
||||||
|
- match: '\\u\h{,3}'
|
||||||
|
scope: invalid.illegal.escape.hex.graphql
|
||||||
|
|
||||||
|
- match: '\\["\\/bfnrt]'
|
||||||
|
scope: constant.character.escape.graphql
|
||||||
|
- match: '\\.'
|
||||||
|
scope: invalid.illegal.escape.graphql
|
||||||
|
|
||||||
|
- match: \[
|
||||||
|
scope: punctuation.section.sequence.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.sequence.graphql
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.sequence.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: (?=\S)
|
||||||
|
push: value
|
||||||
|
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.mapping.begin.graphql
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.mapping.graphql
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.mapping.end.graphql
|
||||||
|
pop: true
|
||||||
|
- match: '{{name}}'
|
||||||
|
scope: meta.mapping.key.graphql
|
||||||
|
push:
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.key-value.graphql
|
||||||
|
set: value
|
||||||
|
- include: else-pop
|
||||||
|
|
||||||
|
- include: else-pop
|
||||||
1290
assets/js-babel.sublime-syntax
Normal file
1290
assets/js-babel.sublime-syntax
Normal file
File diff suppressed because it is too large
Load diff
184
assets/log.sublime-syntax
Normal file
184
assets/log.sublime-syntax
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# See http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
file_extensions:
|
||||||
|
- log
|
||||||
|
scope: text.log
|
||||||
|
variables:
|
||||||
|
ipv4_part: (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
|
||||||
|
hours_minutes_seconds: (?:[01]\d|2[0-3]):(?:[0-5]\d):(?:[0-5]\d)
|
||||||
|
error: \b(?i:fail(?:ure|ed)?|error|exception|fatal|critical)\b
|
||||||
|
warning: \b(?i:warn(?:ing)?)\b
|
||||||
|
info: \b(?i:info)\b
|
||||||
|
debug: \b(?i:debug)\b
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- include: log_level_lines
|
||||||
|
- include: main_without_log_level_line
|
||||||
|
main_without_log_level_line:
|
||||||
|
- match: (\w+)(=)
|
||||||
|
captures:
|
||||||
|
1: variable.parameter.log
|
||||||
|
2: keyword.operator.assignment.log
|
||||||
|
- match: (')([^']*)(')
|
||||||
|
scope: string.quoted.single.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
3: punctuation.definition.string.end.log
|
||||||
|
- match: \"
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.string.begin.log
|
||||||
|
push: double_quoted_string
|
||||||
|
- include: dates
|
||||||
|
- include: ip_addresses
|
||||||
|
- include: numbers
|
||||||
|
- include: log_levels
|
||||||
|
#- include: scope:text.html.markdown#autolink-inet
|
||||||
|
- match: \b\w+:/{2,3}
|
||||||
|
scope: markup.underline.link.scheme.log
|
||||||
|
push: url-host
|
||||||
|
log_level_lines:
|
||||||
|
- match: (?=.*{{error}})
|
||||||
|
push:
|
||||||
|
- error_line_meta
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: (?=.*{{warning}})
|
||||||
|
push:
|
||||||
|
- warning_line_meta
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: (?=.*{{info}})
|
||||||
|
push:
|
||||||
|
- info_line_meta
|
||||||
|
- main_pop_at_eol
|
||||||
|
- match: (?=.*{{debug}})
|
||||||
|
push:
|
||||||
|
- debug_line_meta
|
||||||
|
- main_pop_at_eol
|
||||||
|
log_levels:
|
||||||
|
- match: '{{error}}'
|
||||||
|
scope: markup.error.log
|
||||||
|
- match: '{{warning}}'
|
||||||
|
scope: markup.warning.log
|
||||||
|
- match: '{{info}}'
|
||||||
|
scope: markup.info.log
|
||||||
|
- match: '{{debug}}'
|
||||||
|
scope: markup.info.log
|
||||||
|
error_line_meta:
|
||||||
|
- meta_scope: meta.annotation.error-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
warning_line_meta:
|
||||||
|
- meta_scope: meta.annotation.warning-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
info_line_meta:
|
||||||
|
- meta_scope: meta.annotation.info-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
debug_line_meta:
|
||||||
|
- meta_scope: meta.annotation.debug-line.log
|
||||||
|
- include: immediately_pop
|
||||||
|
immediately_pop:
|
||||||
|
- match: ''
|
||||||
|
pop: true
|
||||||
|
pop_at_eol:
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
main_pop_at_eol:
|
||||||
|
- include: main_without_log_level_line
|
||||||
|
- include: pop_at_eol
|
||||||
|
dates:
|
||||||
|
- match: \b\d{4}-\d{2}-\d{2}(?=\b|T)
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
push: maybe_date_time_separator
|
||||||
|
- match: \b\d{4}/\d{2}/\d{2}(?=\b|T)
|
||||||
|
scope: meta.date.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
push: maybe_date_time_separator
|
||||||
|
- match: \b(?={{hours_minutes_seconds}})
|
||||||
|
push: time
|
||||||
|
time:
|
||||||
|
- match: (?:{{hours_minutes_seconds}})(?:(\.)\d{3})?\b
|
||||||
|
scope: meta.time.log meta.number.integer.decimal.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
- include: immediately_pop
|
||||||
|
maybe_date_time_separator:
|
||||||
|
- match: T(?={{hours_minutes_seconds}})
|
||||||
|
scope: meta.date.log meta.time.log keyword.other.log
|
||||||
|
set: time
|
||||||
|
- include: immediately_pop
|
||||||
|
ip_addresses:
|
||||||
|
- match: \b(?=(?:{{ipv4_part}}\.){3}{{ipv4_part}}\b)
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v4.log meta.number.integer.decimal.log
|
||||||
|
- match: \d+
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: \.
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- include: immediately_pop
|
||||||
|
- match: (?=(?:\h{0,4}:){2,6}\h{1,4}\b)
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.ipaddress.v6.log meta.number.integer.hexadecimal.log
|
||||||
|
- match: \h{1,4}
|
||||||
|
scope: constant.numeric.value.log
|
||||||
|
- match: ':'
|
||||||
|
scope: punctuation.separator.sequence.log
|
||||||
|
- include: immediately_pop
|
||||||
|
numbers:
|
||||||
|
- match: \b(0x)(\h+)(?:(\.)(\h+))?\b
|
||||||
|
scope: meta.number.float.hexadecimal.log
|
||||||
|
captures:
|
||||||
|
1: constant.numeric.base.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
3: constant.numeric.value.log punctuation.separator.decimal.log
|
||||||
|
4: constant.numeric.value.log
|
||||||
|
- match: \b\d+(\.)\d+\b
|
||||||
|
scope: meta.number.float.log constant.numeric.value.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.log
|
||||||
|
- match: \b\d+\b
|
||||||
|
scope: meta.number.integer.log constant.numeric.value.log
|
||||||
|
url-host:
|
||||||
|
- meta_content_scope: markup.underline.link.host.log
|
||||||
|
- match: \[
|
||||||
|
scope: punctuation.section.brackets.begin.log
|
||||||
|
push:
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.brackets.end.log
|
||||||
|
pop: true
|
||||||
|
- include: ip_addresses
|
||||||
|
- match: '[^:/\s]+'
|
||||||
|
- match: ''
|
||||||
|
set: url-after-host
|
||||||
|
url-after-host:
|
||||||
|
- match: (:)(\d+)
|
||||||
|
scope: markup.underline.link.port.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.mapping.port.log
|
||||||
|
2: constant.numeric.value.log
|
||||||
|
#- include: scope:text.html.markdown#url-escaped-chars
|
||||||
|
- match: (%)\h{2}
|
||||||
|
scope: markup.underline.link.path.log constant.character.escape.url.log
|
||||||
|
captures:
|
||||||
|
1: punctuation.definition.escape.log
|
||||||
|
# After a valid domain, zero or more non-space non-< characters may follow
|
||||||
|
- match: (?=[?!.,:*_~]*[\s<]) # Trailing punctuation (specifically, ?, !, ., ,, :, *, _, and ~) will not be considered part of the autolink, though they may be included in the interior of the link
|
||||||
|
pop: true
|
||||||
|
- match: \( # When an autolink ends in ), we scan the entire autolink for the total number of parentheses. If there is a greater number of closing parentheses than opening ones, we don’t consider the last character part of the autolink, in order to facilitate including an autolink inside a parenthesis
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.underline.link.path.log
|
||||||
|
- match: (?=[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: \)
|
||||||
|
pop: true
|
||||||
|
- match: (?=\)[?!.,:*_~]*[\s<])
|
||||||
|
pop: true
|
||||||
|
- match: '[^?!.,:*_~\s<&()%]+|\S'
|
||||||
|
scope: markup.underline.link.path.log
|
||||||
|
- include: immediately_pop
|
||||||
|
double_quoted_string:
|
||||||
|
- meta_scope: string.quoted.double.log
|
||||||
|
- match: \\"
|
||||||
|
scope: constant.character.escape.log
|
||||||
|
- match: \\n
|
||||||
|
scope: constant.character.escape.log
|
||||||
|
- match: \"
|
||||||
|
scope: punctuation.definition.string.end.log
|
||||||
|
pop: true
|
||||||
609
assets/nix.sublime-syntax
Normal file
609
assets/nix.sublime-syntax
Normal file
|
|
@ -0,0 +1,609 @@
|
||||||
|
%YAML 1.2
|
||||||
|
---
|
||||||
|
# http://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
name: Nix
|
||||||
|
file_extensions:
|
||||||
|
- nix
|
||||||
|
scope: source.nix
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- include: expression
|
||||||
|
comment:
|
||||||
|
- match: '/\*([^*]|\*[^\/])*'
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.nix
|
||||||
|
- match: \*\/
|
||||||
|
pop: true
|
||||||
|
- include: comment-remark
|
||||||
|
- match: '\#'
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.line.number-sign.nix
|
||||||
|
- match: $
|
||||||
|
pop: true
|
||||||
|
- include: comment-remark
|
||||||
|
attribute-bind:
|
||||||
|
- include: attribute-name
|
||||||
|
- include: attribute-bind-from-equals
|
||||||
|
attribute-bind-from-equals:
|
||||||
|
- match: \=
|
||||||
|
captures:
|
||||||
|
0: keyword.operator.bind.nix
|
||||||
|
push:
|
||||||
|
- match: \;
|
||||||
|
captures:
|
||||||
|
0: punctuation.terminator.bind.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
attribute-inherit:
|
||||||
|
- match: \binherit\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.inherit.nix
|
||||||
|
push:
|
||||||
|
- match: \;
|
||||||
|
captures:
|
||||||
|
0: punctuation.terminator.inherit.nix
|
||||||
|
pop: true
|
||||||
|
- match: \(
|
||||||
|
captures:
|
||||||
|
0: punctuation.section.function.arguments.nix
|
||||||
|
push:
|
||||||
|
- match: (?=\;)
|
||||||
|
pop: true
|
||||||
|
- match: \)
|
||||||
|
captures:
|
||||||
|
0: punctuation.section.function.arguments.nix
|
||||||
|
push:
|
||||||
|
- match: (?=\;)
|
||||||
|
pop: true
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: attribute-name-single
|
||||||
|
- include: others
|
||||||
|
- include: expression
|
||||||
|
- match: '(?=[a-zA-Z\_])'
|
||||||
|
push:
|
||||||
|
- match: (?=\;)
|
||||||
|
pop: true
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: attribute-name-single
|
||||||
|
- include: others
|
||||||
|
- include: others
|
||||||
|
attribute-name:
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
scope: entity.other.attribute-name.multipart.nix
|
||||||
|
- match: \.
|
||||||
|
- include: string-quoted
|
||||||
|
- include: interpolation
|
||||||
|
attribute-name-single:
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
scope: entity.other.attribute-name.single.nix
|
||||||
|
attrset-contents:
|
||||||
|
- include: attribute-inherit
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: attribute-bind
|
||||||
|
- include: others
|
||||||
|
attrset-definition:
|
||||||
|
- match: '(?=\{)'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: '(\{)'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.attrset.nix
|
||||||
|
push:
|
||||||
|
- match: '(\})'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.attrset.nix
|
||||||
|
pop: true
|
||||||
|
- include: attrset-contents
|
||||||
|
- match: '(?<=\})'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
attrset-definition-brace-opened:
|
||||||
|
- match: '(?<=\})'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: '\}'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.attrset.nix
|
||||||
|
pop: true
|
||||||
|
- include: attrset-contents
|
||||||
|
attrset-for-sure:
|
||||||
|
- match: (?=\brec\b)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: \brec\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=\{)'
|
||||||
|
pop: true
|
||||||
|
- include: others
|
||||||
|
- include: attrset-definition
|
||||||
|
- include: others
|
||||||
|
- match: '(?=\{\s*(\}|[^,?]*(=|;)))'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: attrset-definition
|
||||||
|
- include: others
|
||||||
|
attrset-or-function:
|
||||||
|
- match: '\{'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.attrset-or-function.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: '(?=(\s*\}|\"|\binherit\b|\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*(\s*\.|\s*=[^=])|\$\{[a-zA-z0-9\_\''\-]+\}(\s*\.|\s*=[^=])))'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: attrset-definition-brace-opened
|
||||||
|
- match: '(?=(\.\.\.|\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*\s*[,?]))'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-definition-brace-opened
|
||||||
|
- include: bad-reserved
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
captures:
|
||||||
|
0: variable.parameter.function.maybe.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: (?=\.)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: attrset-definition-brace-opened
|
||||||
|
- match: \s*(\,)
|
||||||
|
captures:
|
||||||
|
1: keyword.operator.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-definition-brace-opened
|
||||||
|
- match: (?=\=)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: attribute-bind-from-equals
|
||||||
|
- include: attrset-definition-brace-opened
|
||||||
|
- match: (?=\?)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-parameter-default
|
||||||
|
- match: \,
|
||||||
|
captures:
|
||||||
|
0: keyword.operator.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-definition-brace-opened
|
||||||
|
- include: others
|
||||||
|
- include: others
|
||||||
|
bad-reserved:
|
||||||
|
- match: '(?<![\w''-])(if|then|else|assert|with|let|in|rec|inherit)(?![\w''-])'
|
||||||
|
scope: invalid.illegal.reserved.nix
|
||||||
|
comment-remark:
|
||||||
|
- match: (TODO|FIXME|BUG|\!\!\!):?
|
||||||
|
captures:
|
||||||
|
1: markup.bold.comment.nix
|
||||||
|
constants:
|
||||||
|
- match: \b(builtins|true|false|null)\b
|
||||||
|
captures:
|
||||||
|
0: constant.language.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- match: \b(scopedImport|import|isNull|abort|throw|baseNameOf|dirOf|removeAttrs|map|toString|derivationStrict|derivation)\b
|
||||||
|
captures:
|
||||||
|
0: support.function.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- match: '\b[0-9]+\b'
|
||||||
|
captures:
|
||||||
|
0: constant.numeric.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
expression:
|
||||||
|
- include: parens-and-cont
|
||||||
|
- include: list-and-cont
|
||||||
|
- include: string
|
||||||
|
- include: interpolation
|
||||||
|
- include: with-assert
|
||||||
|
- include: function-for-sure
|
||||||
|
- include: attrset-for-sure
|
||||||
|
- include: attrset-or-function
|
||||||
|
- include: let
|
||||||
|
- include: if
|
||||||
|
- include: operator-unary
|
||||||
|
- include: constants
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: parameter-name-and-cont
|
||||||
|
- include: others
|
||||||
|
expression-cont:
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: parens
|
||||||
|
- include: list
|
||||||
|
- include: string
|
||||||
|
- include: interpolation
|
||||||
|
- include: function-for-sure
|
||||||
|
- include: attrset-for-sure
|
||||||
|
- include: attrset-or-function
|
||||||
|
- match: '(\bor\b|\.|==|!=|!|\<\=|\<|\>\=|\>|&&|\|\||-\>|//|\?|\+\+|-|\*|/(?=([^*]|$))|\+)'
|
||||||
|
scope: keyword.operator.nix
|
||||||
|
- include: constants
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: parameter-name
|
||||||
|
- include: others
|
||||||
|
function-body:
|
||||||
|
- match: '(@\s*([a-zA-Z\_][a-zA-Z0-9\_\''\-]*)\s*)?(\:)'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
function-body-from-colon:
|
||||||
|
- match: (\:)
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.function.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
function-contents:
|
||||||
|
- include: bad-reserved
|
||||||
|
- include: function-parameter
|
||||||
|
- include: others
|
||||||
|
function-definition:
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-body-from-colon
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- match: '(\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*)'
|
||||||
|
captures:
|
||||||
|
0: variable.parameter.function.4.nix
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- match: \@
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-until-colon-no-arg
|
||||||
|
- include: others
|
||||||
|
- include: others
|
||||||
|
- match: '(?=\{)'
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-until-colon-with-arg
|
||||||
|
- include: others
|
||||||
|
function-definition-brace-opened:
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-body-from-colon
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-close-brace-with-arg
|
||||||
|
- match: (?=.?)
|
||||||
|
push:
|
||||||
|
- match: '(?=\})'
|
||||||
|
pop: true
|
||||||
|
- include: function-contents
|
||||||
|
- include: others
|
||||||
|
function-for-sure:
|
||||||
|
- match: '(?=(\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*\s*[:@]|\{[^}]*\}\s*:|\{[^#}"''/=]*[,\?]))'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: function-definition
|
||||||
|
function-header-close-brace-no-arg:
|
||||||
|
- match: '\}'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.entity.function.nix
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: others
|
||||||
|
function-header-close-brace-with-arg:
|
||||||
|
- match: '\}'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.entity.function.nix
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-terminal-arg
|
||||||
|
- include: others
|
||||||
|
function-header-open-brace:
|
||||||
|
- match: '\{'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.entity.function.2.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=\})'
|
||||||
|
pop: true
|
||||||
|
- include: function-contents
|
||||||
|
function-header-terminal-arg:
|
||||||
|
- match: (?=@)
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- match: \@
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- match: '(\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*)'
|
||||||
|
push:
|
||||||
|
- meta_scope: variable.parameter.function.3.nix
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: others
|
||||||
|
- include: others
|
||||||
|
function-header-until-colon-no-arg:
|
||||||
|
- match: '(?=\{)'
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-open-brace
|
||||||
|
- include: function-header-close-brace-no-arg
|
||||||
|
function-header-until-colon-with-arg:
|
||||||
|
- match: '(?=\{)'
|
||||||
|
push:
|
||||||
|
- match: (?=\:)
|
||||||
|
pop: true
|
||||||
|
- include: function-header-open-brace
|
||||||
|
- include: function-header-close-brace-with-arg
|
||||||
|
function-parameter:
|
||||||
|
- match: (\.\.\.)
|
||||||
|
push:
|
||||||
|
- meta_scope: keyword.operator.nix
|
||||||
|
- match: '(,|(?=\}))'
|
||||||
|
pop: true
|
||||||
|
- include: others
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
captures:
|
||||||
|
0: variable.parameter.function.1.nix
|
||||||
|
push:
|
||||||
|
- match: '(,|(?=\}))'
|
||||||
|
captures:
|
||||||
|
0: keyword.operator.nix
|
||||||
|
pop: true
|
||||||
|
- include: whitespace
|
||||||
|
- include: comment
|
||||||
|
- include: function-parameter-default
|
||||||
|
- include: expression
|
||||||
|
- include: others
|
||||||
|
function-parameter-default:
|
||||||
|
- match: \?
|
||||||
|
captures:
|
||||||
|
0: keyword.operator.nix
|
||||||
|
push:
|
||||||
|
- match: "(?=[,}])"
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
if:
|
||||||
|
- match: (?=\bif\b)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: \bif\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: \bth(?=en\b)
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
- match: (?<=th)en\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: \bel(?=se\b)
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
- match: (?<=el)se\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
illegal:
|
||||||
|
- match: .
|
||||||
|
scope: invalid.illegal
|
||||||
|
interpolation:
|
||||||
|
- match: '\$\{'
|
||||||
|
captures:
|
||||||
|
0: punctuation.section.embedded.begin.nix
|
||||||
|
push:
|
||||||
|
- meta_scope: markup.italic
|
||||||
|
- match: '\}'
|
||||||
|
captures:
|
||||||
|
0: punctuation.section.embedded.end.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
let:
|
||||||
|
- match: (?=\blet\b)
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: \blet\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(in|else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: '(?=\{)'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: '\{'
|
||||||
|
push:
|
||||||
|
- match: '\}'
|
||||||
|
pop: true
|
||||||
|
- include: attrset-contents
|
||||||
|
- match: '(^|(?<=\}))'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- include: others
|
||||||
|
- include: attrset-contents
|
||||||
|
- include: others
|
||||||
|
- match: \bin\b
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
list:
|
||||||
|
- match: '\['
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.list.nix
|
||||||
|
push:
|
||||||
|
- match: '\]'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.list.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
list-and-cont:
|
||||||
|
- match: '(?=\[)'
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: list
|
||||||
|
- include: expression-cont
|
||||||
|
operator-unary:
|
||||||
|
- match: (!|-)
|
||||||
|
scope: keyword.operator.unary.nix
|
||||||
|
others:
|
||||||
|
- include: whitespace
|
||||||
|
- include: comment
|
||||||
|
- include: illegal
|
||||||
|
parameter-name:
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
captures:
|
||||||
|
0: variable.parameter.name.nix
|
||||||
|
parameter-name-and-cont:
|
||||||
|
- match: '\b[a-zA-Z\_][a-zA-Z0-9\_\''\-]*'
|
||||||
|
captures:
|
||||||
|
0: variable.parameter.name.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
parens:
|
||||||
|
- match: \(
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.expression.nix
|
||||||
|
push:
|
||||||
|
- match: \)
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.expression.nix
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
|
parens-and-cont:
|
||||||
|
- match: (?=\()
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: parens
|
||||||
|
- include: expression-cont
|
||||||
|
string:
|
||||||
|
- match: (?=\'\')
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- match: \'\'
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.other.start.nix
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.other.nix
|
||||||
|
- match: \'\'(?!\$|\'|\\.)
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.other.end.nix
|
||||||
|
pop: true
|
||||||
|
- match: \'\'(\$|\'|\\.)
|
||||||
|
scope: constant.character.escape.nix
|
||||||
|
- include: interpolation
|
||||||
|
- include: expression-cont
|
||||||
|
- match: (?=\")
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: string-quoted
|
||||||
|
- include: expression-cont
|
||||||
|
- match: '(~?[a-zA-Z0-9\.\_\-\+]*(\/[a-zA-Z0-9\.\_\-\+]+)+)'
|
||||||
|
captures:
|
||||||
|
0: string.unquoted.path.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- match: '(\<[a-zA-Z0-9\.\_\-\+]+(\/[a-zA-Z0-9\.\_\-\+]+)*\>)'
|
||||||
|
captures:
|
||||||
|
0: string.unquoted.spath.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
- match: '([a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~\*\'']+)'
|
||||||
|
captures:
|
||||||
|
0: string.unquoted.url.nix
|
||||||
|
push:
|
||||||
|
- match: '(?=([\])};,]|\b(else|then)\b))'
|
||||||
|
pop: true
|
||||||
|
- include: expression-cont
|
||||||
|
string-quoted:
|
||||||
|
- match: \"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.double.start.nix
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.nix
|
||||||
|
- match: \"
|
||||||
|
captures:
|
||||||
|
0: punctuation.definition.string.double.end.nix
|
||||||
|
pop: true
|
||||||
|
- match: \\.
|
||||||
|
scope: constant.character.escape.nix
|
||||||
|
- include: interpolation
|
||||||
|
whitespace:
|
||||||
|
- match: \s+
|
||||||
|
with-assert:
|
||||||
|
- match: '(?<![\w''-])(with|assert)(?![\w''-])'
|
||||||
|
captures:
|
||||||
|
0: keyword.other.nix
|
||||||
|
push:
|
||||||
|
- match: \;
|
||||||
|
pop: true
|
||||||
|
- include: expression
|
||||||
552
assets/tf.sublime-syntax
Normal file
552
assets/tf.sublime-syntax
Normal file
|
|
@ -0,0 +1,552 @@
|
||||||
|
%YAML 1.2
|
||||||
|
#
|
||||||
|
# This syntax definition is based on the Terraform guide:
|
||||||
|
# https://www.terraform.io/docs/configuration/index.html
|
||||||
|
#
|
||||||
|
# As well as the HCL Native Syntax Spec:
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md
|
||||||
|
#
|
||||||
|
# For documentation on the .subline-syntax format:
|
||||||
|
# https://www.sublimetext.com/docs/3/syntax.html
|
||||||
|
#
|
||||||
|
# Regex's in this file support the Oniguruma regex engine:
|
||||||
|
# https://raw.githubusercontent.com/kkos/oniguruma/5.9.6/doc/RE
|
||||||
|
#
|
||||||
|
---
|
||||||
|
name: Terraform
|
||||||
|
|
||||||
|
# File Extensions:
|
||||||
|
#
|
||||||
|
# - ".tf": the standard file extension
|
||||||
|
# https://www.terraform.io/docs/configuration/index.html#code-organization
|
||||||
|
#
|
||||||
|
# - ".tfvars": variables definitions file
|
||||||
|
# https://www.terraform.io/docs/configuration/variables.html#variable-definitions-tfvars-files
|
||||||
|
#
|
||||||
|
# - ".hcl": non-terraform tools often use this HCL syntax, i.e. Vault
|
||||||
|
# https://www.vaultproject.io/docs/configuration/
|
||||||
|
file_extensions:
|
||||||
|
- tf
|
||||||
|
- tfvars
|
||||||
|
- hcl
|
||||||
|
scope: source.terraform
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# Identifiers: (UTF-8) (ID_Continue | '-')*;
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#identifiers
|
||||||
|
identifer: \b(?!null|false|true)[[:alpha:]][[:alnum:]_-]*\b
|
||||||
|
|
||||||
|
# Exponent: "e" or "E" followed by an optional sign
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#numeric-literals
|
||||||
|
exponent: ([Ee][+-]?)
|
||||||
|
|
||||||
|
# Character Escapes:
|
||||||
|
#
|
||||||
|
# - \n: newline
|
||||||
|
# - \r: carriage return
|
||||||
|
# - \t: tab
|
||||||
|
# - \": quote
|
||||||
|
# - \\: backslash
|
||||||
|
# - \uNNNN: unicode char (NNNN is 4 hex digits)
|
||||||
|
# - \uNNNNNNNN: unicode char (NNNNNNNN us 8 digits)
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#template-expressions
|
||||||
|
char_escapes: \\[nrt"\\]|\\u(\h{8}|\h{4})
|
||||||
|
|
||||||
|
# Terraform Named Values
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#references-to-named-values
|
||||||
|
named_values: var|local|module|data|path|terraform
|
||||||
|
|
||||||
|
# Block types that are known to Terraform.
|
||||||
|
#
|
||||||
|
# resource: https://www.terraform.io/docs/configuration/resources.html
|
||||||
|
# provider: https://www.terraform.io/docs/configuration/providers.html
|
||||||
|
# variable: https://www.terraform.io/docs/configuration/variables.html
|
||||||
|
# output: https://www.terraform.io/docs/configuration/outputs.html
|
||||||
|
# locals: https://www.terraform.io/docs/configuration/locals.html
|
||||||
|
# module: https://www.terraform.io/docs/configuration/modules.html
|
||||||
|
# data: https://www.terraform.io/docs/configuration/data-sources.html
|
||||||
|
# terraform: https://www.terraform.io/docs/configuration/terraform.html#terraform-block-syntax
|
||||||
|
terraform_known_blocks: resource|provider|variable|output|locals|module|data|terraform
|
||||||
|
|
||||||
|
# Terraform built-in type keywords
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/types.html#primitive-types
|
||||||
|
# https://www.terraform.io/docs/configuration/types.html#dynamic-types-the-quot-any-quot-constraint
|
||||||
|
terraform_type_keywords: any|string|number|bool
|
||||||
|
|
||||||
|
# Built-In Functions
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/functions.html
|
||||||
|
predeclared_funcs: abs|ceil|floor|log|max|min|pow|signum|chomp|format|formatlist|indent|join|lower|regex|regexall|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalesce|coalescelist|compact|concat|contains|distinct|element|flatten|index|keys|length|list|lookup|map|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring
|
||||||
|
|
||||||
|
contexts:
|
||||||
|
main:
|
||||||
|
- include: comments
|
||||||
|
- include: attribute_definition
|
||||||
|
- include: imports
|
||||||
|
- include: block
|
||||||
|
- include: expressions
|
||||||
|
|
||||||
|
comments:
|
||||||
|
- include: inline_comments
|
||||||
|
- include: block_comments
|
||||||
|
|
||||||
|
# Expressions:
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#expression-terms
|
||||||
|
expressions:
|
||||||
|
- include: literal_values
|
||||||
|
- include: operators
|
||||||
|
- include: brackets
|
||||||
|
- include: objects
|
||||||
|
- include: attribute_access
|
||||||
|
- include: functions
|
||||||
|
- include: parens
|
||||||
|
|
||||||
|
comma:
|
||||||
|
- match: \,
|
||||||
|
comment: Commas - used in certain expressions
|
||||||
|
scope: punctuation.separator.terraform
|
||||||
|
|
||||||
|
parens:
|
||||||
|
- match: \(
|
||||||
|
scope: punctuation.section.parens.begin.terraform
|
||||||
|
comment: Parens - matched *after* function syntax
|
||||||
|
push:
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.parens.end.terraform
|
||||||
|
pop: true
|
||||||
|
- include: expressions
|
||||||
|
- match: "{{identifer}}"
|
||||||
|
comment: Local Identifiers
|
||||||
|
scope: variable.other.readwrite.terraform
|
||||||
|
|
||||||
|
# Literal Values: Numbers, Language Constants, and Strings
|
||||||
|
#
|
||||||
|
# Strings are _technically_ part of the "expression sub-language",
|
||||||
|
# but make the most sense to be part of this stack.
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#literal-values
|
||||||
|
literal_values:
|
||||||
|
- include: numeric_literals
|
||||||
|
- include: language_constants
|
||||||
|
- include: string_literals
|
||||||
|
- include: heredoc
|
||||||
|
- include: type_keywords
|
||||||
|
- include: named_value_references
|
||||||
|
|
||||||
|
named_value_references:
|
||||||
|
- match: '\b({{named_values}})\b'
|
||||||
|
comment: Constant values available only to Terraform.
|
||||||
|
scope: support.constant.terraform
|
||||||
|
|
||||||
|
type_keywords:
|
||||||
|
- match: '\b({{terraform_type_keywords}})\b'
|
||||||
|
comment: Type keywords known to Terraform.
|
||||||
|
scope: storage.type.terraform
|
||||||
|
|
||||||
|
# Inline Comments: begin at the operator, end at the end of the line.
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/syntax.html#comments
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#comments-and-whitespace
|
||||||
|
inline_comments:
|
||||||
|
- match: '#|//'
|
||||||
|
comment: Inline Comments
|
||||||
|
scope: punctuation.definition.comment.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.line.terraform
|
||||||
|
- match: $\n?
|
||||||
|
scope: punctuation.definition.comment.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Block comments: start and end delimiters for multi-line comments.
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/syntax.html#comments
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#comments-and-whitespace
|
||||||
|
block_comments:
|
||||||
|
- match: /\*
|
||||||
|
comment: Block comments
|
||||||
|
scope: punctuation.definition.comment.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: comment.block.terraform
|
||||||
|
- match: \*/
|
||||||
|
scope: punctuation.definition.comment.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Language Constants: booleans and `null`.
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#literal-expressions
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#literal-values
|
||||||
|
language_constants:
|
||||||
|
- match: \b(true|false|null)\b
|
||||||
|
comment: Language Constants
|
||||||
|
scope: constant.language.terraform
|
||||||
|
|
||||||
|
# Numbers: Integers, fractions and exponents
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#types-and-values
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#numeric-literals
|
||||||
|
numeric_literals:
|
||||||
|
- match: \b\d+({{exponent}})\d+\b
|
||||||
|
comment: Integer, no fraction, optional exponent
|
||||||
|
scope: constant.numeric.float.terraform
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.exponent.terraform
|
||||||
|
- match: \b\d+(\.)\d+(?:({{exponent}})\d+)?\b
|
||||||
|
comment: Integer, fraction, optional exponent
|
||||||
|
scope: constant.numeric.float.terraform
|
||||||
|
captures:
|
||||||
|
1: punctuation.separator.decimal.terraform
|
||||||
|
2: punctuation.separator.exponent.terraform
|
||||||
|
- match: \b\d+\b
|
||||||
|
comment: Integers
|
||||||
|
scope: constant.numeric.integer.terraform
|
||||||
|
|
||||||
|
# Strings:
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#types-and-values
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#template-expressions
|
||||||
|
string_literals:
|
||||||
|
- match: '"'
|
||||||
|
comment: Strings
|
||||||
|
scope: punctuation.definition.string.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.terraform
|
||||||
|
- match: '"'
|
||||||
|
scope: punctuation.definition.string.end.terraform
|
||||||
|
pop: true
|
||||||
|
- include: string_interpolation
|
||||||
|
- match: '{{char_escapes}}'
|
||||||
|
comment: Character Escapes
|
||||||
|
scope: constant.character.escape.terraform
|
||||||
|
|
||||||
|
# String Interpolation: ("${" | "${~") Expression ("}" | "~}"
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#templates
|
||||||
|
string_interpolation:
|
||||||
|
- match: (\$|\%)\{
|
||||||
|
comment: String interpolation
|
||||||
|
scope: keyword.other.interpolation.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.interpolation.terraform
|
||||||
|
- clear_scopes: 1 # Clear the string.* scope.
|
||||||
|
- match: \}
|
||||||
|
scope: keyword.other.interpolation.end.terraform
|
||||||
|
pop: true
|
||||||
|
- match: \~\s
|
||||||
|
comment: Trim left whitespace
|
||||||
|
scope: keyword.operator.template.left.trim.terraform
|
||||||
|
- match: \s\~
|
||||||
|
comment: Trim right whitespace
|
||||||
|
scope: keyword.operator.template.right.trim.terraform
|
||||||
|
- match: \b(if|else|endif|for|in|endfor)\b
|
||||||
|
comment: if/else/endif and for/in/endfor directives
|
||||||
|
scope: keyword.control.terraform
|
||||||
|
- include: expressions
|
||||||
|
|
||||||
|
# String Heredocs
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#template-expressions
|
||||||
|
heredoc:
|
||||||
|
- match: (\<\<\-?)\s*({{identifer}})\s*$
|
||||||
|
comment: String Heredoc's
|
||||||
|
captures:
|
||||||
|
1: keyword.operator.heredoc.terraform
|
||||||
|
2: keyword.control.heredoc.terraform
|
||||||
|
push:
|
||||||
|
- meta_content_scope: string.unquoted.heredoc.terraform
|
||||||
|
- match: ^\s*\2\s*$
|
||||||
|
comment: The heredoc token identifier (second capture above).
|
||||||
|
scope: keyword.control.heredoc.terraform
|
||||||
|
pop: true
|
||||||
|
- include: string_interpolation
|
||||||
|
|
||||||
|
# Operators:
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#operators-and-delimiters
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#operations
|
||||||
|
operators:
|
||||||
|
- match: \>\= # >=
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \<\= # <=
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \=\= # ==
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \!\= # !=
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \+ # +
|
||||||
|
scope: keyword.operator.arithmetic.terraform
|
||||||
|
- match: \- # -
|
||||||
|
scope: keyword.operator.arithmetic.terraform
|
||||||
|
- match: \* # *
|
||||||
|
scope: keyword.operator.arithmetic.terraform
|
||||||
|
- match: \/ # /
|
||||||
|
scope: keyword.operator.arithmetic.terraform
|
||||||
|
- match: \% # %
|
||||||
|
scope: keyword.operator.arithmetic.terraform
|
||||||
|
- match: \&\& # &&
|
||||||
|
scope: keyword.operator.logical.terraform
|
||||||
|
- match: \|\| # ||
|
||||||
|
scope: keyword.operator.logical.terraform
|
||||||
|
- match: \! # !
|
||||||
|
scope: keyword.operator.logical.terraform
|
||||||
|
- match: \> # >
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \< # <
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \? # ?
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: \.\.\. # ...
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- match: "\\:" # :
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
|
||||||
|
# Terraform "import" statements
|
||||||
|
#
|
||||||
|
# https://www.terraform.io/docs/import/usage.html
|
||||||
|
imports:
|
||||||
|
- match: \s*(terraform)\s*(import)\s*
|
||||||
|
comment: Importing resources
|
||||||
|
captures:
|
||||||
|
1: support.constant.terraform
|
||||||
|
2: keyword.control.import.terraform
|
||||||
|
push:
|
||||||
|
- match: \"
|
||||||
|
comment: String literal label
|
||||||
|
scope: punctuation.definition.string.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.terraform
|
||||||
|
- match: \"
|
||||||
|
scope: punctuation.definition.string.end.terraform
|
||||||
|
pop: true
|
||||||
|
- match: "{{identifer}}"
|
||||||
|
comment: Identifer label
|
||||||
|
scope: entity.name.label.terraform
|
||||||
|
- include: numeric_literals
|
||||||
|
- include: attribute_access
|
||||||
|
- match: $\n?
|
||||||
|
comment: Pop at newline
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Brackets: matches tuples and subscript notation
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#index-operator
|
||||||
|
brackets:
|
||||||
|
- match: \[
|
||||||
|
scope: punctuation.section.brackets.begin.terraform
|
||||||
|
push:
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.brackets.end.terraform
|
||||||
|
pop: true
|
||||||
|
- match: (\*)\]
|
||||||
|
comment: Full-splat operator
|
||||||
|
scope: punctuation.section.brackets.end.terraform
|
||||||
|
captures:
|
||||||
|
1: keyword.operator.splat.terraform
|
||||||
|
pop: true
|
||||||
|
- include: comma
|
||||||
|
- include: comments
|
||||||
|
- include: expressions
|
||||||
|
- include: tuple_for_expression
|
||||||
|
|
||||||
|
# Objects: collection values
|
||||||
|
#
|
||||||
|
# Allows keys as identifiers, strings, and computed values wrapped in parens.
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#collection-values
|
||||||
|
objects:
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.braces.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.braces.terraform
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.braces.end.terraform
|
||||||
|
pop: true
|
||||||
|
- include: object_for_expression
|
||||||
|
- include: comments
|
||||||
|
- match: '\s*({{identifer}})\s*(\=)\s*'
|
||||||
|
comment: Literal, named object key
|
||||||
|
captures:
|
||||||
|
1: meta.mapping.key.terraform string.unquoted.terraform
|
||||||
|
2: keyword.operator.terraform
|
||||||
|
push: object_key_values
|
||||||
|
- match: '((\").*(\"))\s*(\=)\s*'
|
||||||
|
comment: String object key
|
||||||
|
captures:
|
||||||
|
1: meta.mapping.key.terraform string.quoted.double.terraform
|
||||||
|
2: punctuation.definition.string.begin.terraform
|
||||||
|
3: punctuation.definition.string.end.terraform
|
||||||
|
4: keyword.operator.terraform
|
||||||
|
push: object_key_values
|
||||||
|
- match: \(
|
||||||
|
comment: Computed object key (any expression between parens)
|
||||||
|
scope: punctuation.section.parens.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.mapping.key.terraform
|
||||||
|
- match: '(\))\s*(\=)\s*'
|
||||||
|
captures:
|
||||||
|
1: punctuation.section.parens.end.terraform
|
||||||
|
2: keyword.operator.terraform
|
||||||
|
set: object_key_values
|
||||||
|
- include: expressions
|
||||||
|
|
||||||
|
# Object key values: pop at comma, newline, and closing-bracket
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#collection-values
|
||||||
|
object_key_values:
|
||||||
|
- include: comments
|
||||||
|
- include: expressions
|
||||||
|
- match: \,
|
||||||
|
comment: Pop scope on comma.
|
||||||
|
scope: punctuation.separator.terraform
|
||||||
|
pop: true
|
||||||
|
- match: $\n?
|
||||||
|
comment: Pop scope on EOL.
|
||||||
|
pop: true
|
||||||
|
- match: (?=\})
|
||||||
|
comment: Lookahead (don't consume) and pop scope on a bracket.
|
||||||
|
scope: punctuation.section.braces.end.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Attribute Access: "." Identifier
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#attribute-access-operator
|
||||||
|
attribute_access:
|
||||||
|
- match: \.
|
||||||
|
scope: keyword.operator.accessor.terraform
|
||||||
|
push:
|
||||||
|
- match: "{{identifer}}"
|
||||||
|
comment: Attribute access
|
||||||
|
scope: variable.other.member.terraform
|
||||||
|
pop: true
|
||||||
|
- match: \d+
|
||||||
|
comment: Subscript
|
||||||
|
scope: constant.numeric.integer.terraform
|
||||||
|
pop: true
|
||||||
|
- match: \*
|
||||||
|
comment: Attribute-only splat
|
||||||
|
scope: keyword.operator.splat.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Attribute Definition: Identifier "=" Expression Newline
|
||||||
|
#
|
||||||
|
# The "=" operator cannot be immediately followed by "="
|
||||||
|
# ">", as those are other operators, not attr definitions.
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#attribute-definitions
|
||||||
|
attribute_definition:
|
||||||
|
- match: (\()?({{identifer}})(\))?\s*(\=[^\=|\>])\s*
|
||||||
|
comment: Identifier "=" with optional parens
|
||||||
|
scope: variable.declaration.terraform
|
||||||
|
captures:
|
||||||
|
1: punctuation.section.parens.begin.terraform
|
||||||
|
2: variable.other.readwrite.terraform
|
||||||
|
3: punctuation.section.parens.end.terraform
|
||||||
|
4: keyword.operator.assignment.terraform
|
||||||
|
|
||||||
|
# Functions: Terraform builtins and unknown
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#functions-and-function-calls
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#function-calls
|
||||||
|
functions:
|
||||||
|
- match: (({{predeclared_funcs}})|\b({{identifer}})\b)(\()
|
||||||
|
comment: Built-in function calls
|
||||||
|
captures:
|
||||||
|
2: support.function.builtin.terraform
|
||||||
|
3: variable.function.terraform
|
||||||
|
4: punctuation.section.parens.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.function-call.terraform
|
||||||
|
- match: \)
|
||||||
|
scope: punctuation.section.parens.end.terraform
|
||||||
|
pop: true
|
||||||
|
- include: comments
|
||||||
|
- include: expressions
|
||||||
|
- include: comma
|
||||||
|
|
||||||
|
# Tuple for-Expression:
|
||||||
|
#
|
||||||
|
# "[" "for" Identifier ("," Identifier)? "in" Expression ":" Expression ("if" Expression)? "]";
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#for-expressions
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#for-expressions
|
||||||
|
tuple_for_expression:
|
||||||
|
- match: \bfor\b
|
||||||
|
comment: for expression (arrays)
|
||||||
|
scope: keyword.control.terraform
|
||||||
|
set:
|
||||||
|
- include: for_expression_body
|
||||||
|
- match: \]
|
||||||
|
scope: punctuation.section.brackets.end.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Object for-Expression:
|
||||||
|
#
|
||||||
|
# "{" "for" Identifier ("," Identifier)? "in" Expression ":" Expression "=>" Expression "..."? ("if" Expression)? "}";
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#for-expressions
|
||||||
|
# https://www.terraform.io/docs/configuration/expressions.html#for-expressions
|
||||||
|
object_for_expression:
|
||||||
|
- match: \bfor\b
|
||||||
|
comment: for expression (arrays)
|
||||||
|
scope: keyword.control.terraform
|
||||||
|
set:
|
||||||
|
- match: \=\>
|
||||||
|
scope: storage.type.function.terraform
|
||||||
|
- include: for_expression_body
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.braces.end.terraform
|
||||||
|
pop: true
|
||||||
|
|
||||||
|
# Shared body syntax for tuple and object for-expressions.
|
||||||
|
# They require different `set` blocks because they are
|
||||||
|
# pop'd with different characters and objects allow `=>`.
|
||||||
|
for_expression_body:
|
||||||
|
- match: \bin\b
|
||||||
|
comment: in keyword
|
||||||
|
scope: keyword.operator.word.terraform
|
||||||
|
- match: \bif\b
|
||||||
|
comment: if keyword
|
||||||
|
scope: keyword.control.conditional.terraform
|
||||||
|
- match: '\:'
|
||||||
|
scope: keyword.operator.terraform
|
||||||
|
- include: expressions
|
||||||
|
- include: comments
|
||||||
|
- include: comma
|
||||||
|
- match: "{{identifer}}"
|
||||||
|
comment: Local Identifiers
|
||||||
|
scope: variable.other.readwrite.terraform
|
||||||
|
|
||||||
|
# Blocks: Identifier (StringLit|Identifier)* "{" Newline Body "}" Newline;
|
||||||
|
#
|
||||||
|
# https://github.com/hashicorp/hcl2/blob/master/hcl/hclsyntax/spec.md#structural-elements
|
||||||
|
block:
|
||||||
|
- match: '(\b({{terraform_known_blocks}})\b|({{identifer}}))(?=[\s\"\-[:word:]]*(\{))'
|
||||||
|
captures:
|
||||||
|
2: storage.type.terraform
|
||||||
|
3: entity.name.type.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: meta.type.terraform
|
||||||
|
- match: \"
|
||||||
|
comment: String literal label
|
||||||
|
scope: punctuation.definition.string.begin.terraform
|
||||||
|
push:
|
||||||
|
- meta_scope: string.quoted.double.terraform
|
||||||
|
- match: \"
|
||||||
|
scope: punctuation.definition.string.end.terraform
|
||||||
|
pop: true
|
||||||
|
- match: "{{identifer}}"
|
||||||
|
comment: Identifer label
|
||||||
|
scope: entity.name.label.terraform
|
||||||
|
- match: \{
|
||||||
|
scope: punctuation.section.block.begin.terraform
|
||||||
|
set:
|
||||||
|
- meta_scope: meta.block.terraform
|
||||||
|
- include: main
|
||||||
|
- match: \}
|
||||||
|
scope: punctuation.section.block.end.terraform
|
||||||
|
pop: true
|
||||||
3580
assets/tsx.sublime-syntax
Normal file
3580
assets/tsx.sublime-syntax
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue