the home site for me: also iteration 3 or 4 of my site
at main 6.5 kB view raw
1%YAML 1.2 2--- 3version: 2 4 5file_extensions: 6 - gleam 7 8scope: source.gleam 9 10variables: 11 lower_ident: '[[:lower:]][[:word:]]*' 12 upper_ident: '[[:upper:]][[:word:]]*' 13 14contexts: 15 main: 16 - include: base 17 base: 18 - include: attribute 19 - include: bitstring 20 - include: block 21 - include: comment 22 - include: constant_def 23 - include: function_def 24 - include: keyword 25 - include: function_call 26 - include: record 27 - include: import 28 - include: number 29 - include: operator 30 - include: punctuation 31 - include: string 32 - include: unused_name 33 - include: type_name 34 35 # Attributes (annotations) 36 attribute: 37 - match: ^\s*(@{{lower_ident}})\( 38 captures: 39 1: variable.other.constant.gleam 40 push: 41 - include: arguments 42 - meta_scope: meta.annotation.gleam 43 - match: ^\s*(@{{lower_ident}}) 44 scope: meta.annotation.gleam 45 captures: 46 1: variable.other.constant.gleam 47 48 # Arguments (to a function call, record constructor, or attribute) 49 arguments: 50 - include: bitstring 51 - include: block 52 - include: comment 53 - include: function_def 54 - include: function_call 55 - include: record 56 - include: number 57 - include: operator 58 - include: punctuation 59 - include: string 60 - include: unused_name 61 - include: type_name 62 - match: '\b{{lower_ident}}:' 63 scope: constant.other.gleam 64 - match: \) 65 pop: true 66 67 # Bitstrings 68 bitstring: 69 - match: '<<' 70 scope: punctuation.definition.generic.begin.gleam 71 push: 72 - include: number 73 - include: string 74 - match: \b(bytes|int|float|bits|utf8|utf16|utf32|utf8_codepoint|utf16_codepoint|utf32_codepoint|signed|unsigned|big|little|native|unit|size)\b 75 scope: keyword.other.gleam 76 - match: '>>' 77 scope: punctuation.definition.generic.end.gleam 78 pop: true 79 80 # Blocks 81 block: 82 - match: '{' 83 scope: punctuation.section.block.begin.gleam 84 push: base 85 - match: '}' 86 scope: punctuation.section.block.end.gleam 87 pop: true 88 89 # Comments 90 comment: 91 - match: ///?/? 92 scope: punctuation.definition.comment.line.gleam 93 push: 94 - meta_scope: comment.line.gleam 95 - match: $ 96 pop: true 97 98 # Constant definitions 99 constant_def: 100 - match: \b(const)\s+({{lower_ident}})\b 101 captures: 102 1: keyword.other.gleam 103 2: entity.name.constant.gleam 104 105 # Function calls 106 function_call: 107 - match: \b(?:{{lower_ident}}\.)*({{lower_ident}})\( 108 captures: 109 1: variable.function.gleam 110 push: arguments 111 112 # Function definitions 113 function_def: 114 - match: \b(fn)(?:[[:space:]]+({{lower_ident}}))?[[:space:]]*\( 115 captures: 116 1: storage.type.function.gleam 117 2: entity.name.function.gleam 118 push: function_def_args 119 120 # Function arguments 121 function_def_args: 122 - include: function_def 123 - include: punctuation 124 - include: type_name 125 - include: unused_name 126 - match: -> 127 scope: keyword.operator.gleam 128 - match: \b(?:({{lower_ident}})[[:space:]]+)?({{lower_ident}}:) 129 captures: 130 1: constant.other.gleam 131 2: variable.parameter.gleam 132 - match: \( 133 push: function_def_args 134 - match: \) 135 pop: true 136 137 # Imports 138 import: 139 - match: ^import\b 140 scope: keyword.control.import.gleam 141 push: 142 - match: \bas\b 143 scope: keyword.control.import.gleam 144 - match: \b(?:{{lower_ident}}/)*{{lower_ident}}\b 145 scope: entity.name.namespace.gleam 146 - match: (\.)({) 147 captures: 148 1: punctuation.accessor.gleam 149 2: punctuation.definition.generic.begin.gleam 150 push: 151 - include: punctuation 152 - include: type_name 153 - match: \bas\b 154 scope: keyword.control.import.gleam 155 - match: \btype\b 156 scope: storage.type.gleam 157 - match: '}' 158 scope: punctuation.definition.generic.end.gleam 159 pop: true 160 - match: $ 161 pop: true 162 163 # Keywords 164 keyword: 165 - match: \b(as|assert|case|const|echo|if|let|panic|todo|use)\b 166 scope: keyword.other.gleam 167 - match: \b(opaque|pub)\b 168 scope: storage.modifier.gleam 169 - match: \btype\b 170 scope: storage.type.gleam 171 - match: \bfn\b 172 scope: storage.type.function.gleam 173 # Reserved for future use 174 - match: \b(auto|delegate|derive|else|implement|macro|test)\b 175 scope: invalid.illegal.gleam 176 177 # Numbers 178 number: 179 - match: \b0b[01][01_]*\b 180 scope: constant.numeric.binary.gleam 181 - match: \b0o[0-7][0-7_]*\b 182 scope: constant.numeric.octal.gleam 183 - match: \b[0-9][0-9_]*(\.[0-9_]*(e-?[0-9][0-9_]*)?)?\b 184 scope: constant.numeric.decimal.gleam 185 - match: \b0x[[:xdigit:]][[:xdigit:]_]*\b 186 scope: constant.numeric.hexadecimal.gleam 187 188 # Operators 189 operator: 190 - match: <- 191 scope: keyword.operator.assignment.gleam 192 - match: (\|>|\.\.|<=\.|>=\.|==\.|!=\.|<\.|>\.|<=|>=|==|!=|<|>|<>) 193 scope: keyword.operator.gleam 194 - match: '=' 195 scope: keyword.operator.assignment.gleam 196 - match: -> 197 scope: keyword.operator.gleam 198 - match: (\+\.|\-\.|/\.|\*\.|%\.|\+|\-|/|\*|%) 199 scope: keyword.operator.arithmetic.gleam 200 - match: (&&|\|\|) 201 scope: keyword.operator.logical.gleam 202 - match: \| 203 scope: keyword.operator.gleam 204 205 # Punctuation (separators, accessors) 206 punctuation: 207 - match: \. 208 scope: punctuation.accessor.gleam 209 - match: ',' 210 scope: punctuation.separator.gleam 211 212 # Records (constructors with arguments) 213 record: 214 - match: \b((?:{{lower_ident}}\.)*{{upper_ident}})\( 215 captures: 216 1: entity.name.type.gleam 217 push: arguments 218 219 # Strings 220 string: 221 - match: '"' 222 scope: punctuation.definition.string.begin.gleam 223 push: 224 - meta_scope: string.quoted.double.gleam 225 - match: \\[fnrt"\\] 226 scope: constant.character.escape.gleam 227 - match: \\u\{[[:xdigit:]]{1,6}\} 228 scope: constant.character.escape.gleam 229 - match: \\ 230 scope: invalid.illegal.gleam 231 - match: '"' 232 scope: punctuation.definition.string.end.gleam 233 pop: true 234 235 # Types and constructors 236 type_name: 237 - match: \b(?:{{lower_ident}}\.)*{{upper_ident}}\b 238 scope: entity.name.type.gleam 239 240 # Unused bindings 241 unused_name: 242 - match: \b_{{lower_ident}}\b 243 scope: comment.line.gleam