A human-friendly DSL for ATProto Lexicons
26
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adjust syntax highlighting

authored by stavola.xyz and committed by

Tangled 0bf25761 198df48a

+102 -39
+16
tree-sitter-mlf/queries/highlights.scm
··· 111 111 "*" 112 112 ] @operator 113 113 114 + ; The `!` marker. Context gives it its meaning: 115 + ; - On a field/parameter: required-field marker 116 + ; - Inside a union: closed-union marker 117 + (field "!" @keyword.operator) 118 + (parameter "!" @keyword.operator) 119 + (union_type "!" @keyword.operator) 120 + 114 121 ; Delimiters 115 122 [ 116 123 "(" ··· 126 133 ";" 127 134 "." 128 135 ] @punctuation.delimiter 136 + 137 + ; Annotation object literal keys (the `"name"` in `{ "name": value }`) 138 + (annotation_object_entry 139 + key: (string) @property) 140 + 141 + ; Backtick-escaped identifiers — flag visually so authors can see when 142 + ; a reserved word is being used as an identifier. 143 + ((identifier) @string.special 144 + (#match? @string.special "^`.*`$"))
+86 -39
website/syntaxes/mlf.sublime-syntax
··· 10 10 - include: comments 11 11 - include: annotations 12 12 - include: keywords 13 + - include: backtick_identifiers 13 14 - include: types 14 15 - include: strings 15 16 - include: numbers 16 17 - include: operators 18 + 19 + # Reserved words can be used as identifiers by wrapping in backticks. 20 + # Highlight them distinctly so the escape is visually obvious. 21 + backtick_identifiers: 22 + - match: '`[^`]+`' 23 + scope: string.other.identifier.mlf 17 24 18 25 comments: 19 26 - match: '///' ··· 36 43 captures: 37 44 1: entity.name.namespace.mlf 38 45 2: entity.name.function.annotation.mlf 39 - push: 40 - - match: '\(' 41 - scope: punctuation.section.arguments.begin.mlf 42 - set: 43 - - meta_scope: meta.annotation.arguments.mlf 44 - - match: '\)' 45 - scope: punctuation.section.arguments.end.mlf 46 - pop: true 47 - - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*(:)' 48 - captures: 49 - 1: variable.parameter.mlf 50 - 2: punctuation.separator.mlf 51 - - include: strings 52 - - include: numbers 53 - - match: '\b(true|false)\b' 54 - scope: constant.language.mlf 55 - - match: ',' 56 - scope: punctuation.separator.mlf 57 - - match: '(?=\S)' 58 - pop: true 46 + push: maybe_annotation_args 59 47 # Bare annotation with args: @deprecated(true) 60 48 - match: '@([a-zA-Z_][a-zA-Z0-9_]*)' 61 49 scope: meta.annotation.mlf 62 50 captures: 63 51 1: entity.name.function.annotation.mlf 64 - push: 65 - - match: '\(' 66 - scope: punctuation.section.arguments.begin.mlf 67 - set: 68 - - meta_scope: meta.annotation.arguments.mlf 69 - - match: '\)' 70 - scope: punctuation.section.arguments.end.mlf 71 - pop: true 72 - - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*(:)' 73 - captures: 74 - 1: variable.parameter.mlf 75 - 2: punctuation.separator.mlf 76 - - include: strings 77 - - include: numbers 78 - - match: '\b(true|false)\b' 79 - scope: constant.language.mlf 80 - - match: ',' 81 - scope: punctuation.separator.mlf 82 - - match: '(?=\S)' 52 + push: maybe_annotation_args 53 + 54 + # After an annotation head, an opening `(` starts the argument list. 55 + # Any other non-space token means the annotation was bare — bail out. 56 + maybe_annotation_args: 57 + - match: '\(' 58 + scope: punctuation.section.arguments.begin.mlf 59 + set: 60 + - meta_scope: meta.annotation.arguments.mlf 61 + - match: '\)' 62 + scope: punctuation.section.arguments.end.mlf 83 63 pop: true 64 + # Named argument: name: 65 + - match: '([a-zA-Z_][a-zA-Z0-9_]*)\s*(:)' 66 + captures: 67 + 1: variable.parameter.mlf 68 + 2: punctuation.separator.mlf 69 + - include: annotation_value 70 + - match: ',' 71 + scope: punctuation.separator.mlf 72 + - match: '(?=\S)' 73 + pop: true 74 + 75 + # Annotation values: string, number, bool, null, type path, array, object. 76 + # Used inside annotation args, array items, and object entry values. 77 + annotation_value: 78 + - include: strings 79 + - include: numbers 80 + - match: '\b(true|false|null)\b' 81 + scope: constant.language.mlf 82 + - match: '\[' 83 + scope: punctuation.section.brackets.begin.mlf 84 + push: annotation_array_body 85 + - match: '\{' 86 + scope: punctuation.section.braces.begin.mlf 87 + push: annotation_object_body 88 + # Type path: dotted identifier (e.g. `com.example.foo.Bar`). Match 89 + # after strings/numbers so plain keywords and bracket tokens win first. 90 + - match: '\b[a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)+\b' 91 + scope: support.type.mlf 92 + 93 + annotation_array_body: 94 + - match: '\]' 95 + scope: punctuation.section.brackets.end.mlf 96 + pop: true 97 + - include: annotation_value 98 + - match: ',' 99 + scope: punctuation.separator.mlf 100 + 101 + annotation_object_body: 102 + - match: '\}' 103 + scope: punctuation.section.braces.end.mlf 104 + pop: true 105 + # Object key — any string literal followed by `:` 106 + - match: '(")((?:\\.|[^"\\])*)(")\s*(:)' 107 + captures: 108 + 1: punctuation.definition.string.begin.mlf 109 + 2: string.quoted.double.mlf entity.name.tag.mlf 110 + 3: punctuation.definition.string.end.mlf 111 + 4: punctuation.separator.mlf 112 + - include: annotation_value 113 + - match: ',' 114 + scope: punctuation.separator.mlf 84 115 85 116 keywords: 117 + # `error` keyword — when followed by `{`, begin an error-block context 118 + # so error names inside render as constants. 119 + - match: '\b(error)\b\s*(\{)' 120 + captures: 121 + 1: keyword.control.mlf 122 + 2: punctuation.section.block.begin.mlf 123 + push: 124 + - meta_scope: meta.error-block.mlf 125 + - match: '\}' 126 + scope: punctuation.section.block.end.mlf 127 + pop: true 128 + - include: comments 129 + - match: '\b[a-zA-Z_][a-zA-Z0-9_]*\b' 130 + scope: constant.other.mlf 131 + - match: ',' 132 + scope: punctuation.separator.mlf 86 133 - match: '\b(namespace|use|as|record|inline|def|type|token|query|procedure|subscription|throws|constrained|error|self)\b' 87 134 scope: keyword.control.mlf 88 135 - match: '\b(main|defs)\b'