highlight: Add fish and lua syntax support
2c08b65e6f4876ffb6cf6d609101ef77cb82cb39
1 parent
a0e0175f
crates/diff/src/builtins.rs
+16 -1
| 14 | 14 | /// Theme name used for built-in diff highlighting. |
|
| 15 | 15 | const THEME_NAME: &str = "rustik-catppuccin-mocha"; |
|
| 16 | 16 | /// Built-in syntax theme JSON. |
|
| 17 | 17 | const THEME: &str = include_str!("themes/rustik-catppuccin-mocha.json"); |
|
| 18 | 18 | /// Common syntax grammars loaded by the interactive pager. |
|
| 19 | - | const SYNTAXES: [SyntaxAsset; 16] = [ |
|
| 19 | + | const SYNTAXES: [SyntaxAsset; 18] = [ |
|
| 20 | 20 | SyntaxAsset { |
|
| 21 | 21 | source: syntax::syntaxes::C, |
|
| 22 | 22 | file_types: &["c", "h"], |
|
| 23 | 23 | dependencies: &[], |
|
| 24 | 24 | }, |
| 35 | 35 | syntax::syntaxes::RUBY, |
|
| 36 | 36 | syntax::syntaxes::CSS, |
|
| 37 | 37 | syntax::syntaxes::JAVASCRIPT, |
|
| 38 | 38 | ], |
|
| 39 | 39 | }, |
|
| 40 | + | SyntaxAsset { |
|
| 41 | + | source: syntax::syntaxes::FISH, |
|
| 42 | + | file_types: &["fish"], |
|
| 43 | + | dependencies: &[], |
|
| 44 | + | }, |
|
| 40 | 45 | SyntaxAsset { |
|
| 41 | 46 | source: syntax::syntaxes::GO, |
|
| 42 | 47 | file_types: &["go"], |
|
| 43 | 48 | dependencies: &[], |
|
| 44 | 49 | }, |
| 50 | 55 | SyntaxAsset { |
|
| 51 | 56 | source: syntax::syntaxes::JAVASCRIPT, |
|
| 52 | 57 | file_types: &["js", "cjs", "mjs"], |
|
| 53 | 58 | dependencies: &[], |
|
| 54 | 59 | }, |
|
| 60 | + | SyntaxAsset { |
|
| 61 | + | source: syntax::syntaxes::LUA, |
|
| 62 | + | file_types: &["lua"], |
|
| 63 | + | dependencies: &[], |
|
| 64 | + | }, |
|
| 55 | 65 | SyntaxAsset { |
|
| 56 | 66 | source: syntax::syntaxes::MAKE, |
|
| 57 | 67 | file_types: &["makefile", "mk"], |
|
| 58 | 68 | dependencies: &[], |
|
| 59 | 69 | }, |
| 63 | 73 | dependencies: &[ |
|
| 64 | 74 | syntax::syntaxes::YAML, |
|
| 65 | 75 | syntax::syntaxes::HTML, |
|
| 66 | 76 | syntax::syntaxes::CSS, |
|
| 67 | 77 | syntax::syntaxes::JAVASCRIPT, |
|
| 78 | + | syntax::syntaxes::LUA, |
|
| 68 | 79 | ], |
|
| 69 | 80 | }, |
|
| 70 | 81 | SyntaxAsset { |
|
| 71 | 82 | source: syntax::syntaxes::PYTHON, |
|
| 72 | 83 | file_types: &["py", "pyw"], |
| 247 | 258 | "app.js", |
|
| 248 | 259 | "server.mjs", |
|
| 249 | 260 | "Makefile", |
|
| 250 | 261 | "rules.mk", |
|
| 251 | 262 | "index.html.erb", |
|
| 263 | + | "config.fish", |
|
| 264 | + | "init.lua", |
|
| 252 | 265 | "script.py", |
|
| 253 | 266 | "task.rb", |
|
| 254 | 267 | "build.sh", |
|
| 255 | 268 | "Cargo.toml", |
|
| 256 | 269 | "schema.sql", |
| 270 | 283 | for (head, source) in [ |
|
| 271 | 284 | ("#!/usr/bin/env ruby3.3", syntax::syntaxes::RUBY), |
|
| 272 | 285 | ("#!/usr/bin/env python3.11", syntax::syntaxes::PYTHON), |
|
| 273 | 286 | ("#!/bin/sh", syntax::syntaxes::SHELL), |
|
| 274 | 287 | ("#!/usr/bin/env -S bash -e", syntax::syntaxes::SHELL), |
|
| 288 | + | ("#!/usr/bin/env fish", syntax::syntaxes::FISH), |
|
| 275 | 289 | ] { |
|
| 276 | 290 | assert!( |
|
| 277 | 291 | SYNTAXES.iter().any(|syntax| syntax.source == source |
|
| 278 | 292 | && syntax.head_grammar(head).unwrap().is_some()), |
|
| 279 | 293 | "no built-in syntax matched {head}" |
| 285 | 299 | fn scripting_assets_highlight_extensionless_full_source_shebangs() { |
|
| 286 | 300 | for (head, line, token) in [ |
|
| 287 | 301 | ("#!/usr/bin/env ruby", "if true", "if"), |
|
| 288 | 302 | ("#!/usr/bin/env python3", "if True:", "if"), |
|
| 289 | 303 | ("#!/bin/sh", "if true; then", "if"), |
|
| 304 | + | ("#!/usr/bin/env fish", "if test -n \"$argv\"", "if"), |
|
| 290 | 305 | ] { |
|
| 291 | 306 | let result = highlight_extensionless_full_source(head, line); |
|
| 292 | 307 | ||
| 293 | 308 | assert!( |
|
| 294 | 309 | result |
script\n\
+0 -0
{path}\n\
+0 -0
crates/highlight/src/syntaxes.rs
+6 -0
| 20 | 20 | pub const HTML: &str = include_str!("../syntaxes/html.json"); |
|
| 21 | 21 | ||
| 22 | 22 | /// JavaScript grammar source. |
|
| 23 | 23 | pub const JAVASCRIPT: &str = include_str!("../syntaxes/javascript.json"); |
|
| 24 | 24 | ||
| 25 | + | /// Fish grammar source. |
|
| 26 | + | pub const FISH: &str = include_str!("../syntaxes/fish.json"); |
|
| 27 | + | ||
| 28 | + | /// Lua grammar source. |
|
| 29 | + | pub const LUA: &str = include_str!("../syntaxes/lua.json"); |
|
| 30 | + | ||
| 25 | 31 | /// Makefile grammar source. |
|
| 26 | 32 | pub const MAKE: &str = include_str!("../syntaxes/make.json"); |
|
| 27 | 33 | ||
| 28 | 34 | /// Markdown grammar source. |
|
| 29 | 35 | pub const MARKDOWN: &str = include_str!("../syntaxes/markdown.json"); |
crates/highlight/syntaxes/LICENSE
+4 -0
| 1 | 1 | Copyright (c) 2020 Dustin Pomerleau |
|
| 2 | 2 | Copyright (c) Microsoft Corporation |
|
| 3 | 3 | Copyright (c) 2021 Pine Wu |
|
| 4 | 4 | Copyright (c) 2023 Anthony Fu |
|
| 5 | + | Copyright (c) 2022 最萌小汐 |
|
| 6 | + | Copyright (c) 2019 Brian Malehorn |
|
| 7 | + | Copyright (c) 2018 Aaron Sky |
|
| 8 | + | Copyright (c) 2017 Sebastian Wiesner |
|
| 5 | 9 | ||
| 6 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy |
|
| 7 | 11 | of this software and associated documentation files (the "Software"), to deal |
|
| 8 | 12 | in the Software without restriction, including without limitation the rights |
|
| 9 | 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
crates/highlight/syntaxes/fish.json
added
+379 -0
| 1 | + | { |
|
| 2 | + | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", |
|
| 3 | + | "firstLineMatch": "^#!.*\\bfish\\b", |
|
| 4 | + | "keyEquivalent": "^~F", |
|
| 5 | + | "name": "fish", |
|
| 6 | + | "patterns": [ |
|
| 7 | + | { "include": "#string-double" }, |
|
| 8 | + | { "include": "#string-single" }, |
|
| 9 | + | { "include": "#comment" }, |
|
| 10 | + | { "include": "#subshell-bare" }, |
|
| 11 | + | { "include": "#subshell" }, |
|
| 12 | + | { "include": "#command" }, |
|
| 13 | + | { "include": "#keywords" }, |
|
| 14 | + | { "include": "#io-redirection" }, |
|
| 15 | + | { "include": "#operators" }, |
|
| 16 | + | { "include": "#options" }, |
|
| 17 | + | { "include": "#variable" }, |
|
| 18 | + | { "include": "#escape" } |
|
| 19 | + | ], |
|
| 20 | + | "repository": { |
|
| 21 | + | "string-double": { |
|
| 22 | + | "begin": "\"", |
|
| 23 | + | "beginCaptures": { |
|
| 24 | + | "0": { "name": "punctuation.definition.string.begin.fish" } |
|
| 25 | + | }, |
|
| 26 | + | "comment": "Double quoted string", |
|
| 27 | + | "end": "\"", |
|
| 28 | + | "endCaptures": { |
|
| 29 | + | "0": { "name": "punctuation.definition.string.end.fish" } |
|
| 30 | + | }, |
|
| 31 | + | "name": "string.quoted.double.fish", |
|
| 32 | + | "patterns": [ |
|
| 33 | + | { "include": "#subshell" }, |
|
| 34 | + | { "include": "#variable-string-double" }, |
|
| 35 | + | { |
|
| 36 | + | "comment": "https://fishshell.com/docs/current/#quotes", |
|
| 37 | + | "match": "\\\\(\\\"|\\$|$|\\\\)", |
|
| 38 | + | "name": "constant.character.escape.fish" |
|
| 39 | + | } |
|
| 40 | + | ] |
|
| 41 | + | }, |
|
| 42 | + | "string-single": { |
|
| 43 | + | "begin": "'", |
|
| 44 | + | "beginCaptures": { |
|
| 45 | + | "0": { "name": "punctuation.definition.string.begin.fish" } |
|
| 46 | + | }, |
|
| 47 | + | "comment": "Single quoted string", |
|
| 48 | + | "end": "'", |
|
| 49 | + | "endCaptures": { |
|
| 50 | + | "0": { "name": "punctuation.definition.string.end.fish" } |
|
| 51 | + | }, |
|
| 52 | + | "name": "string.quoted.single.fish", |
|
| 53 | + | "patterns": [ |
|
| 54 | + | { |
|
| 55 | + | "comment": "https://fishshell.com/docs/current/#quotes", |
|
| 56 | + | "match": "\\\\('|`|\\\\)", |
|
| 57 | + | "name": "constant.character.escape.fish" |
|
| 58 | + | } |
|
| 59 | + | ] |
|
| 60 | + | }, |
|
| 61 | + | "comment": { |
|
| 62 | + | "captures": { "1": { "name": "punctuation.definition.comment.fish" } }, |
|
| 63 | + | "comment": "line comment", |
|
| 64 | + | "match": "(?<!\\$)(#)(?!\\{).*$\\n?", |
|
| 65 | + | "name": "comment.line.number-sign.fish" |
|
| 66 | + | }, |
|
| 67 | + | "command": { |
|
| 68 | + | "comment": "name of command, either a function or a binary", |
|
| 69 | + | "match": "(^\\s*|&&\\s*|(\\|)\\s*|\\(\\s*|[;]\\s*|\\b(if|while)\\b\\s+)(?!(?<!\\.)\\b(function|while|if|else|switch|case|for|in|begin|end|continue|break|return|source|exit|wait|and|or|not)\\b(?![?!]))([a-zA-Z_\\-0-9\\[\\].]+)", |
|
| 70 | + | "captures": { |
|
| 71 | + | "2": { "name": "keyword.operator.pipe.fish" }, |
|
| 72 | + | "3": { "name": "keyword.control.fish" }, |
|
| 73 | + | "5": { "name": "support.function.command.fish" } |
|
| 74 | + | } |
|
| 75 | + | }, |
|
| 76 | + | "command-subshell": { |
|
| 77 | + | "comment": "name of command in subshell context", |
|
| 78 | + | "match": "(\\G\\s*|&&\\s*|(\\|)\\s*|\\(\\s*|[;]\\s*|\\b(if|while)\\b\\s+)(?!(?<!\\.)\\b(function|while|if|else|switch|case|for|in|begin|end|continue|break|return|source|exit|wait|and|or|not)\\b(?![?!]))([a-zA-Z_\\-0-9\\[\\].]+)", |
|
| 79 | + | "captures": { |
|
| 80 | + | "2": { "name": "keyword.operator.pipe.fish" }, |
|
| 81 | + | "3": { "name": "keyword.control.fish" }, |
|
| 82 | + | "5": { "name": "support.function.command.fish" } |
|
| 83 | + | } |
|
| 84 | + | }, |
|
| 85 | + | "keywords": { |
|
| 86 | + | "patterns": [ |
|
| 87 | + | { |
|
| 88 | + | "comment": "command-expecting keywords (allow subsequent keywords)", |
|
| 89 | + | "match": "(^\\s*|&&\\s*|(?<=\\|)\\s*|\\(\\s*|[;]\\s*|(?<=\\bwhile\\b)\\s+|(?<=\\bif\\b)\\s+|(?<=\\band\\b)\\s+|(?<=\\bor\\b)\\s+|(?<=\\bnot\\b)\\s+)(?<!\\.)\\b(while|if|and|or|not)\\b(?![?!])", |
|
| 90 | + | "captures": { "2": { "name": "keyword.control.fish" } } |
|
| 91 | + | }, |
|
| 92 | + | { |
|
| 93 | + | "comment": "regular keywords (command position only)", |
|
| 94 | + | "match": "(^\\s*|&&\\s*|(?<=\\|)\\s*|\\(\\s*|[;]\\s*)(?<!\\.)\\b(function|else|switch|case|for|begin|end|continue|break|return|source|exit|wait)\\b(?![?!])", |
|
| 95 | + | "captures": { "2": { "name": "keyword.control.fish" } } |
|
| 96 | + | }, |
|
| 97 | + | { |
|
| 98 | + | "comment": "in keyword (special case for 'for' loops)", |
|
| 99 | + | "match": "\\b(in)\\b(?![?!])", |
|
| 100 | + | "name": "keyword.control.fish" |
|
| 101 | + | } |
|
| 102 | + | ] |
|
| 103 | + | }, |
|
| 104 | + | "keywords-subshell": { |
|
| 105 | + | "patterns": [ |
|
| 106 | + | { |
|
| 107 | + | "comment": "command-expecting keywords in subshell (allow subsequent keywords)", |
|
| 108 | + | "match": "(\\G\\s*|&&\\s*|(?<=\\|)\\s*|\\(\\s*|[;]\\s*|(?<=\\bwhile\\b)\\s+|(?<=\\bif\\b)\\s+|(?<=\\band\\b)\\s+|(?<=\\bor\\b)\\s+|(?<=\\bnot\\b)\\s+)(?<!\\.)\\b(while|if|and|or|not)\\b(?![?!])", |
|
| 109 | + | "captures": { "2": { "name": "keyword.control.fish" } } |
|
| 110 | + | }, |
|
| 111 | + | { |
|
| 112 | + | "comment": "regular keywords in subshell (command position only)", |
|
| 113 | + | "match": "(\\G\\s*|&&\\s*|(?<=\\|)\\s*|\\(\\s*|[;]\\s*)(?<!\\.)\\b(function|else|switch|case|for|begin|end|continue|break|return|source|exit|wait)\\b(?![?!])", |
|
| 114 | + | "captures": { "2": { "name": "keyword.control.fish" } } |
|
| 115 | + | }, |
|
| 116 | + | { |
|
| 117 | + | "comment": "in keyword (special case for 'for' loops)", |
|
| 118 | + | "match": "\\b(in)\\b(?![?!])", |
|
| 119 | + | "name": "keyword.control.fish" |
|
| 120 | + | } |
|
| 121 | + | ] |
|
| 122 | + | }, |
|
| 123 | + | "io-redirection": { |
|
| 124 | + | "patterns": [ |
|
| 125 | + | { |
|
| 126 | + | "comment": "IO Redirection with simple target", |
|
| 127 | + | "match": "(<|(?:>|\\^|>>|\\^\\^)(?:&[012\\-])?|[012](?:<|>|>>)(?:&[012\\-])?)\\s*(?!\\()([a-zA-Z0-9_./\\-]+)", |
|
| 128 | + | "captures": { |
|
| 129 | + | "1": { "name": "keyword.operator.redirect.fish" }, |
|
| 130 | + | "2": { "name": "keyword.operator.redirect.target.fish" } |
|
| 131 | + | } |
|
| 132 | + | }, |
|
| 133 | + | { |
|
| 134 | + | "comment": "IO Redirection without target", |
|
| 135 | + | "match": "(?x:\n<|(>|\\^|>>|\\^\\^)(&[012\\-])?|[012](<|>|>>)(&[012\\-])?)", |
|
| 136 | + | "name": "keyword.operator.redirect.fish" |
|
| 137 | + | } |
|
| 138 | + | ] |
|
| 139 | + | }, |
|
| 140 | + | "operators": { |
|
| 141 | + | "patterns": [ |
|
| 142 | + | { |
|
| 143 | + | "match": "&", |
|
| 144 | + | "name": "keyword.operator.background.fish" |
|
| 145 | + | }, |
|
| 146 | + | { |
|
| 147 | + | "match": "\\*\\*|\\*|\\?", |
|
| 148 | + | "name": "keyword.operator.glob.fish" |
|
| 149 | + | } |
|
| 150 | + | ] |
|
| 151 | + | }, |
|
| 152 | + | "options": { |
|
| 153 | + | "comment": "command short/long options", |
|
| 154 | + | "match": "\\s(-{1,2}[a-zA-Z_\\-0-9]+|-\\w)\\b", |
|
| 155 | + | "captures": { "1": { "name": "source.option.fish" } } |
|
| 156 | + | }, |
|
| 157 | + | "subshell": { |
|
| 158 | + | "comment": "Command substitution $(command)", |
|
| 159 | + | "begin": "\\$\\(", |
|
| 160 | + | "beginCaptures": { |
|
| 161 | + | "0": { "name": "punctuation.definition.subshell.begin.fish" } |
|
| 162 | + | }, |
|
| 163 | + | "end": "(?<!\\\\)((\\\\\\\\)*)(\\))", |
|
| 164 | + | "endCaptures": { |
|
| 165 | + | "1": { "name": "constant.character.escape.string.fish" }, |
|
| 166 | + | "3": { "name": "punctuation.definition.subshell.end.fish" } |
|
| 167 | + | }, |
|
| 168 | + | "name": "meta.embedded.subshell.fish", |
|
| 169 | + | "patterns": [ |
|
| 170 | + | { "include": "#string-double" }, |
|
| 171 | + | { "include": "#string-single" }, |
|
| 172 | + | { "include": "#comment" }, |
|
| 173 | + | { "include": "#keywords-subshell" }, |
|
| 174 | + | { "include": "#command-subshell" }, |
|
| 175 | + | { "include": "#io-redirection" }, |
|
| 176 | + | { "include": "#operators" }, |
|
| 177 | + | { "include": "#options" }, |
|
| 178 | + | { "include": "#subshell" }, |
|
| 179 | + | { "include": "#variable" }, |
|
| 180 | + | { "include": "#escape" } |
|
| 181 | + | ] |
|
| 182 | + | }, |
|
| 183 | + | "slice": { |
|
| 184 | + | "comment": "List variable slice $variable[...] outside of strings", |
|
| 185 | + | "begin": "\\[", |
|
| 186 | + | "beginCaptures": { |
|
| 187 | + | "0": { "name": "punctuation.definition.slice.begin.fish" } |
|
| 188 | + | }, |
|
| 189 | + | "end": "(?<!\\\\)((\\\\\\\\)*)(\\])", |
|
| 190 | + | "endCaptures": { |
|
| 191 | + | "1": { "name": "constant.character.escape.string.fish" }, |
|
| 192 | + | "3": { "name": "punctuation.definition.slice.end.fish" } |
|
| 193 | + | }, |
|
| 194 | + | "name": "meta.embedded.slice.fish variable.interpolation.fish", |
|
| 195 | + | "patterns": [ |
|
| 196 | + | { "include": "#string-double" }, |
|
| 197 | + | { "include": "#string-single" }, |
|
| 198 | + | { "include": "#subshell-bare" }, |
|
| 199 | + | { "include": "#subshell" }, |
|
| 200 | + | { "include": "#variable" }, |
|
| 201 | + | { "include": "#escape" } |
|
| 202 | + | ] |
|
| 203 | + | }, |
|
| 204 | + | "slice-string-double": { |
|
| 205 | + | "comment": "List variable slice $variable[...] inside double-quoted strings", |
|
| 206 | + | "begin": "\\[", |
|
| 207 | + | "beginCaptures": { |
|
| 208 | + | "0": { "name": "punctuation.definition.slice.begin.fish" } |
|
| 209 | + | }, |
|
| 210 | + | "end": "(?<!\\\\)((\\\\\\\\)*)(\\])", |
|
| 211 | + | "endCaptures": { |
|
| 212 | + | "1": { "name": "constant.character.escape.string.fish" }, |
|
| 213 | + | "3": { "name": "punctuation.definition.slice.end.fish" } |
|
| 214 | + | }, |
|
| 215 | + | "name": "meta.embedded.slice.fish variable.interpolation.string.fish", |
|
| 216 | + | "patterns": [ |
|
| 217 | + | { "include": "#subshell" }, |
|
| 218 | + | { "include": "#variable" }, |
|
| 219 | + | { |
|
| 220 | + | "comment": "https://fishshell.com/docs/current/#quotes", |
|
| 221 | + | "match": "\\\\(\\\"|\\$|$|\\\\)", |
|
| 222 | + | "name": "constant.character.escape.fish" |
|
| 223 | + | } |
|
| 224 | + | ] |
|
| 225 | + | }, |
|
| 226 | + | "subshell-bare": { |
|
| 227 | + | "comment": "Bare parentheses command substitution (command) - valid in fish 3.4+", |
|
| 228 | + | "begin": "\\(", |
|
| 229 | + | "beginCaptures": { |
|
| 230 | + | "0": { "name": "punctuation.definition.subshell.begin.fish" } |
|
| 231 | + | }, |
|
| 232 | + | "end": "(?<!\\\\)((\\\\\\\\)*)(\\))", |
|
| 233 | + | "endCaptures": { |
|
| 234 | + | "1": { "name": "constant.character.escape.string.fish" }, |
|
| 235 | + | "3": { "name": "punctuation.definition.subshell.end.fish" } |
|
| 236 | + | }, |
|
| 237 | + | "name": "meta.embedded.subshell.fish", |
|
| 238 | + | "patterns": [ |
|
| 239 | + | { "include": "#string-double" }, |
|
| 240 | + | { "include": "#string-single" }, |
|
| 241 | + | { "include": "#comment" }, |
|
| 242 | + | { "include": "#keywords-subshell" }, |
|
| 243 | + | { "include": "#command-subshell" }, |
|
| 244 | + | { "include": "#io-redirection" }, |
|
| 245 | + | { "include": "#operators" }, |
|
| 246 | + | { "include": "#options" }, |
|
| 247 | + | { "include": "#subshell-bare" }, |
|
| 248 | + | { "include": "#subshell" }, |
|
| 249 | + | { "include": "#variable" }, |
|
| 250 | + | { "include": "#escape" } |
|
| 251 | + | ] |
|
| 252 | + | }, |
|
| 253 | + | "escape": { |
|
| 254 | + | "patterns": [ |
|
| 255 | + | { |
|
| 256 | + | "comment": "single character character escape sequences", |
|
| 257 | + | "match": "\\\\[abefnrtv $*?~#(){}\\[\\]<>^&|;\"']", |
|
| 258 | + | "name": "constant.character.escape.string.fish" |
|
| 259 | + | }, |
|
| 260 | + | { |
|
| 261 | + | "comment": "escapes the ascii character with the specified value (hexadecimal)", |
|
| 262 | + | "match": "\\\\x[0-9a-fA-F]{1,2}", |
|
| 263 | + | "name": "constant.character.escape.hex-ascii.fish" |
|
| 264 | + | }, |
|
| 265 | + | { |
|
| 266 | + | "comment": "escapes a byte of data with the specified value (hexadecimal). If you are using mutibyte encoding, this can be used to enter invalid strings. Only use this if you know what are doing.", |
|
| 267 | + | "match": "\\\\X[0-9a-fA-F]{1,2}", |
|
| 268 | + | "name": "constant.character.escape.hex-byte.fish" |
|
| 269 | + | }, |
|
| 270 | + | { |
|
| 271 | + | "comment": "escapes the ascii character with the specified value (octal)", |
|
| 272 | + | "match": "\\\\[0-7]{1,3}", |
|
| 273 | + | "name": "constant.character.escape.octal.fish" |
|
| 274 | + | }, |
|
| 275 | + | { |
|
| 276 | + | "comment": "escapes the 16-bit unicode character with the specified value (hexadecimal)", |
|
| 277 | + | "match": "\\\\u[0-9a-fA-F]{1,4}", |
|
| 278 | + | "name": "constant.character.escape.unicode-16-bit.fish" |
|
| 279 | + | }, |
|
| 280 | + | { |
|
| 281 | + | "comment": "escapes the 32-bit unicode character with the specified value (hexadecimal)", |
|
| 282 | + | "match": "\\\\U[0-9a-fA-F]{1,8}", |
|
| 283 | + | "name": "constant.character.escape.unicode-32-bit.fish" |
|
| 284 | + | }, |
|
| 285 | + | { |
|
| 286 | + | "comment": "escapes the control sequence generated by pressing the control key and the specified letter", |
|
| 287 | + | "match": "\\\\c[a-zA-Z]", |
|
| 288 | + | "name": "constant.character.escape.control.fish" |
|
| 289 | + | } |
|
| 290 | + | ] |
|
| 291 | + | }, |
|
| 292 | + | "variable": { |
|
| 293 | + | "patterns": [ |
|
| 294 | + | { |
|
| 295 | + | "comment": "Built-in variables with slice", |
|
| 296 | + | "begin": "(\\$)(argv|CMD_DURATION|COLUMNS|fish_bind_mode|fish_color_autosuggestion|fish_color_cancel|fish_color_command|fish_color_comment|fish_color_cwd|fish_color_cwd_root|fish_color_end|fish_color_error|fish_color_escape|fish_color_hg_added|fish_color_hg_clean|fish_color_hg_copied|fish_color_hg_deleted|fish_color_hg_dirty|fish_color_hg_modified|fish_color_hg_renamed|fish_color_hg_unmerged|fish_color_hg_untracked|fish_color_history_current|fish_color_host|fish_color_host_remote|fish_color_match|fish_color_normal|fish_color_operator|fish_color_param|fish_color_quote|fish_color_redirection|fish_color_search_match|fish_color_selection|fish_color_status|fish_color_user|fish_color_valid_path|fish_complete_path|fish_function_path|fish_greeting|fish_key_bindings|fish_pager_color_completion|fish_pager_color_description|fish_pager_color_prefix|fish_pager_color_progress|fish_pid|fish_prompt_hg_status_added|fish_prompt_hg_status_copied|fish_prompt_hg_status_deleted|fish_prompt_hg_status_modified|fish_prompt_hg_status_order|fish_prompt_hg_status_unmerged|fish_prompt_hg_status_untracked|FISH_VERSION|history|hostname|IFS|LINES|pipestatus|status|umask|version)\\b(?=\\[)", |
|
| 297 | + | "beginCaptures": { |
|
| 298 | + | "1": { "name": "punctuation.definition.variable.fish" }, |
|
| 299 | + | "2": { "name": "variable.language.fish" } |
|
| 300 | + | }, |
|
| 301 | + | "end": "(?<=\\])", |
|
| 302 | + | "name": "variable.language.fish", |
|
| 303 | + | "patterns": [{ "include": "#slice" }] |
|
| 304 | + | }, |
|
| 305 | + | { |
|
| 306 | + | "comment": "Built-in variables without slice", |
|
| 307 | + | "captures": { |
|
| 308 | + | "1": { "name": "punctuation.definition.variable.fish" } |
|
| 309 | + | }, |
|
| 310 | + | "match": "(\\$)(argv|CMD_DURATION|COLUMNS|fish_bind_mode|fish_color_autosuggestion|fish_color_cancel|fish_color_command|fish_color_comment|fish_color_cwd|fish_color_cwd_root|fish_color_end|fish_color_error|fish_color_escape|fish_color_hg_added|fish_color_hg_clean|fish_color_hg_copied|fish_color_hg_deleted|fish_color_hg_dirty|fish_color_hg_modified|fish_color_hg_renamed|fish_color_hg_unmerged|fish_color_hg_untracked|fish_color_history_current|fish_color_host|fish_color_host_remote|fish_color_match|fish_color_normal|fish_color_operator|fish_color_param|fish_color_quote|fish_color_redirection|fish_color_search_match|fish_color_selection|fish_color_status|fish_color_user|fish_color_valid_path|fish_complete_path|fish_function_path|fish_greeting|fish_key_bindings|fish_pager_color_completion|fish_pager_color_description|fish_pager_color_prefix|fish_pager_color_progress|fish_pid|fish_prompt_hg_status_added|fish_prompt_hg_status_copied|fish_prompt_hg_status_deleted|fish_prompt_hg_status_modified|fish_prompt_hg_status_order|fish_prompt_hg_status_unmerged|fish_prompt_hg_status_untracked|FISH_VERSION|history|hostname|IFS|LINES|pipestatus|status|umask|version)\\b", |
|
| 311 | + | "name": "variable.language.fish" |
|
| 312 | + | }, |
|
| 313 | + | { |
|
| 314 | + | "comment": "Normal variables with slice", |
|
| 315 | + | "begin": "(\\$)([a-zA-Z_][a-zA-Z0-9_]*)(?=\\[)", |
|
| 316 | + | "beginCaptures": { |
|
| 317 | + | "1": { "name": "punctuation.definition.variable.fish" }, |
|
| 318 | + | "2": { "name": "variable.other.normal.fish" } |
|
| 319 | + | }, |
|
| 320 | + | "end": "(?<=\\])", |
|
| 321 | + | "name": "variable.other.normal.fish", |
|
| 322 | + | "patterns": [{ "include": "#slice" }] |
|
| 323 | + | }, |
|
| 324 | + | { |
|
| 325 | + | "comment": "Normal variables without slice", |
|
| 326 | + | "captures": { |
|
| 327 | + | "1": { "name": "punctuation.definition.variable.fish" } |
|
| 328 | + | }, |
|
| 329 | + | "match": "(\\$)[a-zA-Z_][a-zA-Z0-9_]*", |
|
| 330 | + | "name": "variable.other.normal.fish" |
|
| 331 | + | } |
|
| 332 | + | ] |
|
| 333 | + | }, |
|
| 334 | + | "variable-string-double": { |
|
| 335 | + | "patterns": [ |
|
| 336 | + | { |
|
| 337 | + | "comment": "Built-in variables with slice inside double-quoted strings", |
|
| 338 | + | "begin": "(\\$)(argv|CMD_DURATION|COLUMNS|fish_bind_mode|fish_color_autosuggestion|fish_color_cancel|fish_color_command|fish_color_comment|fish_color_cwd|fish_color_cwd_root|fish_color_end|fish_color_error|fish_color_escape|fish_color_hg_added|fish_color_hg_clean|fish_color_hg_copied|fish_color_hg_deleted|fish_color_hg_dirty|fish_color_hg_modified|fish_color_hg_renamed|fish_color_hg_unmerged|fish_color_hg_untracked|fish_color_history_current|fish_color_host|fish_color_host_remote|fish_color_match|fish_color_normal|fish_color_operator|fish_color_param|fish_color_quote|fish_color_redirection|fish_color_search_match|fish_color_selection|fish_color_status|fish_color_user|fish_color_valid_path|fish_complete_path|fish_function_path|fish_greeting|fish_key_bindings|fish_pager_color_completion|fish_pager_color_description|fish_pager_color_prefix|fish_pager_color_progress|fish_pid|fish_prompt_hg_status_added|fish_prompt_hg_status_copied|fish_prompt_hg_status_deleted|fish_prompt_hg_status_modified|fish_prompt_hg_status_order|fish_prompt_hg_status_unmerged|fish_prompt_hg_status_untracked|FISH_VERSION|history|hostname|IFS|LINES|pipestatus|status|umask|version)\\b(?=\\[)", |
|
| 339 | + | "beginCaptures": { |
|
| 340 | + | "1": { "name": "punctuation.definition.variable.fish" }, |
|
| 341 | + | "2": { "name": "variable.language.fish" } |
|
| 342 | + | }, |
|
| 343 | + | "end": "(?<=\\])", |
|
| 344 | + | "name": "variable.language.fish", |
|
| 345 | + | "patterns": [{ "include": "#slice-string-double" }] |
|
| 346 | + | }, |
|
| 347 | + | { |
|
| 348 | + | "comment": "Built-in variables without slice inside double-quoted strings", |
|
| 349 | + | "captures": { |
|
| 350 | + | "1": { "name": "punctuation.definition.variable.fish" } |
|
| 351 | + | }, |
|
| 352 | + | "match": "(\\$)(argv|CMD_DURATION|COLUMNS|fish_bind_mode|fish_color_autosuggestion|fish_color_cancel|fish_color_command|fish_color_comment|fish_color_cwd|fish_color_cwd_root|fish_color_end|fish_color_error|fish_color_escape|fish_color_hg_added|fish_color_hg_clean|fish_color_hg_copied|fish_color_hg_deleted|fish_color_hg_dirty|fish_color_hg_modified|fish_color_hg_renamed|fish_color_hg_unmerged|fish_color_hg_untracked|fish_color_history_current|fish_color_host|fish_color_host_remote|fish_color_match|fish_color_normal|fish_color_operator|fish_color_param|fish_color_quote|fish_color_redirection|fish_color_search_match|fish_color_selection|fish_color_status|fish_color_user|fish_color_valid_path|fish_complete_path|fish_function_path|fish_greeting|fish_key_bindings|fish_pager_color_completion|fish_pager_color_description|fish_pager_color_prefix|fish_pager_color_progress|fish_pid|fish_prompt_hg_status_added|fish_prompt_hg_status_copied|fish_prompt_hg_status_deleted|fish_prompt_hg_status_modified|fish_prompt_hg_status_order|fish_prompt_hg_status_unmerged|fish_prompt_hg_status_untracked|FISH_VERSION|history|hostname|IFS|LINES|pipestatus|status|umask|version)\\b", |
|
| 353 | + | "name": "variable.language.fish" |
|
| 354 | + | }, |
|
| 355 | + | { |
|
| 356 | + | "comment": "Normal variables with slice inside double-quoted strings", |
|
| 357 | + | "begin": "(\\$)([a-zA-Z_][a-zA-Z0-9_]*)(?=\\[)", |
|
| 358 | + | "beginCaptures": { |
|
| 359 | + | "1": { "name": "punctuation.definition.variable.fish" }, |
|
| 360 | + | "2": { "name": "variable.other.normal.fish" } |
|
| 361 | + | }, |
|
| 362 | + | "end": "(?<=\\])", |
|
| 363 | + | "name": "variable.other.normal.fish", |
|
| 364 | + | "patterns": [{ "include": "#slice-string-double" }] |
|
| 365 | + | }, |
|
| 366 | + | { |
|
| 367 | + | "comment": "Normal variables without slice inside double-quoted strings", |
|
| 368 | + | "captures": { |
|
| 369 | + | "1": { "name": "punctuation.definition.variable.fish" } |
|
| 370 | + | }, |
|
| 371 | + | "match": "(\\$)[a-zA-Z_][a-zA-Z0-9_]*", |
|
| 372 | + | "name": "variable.other.normal.fish" |
|
| 373 | + | } |
|
| 374 | + | ] |
|
| 375 | + | } |
|
| 376 | + | }, |
|
| 377 | + | "scopeName": "source.fish", |
|
| 378 | + | "uuid": "9CA6DB6F-A16F-4836-A058-617C7378775D" |
|
| 379 | + | } |
crates/highlight/syntaxes/lua.json
added
+984 -0
| 1 | + | { |
|
| 2 | + | "information_for_contributors": [ |
|
| 3 | + | "This file has been converted from https://github.com/sumneko/lua.tmbundle/blob/master/Syntaxes/Lua.plist", |
|
| 4 | + | "If you want to provide a fix or improvement, please create a pull request against the original repository.", |
|
| 5 | + | "Once accepted there, we are happy to receive an update request." |
|
| 6 | + | ], |
|
| 7 | + | "version": "https://github.com/sumneko/lua.tmbundle/commit/b295d83bf0e91b5d3a69eb097f9ed351623b95be", |
|
| 8 | + | "name": "Lua", |
|
| 9 | + | "scopeName": "source.lua", |
|
| 10 | + | "patterns": [ |
|
| 11 | + | { |
|
| 12 | + | "begin": "\\b(?:(local)\\s+)?(function)\\b(?![,:])", |
|
| 13 | + | "beginCaptures": { |
|
| 14 | + | "1": { |
|
| 15 | + | "name": "keyword.local.lua" |
|
| 16 | + | }, |
|
| 17 | + | "2": { |
|
| 18 | + | "name": "keyword.control.lua" |
|
| 19 | + | } |
|
| 20 | + | }, |
|
| 21 | + | "end": "(?<=[\\)\\-{}\\[\\]\"'])", |
|
| 22 | + | "name": "meta.function.lua", |
|
| 23 | + | "patterns": [ |
|
| 24 | + | { |
|
| 25 | + | "include": "#comment" |
|
| 26 | + | }, |
|
| 27 | + | { |
|
| 28 | + | "begin": "(\\()", |
|
| 29 | + | "beginCaptures": { |
|
| 30 | + | "1": { |
|
| 31 | + | "name": "punctuation.definition.parameters.begin.lua" |
|
| 32 | + | } |
|
| 33 | + | }, |
|
| 34 | + | "end": "(\\))|(?=[\\-{}\\[\\]\"'])|(?<!\\.)\\.(?!\\.)", |
|
| 35 | + | "endCaptures": { |
|
| 36 | + | "1": { |
|
| 37 | + | "name": "punctuation.definition.parameters.finish.lua" |
|
| 38 | + | } |
|
| 39 | + | }, |
|
| 40 | + | "name": "meta.parameter.lua", |
|
| 41 | + | "patterns": [ |
|
| 42 | + | { |
|
| 43 | + | "include": "#comment" |
|
| 44 | + | }, |
|
| 45 | + | { |
|
| 46 | + | "match": "(\\.{3})\\s*([a-zA-Z_][a-zA-Z0-9_]*)", |
|
| 47 | + | "captures": { |
|
| 48 | + | "1": { |
|
| 49 | + | "name": "constant.language.lua" |
|
| 50 | + | }, |
|
| 51 | + | "2": { |
|
| 52 | + | "name": "variable.parameter.function.lua" |
|
| 53 | + | } |
|
| 54 | + | } |
|
| 55 | + | }, |
|
| 56 | + | { |
|
| 57 | + | "match": "[a-zA-Z_][a-zA-Z0-9_]*", |
|
| 58 | + | "name": "variable.parameter.function.lua" |
|
| 59 | + | }, |
|
| 60 | + | { |
|
| 61 | + | "match": ",", |
|
| 62 | + | "name": "punctuation.separator.arguments.lua" |
|
| 63 | + | }, |
|
| 64 | + | { |
|
| 65 | + | "begin": ":", |
|
| 66 | + | "beginCaptures": { |
|
| 67 | + | "0": { |
|
| 68 | + | "name": "punctuation.separator.arguments.lua" |
|
| 69 | + | } |
|
| 70 | + | }, |
|
| 71 | + | "end": "(?=[\\),])", |
|
| 72 | + | "patterns": [ |
|
| 73 | + | { |
|
| 74 | + | "include": "#emmydoc.type" |
|
| 75 | + | } |
|
| 76 | + | ] |
|
| 77 | + | } |
|
| 78 | + | ] |
|
| 79 | + | }, |
|
| 80 | + | { |
|
| 81 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b\\s*(?=:)", |
|
| 82 | + | "name": "entity.name.class.lua" |
|
| 83 | + | }, |
|
| 84 | + | { |
|
| 85 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b", |
|
| 86 | + | "name": "entity.name.function.lua" |
|
| 87 | + | } |
|
| 88 | + | ] |
|
| 89 | + | }, |
|
| 90 | + | { |
|
| 91 | + | "match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(\\.[0-9A-Fa-f]*)?([eE]-?\\d*)?([pP][-+]\\d+)?", |
|
| 92 | + | "name": "constant.numeric.float.hexadecimal.lua" |
|
| 93 | + | }, |
|
| 94 | + | { |
|
| 95 | + | "match": "(?<![\\w\\d.])0[xX]\\.[0-9A-Fa-f]+([eE]-?\\d*)?([pP][-+]\\d+)?", |
|
| 96 | + | "name": "constant.numeric.float.hexadecimal.lua" |
|
| 97 | + | }, |
|
| 98 | + | { |
|
| 99 | + | "match": "(?<![\\w\\d.])0[xX][0-9A-Fa-f]+(?![pPeE.0-9])", |
|
| 100 | + | "name": "constant.numeric.integer.hexadecimal.lua" |
|
| 101 | + | }, |
|
| 102 | + | { |
|
| 103 | + | "match": "(?<![\\w\\d.])\\d+(\\.\\d*)?([eE]-?\\d*)?", |
|
| 104 | + | "name": "constant.numeric.float.lua" |
|
| 105 | + | }, |
|
| 106 | + | { |
|
| 107 | + | "match": "(?<![\\w\\d.])\\.\\d+([eE]-?\\d*)?", |
|
| 108 | + | "name": "constant.numeric.float.lua" |
|
| 109 | + | }, |
|
| 110 | + | { |
|
| 111 | + | "match": "(?<![\\w\\d.])\\d+(?![pPeE.0-9])", |
|
| 112 | + | "name": "constant.numeric.integer.lua" |
|
| 113 | + | }, |
|
| 114 | + | { |
|
| 115 | + | "include": "#string" |
|
| 116 | + | }, |
|
| 117 | + | { |
|
| 118 | + | "captures": { |
|
| 119 | + | "1": { |
|
| 120 | + | "name": "punctuation.definition.comment.lua" |
|
| 121 | + | } |
|
| 122 | + | }, |
|
| 123 | + | "match": "\\A(#!).*$\\n?", |
|
| 124 | + | "name": "comment.line.shebang.lua" |
|
| 125 | + | }, |
|
| 126 | + | { |
|
| 127 | + | "include": "#comment" |
|
| 128 | + | }, |
|
| 129 | + | { |
|
| 130 | + | "captures": { |
|
| 131 | + | "1": { |
|
| 132 | + | "name": "keyword.control.goto.lua" |
|
| 133 | + | }, |
|
| 134 | + | "2": { |
|
| 135 | + | "name": "string.tag.lua" |
|
| 136 | + | } |
|
| 137 | + | }, |
|
| 138 | + | "match": "\\b(goto)\\s+([a-zA-Z_][a-zA-Z0-9_]*)" |
|
| 139 | + | }, |
|
| 140 | + | { |
|
| 141 | + | "captures": { |
|
| 142 | + | "1": { |
|
| 143 | + | "name": "punctuation.section.embedded.begin.lua" |
|
| 144 | + | }, |
|
| 145 | + | "2": { |
|
| 146 | + | "name": "punctuation.section.embedded.end.lua" |
|
| 147 | + | } |
|
| 148 | + | }, |
|
| 149 | + | "match": "(::)\\s*[a-zA-Z_][a-zA-Z0-9_]*\\s*(::)", |
|
| 150 | + | "name": "string.tag.lua" |
|
| 151 | + | }, |
|
| 152 | + | { |
|
| 153 | + | "match": "<\\s*(const|close)\\s*>", |
|
| 154 | + | "captures": { |
|
| 155 | + | "0": { |
|
| 156 | + | "name": "storage.type.attribute.lua" |
|
| 157 | + | } |
|
| 158 | + | } |
|
| 159 | + | }, |
|
| 160 | + | { |
|
| 161 | + | "match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>", |
|
| 162 | + | "name": "storage.type.generic.lua" |
|
| 163 | + | }, |
|
| 164 | + | { |
|
| 165 | + | "match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in)\\b", |
|
| 166 | + | "name": "keyword.control.lua" |
|
| 167 | + | }, |
|
| 168 | + | { |
|
| 169 | + | "match": "\\b(local)\\b", |
|
| 170 | + | "name": "keyword.local.lua" |
|
| 171 | + | }, |
|
| 172 | + | { |
|
| 173 | + | "match": "^\\s*(global)\\b(?!\\s*=)", |
|
| 174 | + | "captures": { |
|
| 175 | + | "1": { |
|
| 176 | + | "name": "keyword.global.lua" |
|
| 177 | + | } |
|
| 178 | + | } |
|
| 179 | + | }, |
|
| 180 | + | { |
|
| 181 | + | "match": "\\b(function)\\b(?![,:])", |
|
| 182 | + | "name": "keyword.control.lua" |
|
| 183 | + | }, |
|
| 184 | + | { |
|
| 185 | + | "match": "(?<![^.]\\.|:)\\b(false|nil(?!:)|true|_ENV|_G|_VERSION|math\\.(pi|huge|maxinteger|mininteger)|utf8\\.charpattern|io\\.(stdin|stdout|stderr)|package\\.(config|cpath|loaded|loaders|path|preload|searchers))\\b|(?<![.])\\.{3}(?!\\.)", |
|
| 186 | + | "name": "constant.language.lua" |
|
| 187 | + | }, |
|
| 188 | + | { |
|
| 189 | + | "match": "(?<![^.]\\.|:)\\b(self)\\b", |
|
| 190 | + | "name": "variable.language.self.lua" |
|
| 191 | + | }, |
|
| 192 | + | { |
|
| 193 | + | "match": "(?<![^.]\\.|:)\\b(assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|loadstring|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\\b(?!\\s*=(?!=))", |
|
| 194 | + | "name": "support.function.lua" |
|
| 195 | + | }, |
|
| 196 | + | { |
|
| 197 | + | "match": "(?<![^.]\\.|:)\\b(async)\\b(?!\\s*=(?!=))", |
|
| 198 | + | "name": "entity.name.tag.lua" |
|
| 199 | + | }, |
|
| 200 | + | { |
|
| 201 | + | "match": "(?<![^.]\\.|:)\\b(coroutine\\.(create|isyieldable|close|resume|running|status|wrap|yield)|string\\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|pack|packsize|rep|reverse|sub|unpack|upper)|table\\.(concat|create|insert|maxn|move|pack|remove|sort|unpack)|math\\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|ldexp|log|log10|max|min|modf|pow|rad|random|randomseed|sinh?|sqrt|tanh?|tointeger|type)|io\\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write)|os\\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)|package\\.(loadlib|seeall|searchpath)|debug\\.(debug|[gs]etfenv|[gs]ethook|getinfo|[gs]etlocal|[gs]etmetatable|getregistry|[gs]etupvalue|[gs]etuservalue|set[Cc]stacklimit|traceback|upvalueid|upvaluejoin)|bit32\\.(arshift|band|bnot|bor|btest|bxor|extract|replace|lrotate|lshift|rrotate|rshift)|utf8\\.(char|codes|codepoint|len|offset))\\b(?!\\s*=(?!=))", |
|
| 202 | + | "name": "support.function.library.lua" |
|
| 203 | + | }, |
|
| 204 | + | { |
|
| 205 | + | "match": "\\b(\\|\\||\\&\\&|\\!)\\b", |
|
| 206 | + | "name": "keyword.operator.lua" |
|
| 207 | + | }, |
|
| 208 | + | { |
|
| 209 | + | "match": "\\b(and|or|not)\\b", |
|
| 210 | + | "name": "keyword.operator.logical.lua" |
|
| 211 | + | }, |
|
| 212 | + | { |
|
| 213 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*(?:[({\"']|\\[\\[))", |
|
| 214 | + | "name": "support.function.any-method.lua" |
|
| 215 | + | }, |
|
| 216 | + | { |
|
| 217 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*\\??:)", |
|
| 218 | + | "name": "entity.name.class.lua" |
|
| 219 | + | }, |
|
| 220 | + | { |
|
| 221 | + | "match": "(?<=[^.]\\.|:)\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?!\\s*=\\s*\\b(function)\\b)", |
|
| 222 | + | "name": "entity.other.attribute.lua" |
|
| 223 | + | }, |
|
| 224 | + | { |
|
| 225 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?!\\s*=\\s*\\b(function)\\b)", |
|
| 226 | + | "name": "variable.other.lua" |
|
| 227 | + | }, |
|
| 228 | + | { |
|
| 229 | + | "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(?=\\s*=\\s*\\b(function)\\b)", |
|
| 230 | + | "name": "entity.name.function.lua" |
|
| 231 | + | }, |
|
| 232 | + | { |
|
| 233 | + | "match": "\\+|-|%|#|\\*|\\/|\\^|==?|~=|!=|<=?|>=?|(?<!\\.)\\.{2}(?!\\.)", |
|
| 234 | + | "name": "keyword.operator.lua" |
|
| 235 | + | } |
|
| 236 | + | ], |
|
| 237 | + | "repository": { |
|
| 238 | + | "escaped_char": { |
|
| 239 | + | "patterns": [ |
|
| 240 | + | { |
|
| 241 | + | "match": "\\\\[abfnrtv\\\\\"'\\n]", |
|
| 242 | + | "name": "constant.character.escape.lua" |
|
| 243 | + | }, |
|
| 244 | + | { |
|
| 245 | + | "match": "\\\\z[\\n\\t ]*", |
|
| 246 | + | "name": "constant.character.escape.lua" |
|
| 247 | + | }, |
|
| 248 | + | { |
|
| 249 | + | "match": "\\\\\\d{1,3}", |
|
| 250 | + | "name": "constant.character.escape.byte.lua" |
|
| 251 | + | }, |
|
| 252 | + | { |
|
| 253 | + | "match": "\\\\x[0-9A-Fa-f][0-9A-Fa-f]", |
|
| 254 | + | "name": "constant.character.escape.byte.lua" |
|
| 255 | + | }, |
|
| 256 | + | { |
|
| 257 | + | "match": "\\\\u\\{[0-9A-Fa-f]+\\}", |
|
| 258 | + | "name": "constant.character.escape.unicode.lua" |
|
| 259 | + | }, |
|
| 260 | + | { |
|
| 261 | + | "match": "\\\\.", |
|
| 262 | + | "name": "invalid.illegal.character.escape.lua" |
|
| 263 | + | } |
|
| 264 | + | ] |
|
| 265 | + | }, |
|
| 266 | + | "string": { |
|
| 267 | + | "patterns": [ |
|
| 268 | + | { |
|
| 269 | + | "begin": "'", |
|
| 270 | + | "beginCaptures": { |
|
| 271 | + | "0": { |
|
| 272 | + | "name": "punctuation.definition.string.begin.lua" |
|
| 273 | + | } |
|
| 274 | + | }, |
|
| 275 | + | "end": "'[ \\t]*|(?=\\n)", |
|
| 276 | + | "endCaptures": { |
|
| 277 | + | "0": { |
|
| 278 | + | "name": "punctuation.definition.string.end.lua" |
|
| 279 | + | } |
|
| 280 | + | }, |
|
| 281 | + | "name": "string.quoted.single.lua", |
|
| 282 | + | "patterns": [ |
|
| 283 | + | { |
|
| 284 | + | "include": "#escaped_char" |
|
| 285 | + | } |
|
| 286 | + | ] |
|
| 287 | + | }, |
|
| 288 | + | { |
|
| 289 | + | "begin": "\"", |
|
| 290 | + | "beginCaptures": { |
|
| 291 | + | "0": { |
|
| 292 | + | "name": "punctuation.definition.string.begin.lua" |
|
| 293 | + | } |
|
| 294 | + | }, |
|
| 295 | + | "end": "\"[ \\t]*|(?=\\n)", |
|
| 296 | + | "endCaptures": { |
|
| 297 | + | "0": { |
|
| 298 | + | "name": "punctuation.definition.string.end.lua" |
|
| 299 | + | } |
|
| 300 | + | }, |
|
| 301 | + | "name": "string.quoted.double.lua", |
|
| 302 | + | "patterns": [ |
|
| 303 | + | { |
|
| 304 | + | "include": "#escaped_char" |
|
| 305 | + | } |
|
| 306 | + | ] |
|
| 307 | + | }, |
|
| 308 | + | { |
|
| 309 | + | "begin": "`", |
|
| 310 | + | "beginCaptures": { |
|
| 311 | + | "0": { |
|
| 312 | + | "name": "punctuation.definition.string.begin.lua" |
|
| 313 | + | } |
|
| 314 | + | }, |
|
| 315 | + | "end": "`[ \\t]*|(?=\\n)", |
|
| 316 | + | "endCaptures": { |
|
| 317 | + | "0": { |
|
| 318 | + | "name": "punctuation.definition.string.end.lua" |
|
| 319 | + | } |
|
| 320 | + | }, |
|
| 321 | + | "name": "string.quoted.double.lua" |
|
| 322 | + | }, |
|
| 323 | + | { |
|
| 324 | + | "begin": "(?<=\\.cdef)\\s*(\\[(=*)\\[)", |
|
| 325 | + | "beginCaptures": { |
|
| 326 | + | "0": { |
|
| 327 | + | "name": "string.quoted.other.multiline.lua" |
|
| 328 | + | }, |
|
| 329 | + | "1": { |
|
| 330 | + | "name": "punctuation.definition.string.begin.lua" |
|
| 331 | + | } |
|
| 332 | + | }, |
|
| 333 | + | "contentName": "meta.embedded.lua", |
|
| 334 | + | "end": "(\\]\\2\\])[ \\t]*", |
|
| 335 | + | "endCaptures": { |
|
| 336 | + | "0": { |
|
| 337 | + | "name": "string.quoted.other.multiline.lua" |
|
| 338 | + | }, |
|
| 339 | + | "1": { |
|
| 340 | + | "name": "punctuation.definition.string.end.lua" |
|
| 341 | + | } |
|
| 342 | + | }, |
|
| 343 | + | "patterns": [ |
|
| 344 | + | { |
|
| 345 | + | "include": "source.c" |
|
| 346 | + | } |
|
| 347 | + | ] |
|
| 348 | + | }, |
|
| 349 | + | { |
|
| 350 | + | "begin": "(?<!--)\\[(=*)\\[", |
|
| 351 | + | "beginCaptures": { |
|
| 352 | + | "0": { |
|
| 353 | + | "name": "punctuation.definition.string.begin.lua" |
|
| 354 | + | } |
|
| 355 | + | }, |
|
| 356 | + | "end": "\\]\\1\\][ \\t]*", |
|
| 357 | + | "endCaptures": { |
|
| 358 | + | "0": { |
|
| 359 | + | "name": "punctuation.definition.string.end.lua" |
|
| 360 | + | } |
|
| 361 | + | }, |
|
| 362 | + | "name": "string.quoted.other.multiline.lua" |
|
| 363 | + | } |
|
| 364 | + | ] |
|
| 365 | + | }, |
|
| 366 | + | "comment": { |
|
| 367 | + | "patterns": [ |
|
| 368 | + | { |
|
| 369 | + | "begin": "(^[ \\t]+)?(?=--)", |
|
| 370 | + | "beginCaptures": { |
|
| 371 | + | "1": { |
|
| 372 | + | "name": "punctuation.whitespace.comment.leading.lua" |
|
| 373 | + | } |
|
| 374 | + | }, |
|
| 375 | + | "end": "(?!\\G)((?!^)[ \\t]+\\n)?", |
|
| 376 | + | "endCaptures": { |
|
| 377 | + | "1": { |
|
| 378 | + | "name": "punctuation.whitespace.comment.trailing.lua" |
|
| 379 | + | } |
|
| 380 | + | }, |
|
| 381 | + | "patterns": [ |
|
| 382 | + | { |
|
| 383 | + | "begin": "--\\[(=*)\\[@@@", |
|
| 384 | + | "beginCaptures": { |
|
| 385 | + | "0": { |
|
| 386 | + | "name": "punctuation.definition.comment.begin.lua" |
|
| 387 | + | } |
|
| 388 | + | }, |
|
| 389 | + | "end": "(--)?\\]\\1\\]", |
|
| 390 | + | "endCaptures": { |
|
| 391 | + | "0": { |
|
| 392 | + | "name": "punctuation.definition.comment.end.lua" |
|
| 393 | + | } |
|
| 394 | + | }, |
|
| 395 | + | "name": "", |
|
| 396 | + | "patterns": [ |
|
| 397 | + | { |
|
| 398 | + | "include": "source.lua" |
|
| 399 | + | } |
|
| 400 | + | ] |
|
| 401 | + | }, |
|
| 402 | + | { |
|
| 403 | + | "begin": "--\\[(=*)\\[", |
|
| 404 | + | "beginCaptures": { |
|
| 405 | + | "0": { |
|
| 406 | + | "name": "punctuation.definition.comment.begin.lua" |
|
| 407 | + | } |
|
| 408 | + | }, |
|
| 409 | + | "end": "(--)?\\]\\1\\]", |
|
| 410 | + | "endCaptures": { |
|
| 411 | + | "0": { |
|
| 412 | + | "name": "punctuation.definition.comment.end.lua" |
|
| 413 | + | } |
|
| 414 | + | }, |
|
| 415 | + | "name": "comment.block.lua", |
|
| 416 | + | "patterns": [ |
|
| 417 | + | { |
|
| 418 | + | "include": "#emmydoc" |
|
| 419 | + | }, |
|
| 420 | + | { |
|
| 421 | + | "include": "#ldoc_tag" |
|
| 422 | + | } |
|
| 423 | + | ] |
|
| 424 | + | }, |
|
| 425 | + | { |
|
| 426 | + | "begin": "----", |
|
| 427 | + | "beginCaptures": { |
|
| 428 | + | "0": { |
|
| 429 | + | "name": "punctuation.definition.comment.lua" |
|
| 430 | + | } |
|
| 431 | + | }, |
|
| 432 | + | "end": "\\n", |
|
| 433 | + | "name": "comment.line.double-dash.lua" |
|
| 434 | + | }, |
|
| 435 | + | { |
|
| 436 | + | "begin": "---", |
|
| 437 | + | "beginCaptures": { |
|
| 438 | + | "0": { |
|
| 439 | + | "name": "punctuation.definition.comment.lua" |
|
| 440 | + | } |
|
| 441 | + | }, |
|
| 442 | + | "end": "\\n", |
|
| 443 | + | "name": "comment.line.double-dash.documentation.lua", |
|
| 444 | + | "patterns": [ |
|
| 445 | + | { |
|
| 446 | + | "include": "#emmydoc" |
|
| 447 | + | }, |
|
| 448 | + | { |
|
| 449 | + | "include": "#ldoc_tag" |
|
| 450 | + | } |
|
| 451 | + | ] |
|
| 452 | + | }, |
|
| 453 | + | { |
|
| 454 | + | "begin": "--", |
|
| 455 | + | "beginCaptures": { |
|
| 456 | + | "0": { |
|
| 457 | + | "name": "punctuation.definition.comment.lua" |
|
| 458 | + | } |
|
| 459 | + | }, |
|
| 460 | + | "end": "\\n", |
|
| 461 | + | "name": "comment.line.double-dash.lua", |
|
| 462 | + | "patterns": [ |
|
| 463 | + | { |
|
| 464 | + | "include": "#ldoc_tag" |
|
| 465 | + | } |
|
| 466 | + | ] |
|
| 467 | + | } |
|
| 468 | + | ] |
|
| 469 | + | }, |
|
| 470 | + | { |
|
| 471 | + | "begin": "\\/\\*", |
|
| 472 | + | "beginCaptures": { |
|
| 473 | + | "0": { |
|
| 474 | + | "name": "punctuation.definition.comment.begin.lua" |
|
| 475 | + | } |
|
| 476 | + | }, |
|
| 477 | + | "end": "\\*\\/", |
|
| 478 | + | "endCaptures": { |
|
| 479 | + | "0": { |
|
| 480 | + | "name": "punctuation.definition.comment.end.lua" |
|
| 481 | + | } |
|
| 482 | + | }, |
|
| 483 | + | "name": "comment.block.lua", |
|
| 484 | + | "patterns": [ |
|
| 485 | + | { |
|
| 486 | + | "include": "#emmydoc" |
|
| 487 | + | }, |
|
| 488 | + | { |
|
| 489 | + | "include": "#ldoc_tag" |
|
| 490 | + | } |
|
| 491 | + | ] |
|
| 492 | + | } |
|
| 493 | + | ] |
|
| 494 | + | }, |
|
| 495 | + | "emmydoc": { |
|
| 496 | + | "patterns": [ |
|
| 497 | + | { |
|
| 498 | + | "begin": "(?<=---)[ \\t]*@class", |
|
| 499 | + | "beginCaptures": { |
|
| 500 | + | "0": { |
|
| 501 | + | "name": "storage.type.annotation.lua" |
|
| 502 | + | } |
|
| 503 | + | }, |
|
| 504 | + | "end": "(?=[\\n@#])", |
|
| 505 | + | "patterns": [ |
|
| 506 | + | { |
|
| 507 | + | "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", |
|
| 508 | + | "name": "support.class.lua" |
|
| 509 | + | }, |
|
| 510 | + | { |
|
| 511 | + | "match": ":|,", |
|
| 512 | + | "name": "keyword.operator.lua" |
|
| 513 | + | } |
|
| 514 | + | ] |
|
| 515 | + | }, |
|
| 516 | + | { |
|
| 517 | + | "begin": "(?<=---)[ \\t]*@enum", |
|
| 518 | + | "beginCaptures": { |
|
| 519 | + | "0": { |
|
| 520 | + | "name": "storage.type.annotation.lua" |
|
| 521 | + | } |
|
| 522 | + | }, |
|
| 523 | + | "end": "(?=[\\n@#])", |
|
| 524 | + | "patterns": [ |
|
| 525 | + | { |
|
| 526 | + | "begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", |
|
| 527 | + | "beginCaptures": { |
|
| 528 | + | "0": { |
|
| 529 | + | "name": "variable.lua" |
|
| 530 | + | } |
|
| 531 | + | }, |
|
| 532 | + | "end": "(?=\\n)" |
|
| 533 | + | } |
|
| 534 | + | ] |
|
| 535 | + | }, |
|
| 536 | + | { |
|
| 537 | + | "begin": "(?<=---)[ \\t]*@type", |
|
| 538 | + | "beginCaptures": { |
|
| 539 | + | "0": { |
|
| 540 | + | "name": "storage.type.annotation.lua" |
|
| 541 | + | } |
|
| 542 | + | }, |
|
| 543 | + | "end": "(?=[\\n@#])", |
|
| 544 | + | "patterns": [ |
|
| 545 | + | { |
|
| 546 | + | "include": "#emmydoc.type" |
|
| 547 | + | } |
|
| 548 | + | ] |
|
| 549 | + | }, |
|
| 550 | + | { |
|
| 551 | + | "begin": "(?<=---)[ \\t]*@alias", |
|
| 552 | + | "beginCaptures": { |
|
| 553 | + | "0": { |
|
| 554 | + | "name": "storage.type.annotation.lua" |
|
| 555 | + | } |
|
| 556 | + | }, |
|
| 557 | + | "end": "(?=[\\n@#])", |
|
| 558 | + | "patterns": [ |
|
| 559 | + | { |
|
| 560 | + | "begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", |
|
| 561 | + | "beginCaptures": { |
|
| 562 | + | "0": { |
|
| 563 | + | "name": "variable.lua" |
|
| 564 | + | } |
|
| 565 | + | }, |
|
| 566 | + | "end": "(?=[\\n#])", |
|
| 567 | + | "patterns": [ |
|
| 568 | + | { |
|
| 569 | + | "include": "#emmydoc.type" |
|
| 570 | + | } |
|
| 571 | + | ] |
|
| 572 | + | } |
|
| 573 | + | ] |
|
| 574 | + | }, |
|
| 575 | + | { |
|
| 576 | + | "begin": "(?<=---)[ \\t]*(@operator)\\s*(\\b[a-z]+)?", |
|
| 577 | + | "beginCaptures": { |
|
| 578 | + | "1": { |
|
| 579 | + | "name": "storage.type.annotation.lua" |
|
| 580 | + | }, |
|
| 581 | + | "2": { |
|
| 582 | + | "name": "support.function.library.lua" |
|
| 583 | + | } |
|
| 584 | + | }, |
|
| 585 | + | "end": "(?=[\\n@#])", |
|
| 586 | + | "patterns": [ |
|
| 587 | + | { |
|
| 588 | + | "include": "#emmydoc.type" |
|
| 589 | + | } |
|
| 590 | + | ] |
|
| 591 | + | }, |
|
| 592 | + | { |
|
| 593 | + | "begin": "(?<=---)[ \\t]*@cast", |
|
| 594 | + | "beginCaptures": { |
|
| 595 | + | "0": { |
|
| 596 | + | "name": "storage.type.annotation.lua" |
|
| 597 | + | } |
|
| 598 | + | }, |
|
| 599 | + | "end": "(?=[\\n@#])", |
|
| 600 | + | "patterns": [ |
|
| 601 | + | { |
|
| 602 | + | "begin": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", |
|
| 603 | + | "beginCaptures": { |
|
| 604 | + | "0": { |
|
| 605 | + | "name": "variable.other.lua" |
|
| 606 | + | } |
|
| 607 | + | }, |
|
| 608 | + | "end": "(?=\\n)", |
|
| 609 | + | "patterns": [ |
|
| 610 | + | { |
|
| 611 | + | "include": "#emmydoc.type" |
|
| 612 | + | }, |
|
| 613 | + | { |
|
| 614 | + | "match": "([+-|])", |
|
| 615 | + | "name": "keyword.operator.lua" |
|
| 616 | + | } |
|
| 617 | + | ] |
|
| 618 | + | } |
|
| 619 | + | ] |
|
| 620 | + | }, |
|
| 621 | + | { |
|
| 622 | + | "begin": "(?<=---)[ \\t]*@param", |
|
| 623 | + | "beginCaptures": { |
|
| 624 | + | "0": { |
|
| 625 | + | "name": "storage.type.annotation.lua" |
|
| 626 | + | } |
|
| 627 | + | }, |
|
| 628 | + | "end": "(?=[\\n@#])", |
|
| 629 | + | "patterns": [ |
|
| 630 | + | { |
|
| 631 | + | "begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b(\\??)", |
|
| 632 | + | "beginCaptures": { |
|
| 633 | + | "1": { |
|
| 634 | + | "name": "entity.name.variable.lua" |
|
| 635 | + | }, |
|
| 636 | + | "2": { |
|
| 637 | + | "name": "keyword.operator.lua" |
|
| 638 | + | } |
|
| 639 | + | }, |
|
| 640 | + | "end": "(?=[\\n#])", |
|
| 641 | + | "patterns": [ |
|
| 642 | + | { |
|
| 643 | + | "include": "#emmydoc.type" |
|
| 644 | + | } |
|
| 645 | + | ] |
|
| 646 | + | } |
|
| 647 | + | ] |
|
| 648 | + | }, |
|
| 649 | + | { |
|
| 650 | + | "begin": "(?<=---)[ \\t]*@return", |
|
| 651 | + | "beginCaptures": { |
|
| 652 | + | "0": { |
|
| 653 | + | "name": "storage.type.annotation.lua" |
|
| 654 | + | } |
|
| 655 | + | }, |
|
| 656 | + | "end": "(?=[\\n@#])", |
|
| 657 | + | "patterns": [ |
|
| 658 | + | { |
|
| 659 | + | "match": "\\?", |
|
| 660 | + | "name": "keyword.operator.lua" |
|
| 661 | + | }, |
|
| 662 | + | { |
|
| 663 | + | "include": "#emmydoc.type" |
|
| 664 | + | } |
|
| 665 | + | ] |
|
| 666 | + | }, |
|
| 667 | + | { |
|
| 668 | + | "begin": "(?<=---)[ \\t]*@field", |
|
| 669 | + | "beginCaptures": { |
|
| 670 | + | "0": { |
|
| 671 | + | "name": "storage.type.annotation.lua" |
|
| 672 | + | } |
|
| 673 | + | }, |
|
| 674 | + | "end": "(?=[\\n@#])", |
|
| 675 | + | "patterns": [ |
|
| 676 | + | { |
|
| 677 | + | "begin": "(\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b|(\\[))(\\??)", |
|
| 678 | + | "beginCaptures": { |
|
| 679 | + | "2": { |
|
| 680 | + | "name": "entity.name.variable.lua" |
|
| 681 | + | }, |
|
| 682 | + | "3": { |
|
| 683 | + | "name": "keyword.operator.lua" |
|
| 684 | + | } |
|
| 685 | + | }, |
|
| 686 | + | "end": "(?=[\\n#])", |
|
| 687 | + | "patterns": [ |
|
| 688 | + | { |
|
| 689 | + | "include": "#string" |
|
| 690 | + | }, |
|
| 691 | + | { |
|
| 692 | + | "include": "#emmydoc.type" |
|
| 693 | + | }, |
|
| 694 | + | { |
|
| 695 | + | "match": "\\]", |
|
| 696 | + | "name": "keyword.operator.lua" |
|
| 697 | + | } |
|
| 698 | + | ] |
|
| 699 | + | } |
|
| 700 | + | ] |
|
| 701 | + | }, |
|
| 702 | + | { |
|
| 703 | + | "begin": "(?<=---)[ \\t]*@generic", |
|
| 704 | + | "beginCaptures": { |
|
| 705 | + | "0": { |
|
| 706 | + | "name": "storage.type.annotation.lua" |
|
| 707 | + | } |
|
| 708 | + | }, |
|
| 709 | + | "end": "(?=[\\n@#])", |
|
| 710 | + | "patterns": [ |
|
| 711 | + | { |
|
| 712 | + | "begin": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b", |
|
| 713 | + | "beginCaptures": { |
|
| 714 | + | "0": { |
|
| 715 | + | "name": "storage.type.generic.lua" |
|
| 716 | + | } |
|
| 717 | + | }, |
|
| 718 | + | "end": "(?=\\n)|(,)", |
|
| 719 | + | "endCaptures": { |
|
| 720 | + | "0": { |
|
| 721 | + | "name": "keyword.operator.lua" |
|
| 722 | + | } |
|
| 723 | + | }, |
|
| 724 | + | "patterns": [ |
|
| 725 | + | { |
|
| 726 | + | "match": ":", |
|
| 727 | + | "name": "keyword.operator.lua" |
|
| 728 | + | }, |
|
| 729 | + | { |
|
| 730 | + | "include": "#emmydoc.type" |
|
| 731 | + | } |
|
| 732 | + | ] |
|
| 733 | + | } |
|
| 734 | + | ] |
|
| 735 | + | }, |
|
| 736 | + | { |
|
| 737 | + | "begin": "(?<=---)[ \\t]*@vararg", |
|
| 738 | + | "beginCaptures": { |
|
| 739 | + | "0": { |
|
| 740 | + | "name": "storage.type.annotation.lua" |
|
| 741 | + | } |
|
| 742 | + | }, |
|
| 743 | + | "end": "(?=[\\n@#])", |
|
| 744 | + | "patterns": [ |
|
| 745 | + | { |
|
| 746 | + | "include": "#emmydoc.type" |
|
| 747 | + | } |
|
| 748 | + | ] |
|
| 749 | + | }, |
|
| 750 | + | { |
|
| 751 | + | "begin": "(?<=---)[ \\t]*@overload", |
|
| 752 | + | "beginCaptures": { |
|
| 753 | + | "0": { |
|
| 754 | + | "name": "storage.type.annotation.lua" |
|
| 755 | + | } |
|
| 756 | + | }, |
|
| 757 | + | "end": "(?=[\\n@#])", |
|
| 758 | + | "patterns": [ |
|
| 759 | + | { |
|
| 760 | + | "include": "#emmydoc.type" |
|
| 761 | + | } |
|
| 762 | + | ] |
|
| 763 | + | }, |
|
| 764 | + | { |
|
| 765 | + | "begin": "(?<=---)[ \\t]*@deprecated", |
|
| 766 | + | "beginCaptures": { |
|
| 767 | + | "0": { |
|
| 768 | + | "name": "storage.type.annotation.lua" |
|
| 769 | + | } |
|
| 770 | + | }, |
|
| 771 | + | "end": "(?=[\\n@#])" |
|
| 772 | + | }, |
|
| 773 | + | { |
|
| 774 | + | "begin": "(?<=---)[ \\t]*@meta", |
|
| 775 | + | "beginCaptures": { |
|
| 776 | + | "0": { |
|
| 777 | + | "name": "storage.type.annotation.lua" |
|
| 778 | + | } |
|
| 779 | + | }, |
|
| 780 | + | "end": "(?=[\\n@#])" |
|
| 781 | + | }, |
|
| 782 | + | { |
|
| 783 | + | "begin": "(?<=---)[ \\t]*@private", |
|
| 784 | + | "beginCaptures": { |
|
| 785 | + | "0": { |
|
| 786 | + | "name": "storage.type.annotation.lua" |
|
| 787 | + | } |
|
| 788 | + | }, |
|
| 789 | + | "end": "(?=[\\n@#])" |
|
| 790 | + | }, |
|
| 791 | + | { |
|
| 792 | + | "begin": "(?<=---)[ \\t]*@protected", |
|
| 793 | + | "beginCaptures": { |
|
| 794 | + | "0": { |
|
| 795 | + | "name": "storage.type.annotation.lua" |
|
| 796 | + | } |
|
| 797 | + | }, |
|
| 798 | + | "end": "(?=[\\n@#])" |
|
| 799 | + | }, |
|
| 800 | + | { |
|
| 801 | + | "begin": "(?<=---)[ \\t]*@package", |
|
| 802 | + | "beginCaptures": { |
|
| 803 | + | "0": { |
|
| 804 | + | "name": "storage.type.annotation.lua" |
|
| 805 | + | } |
|
| 806 | + | }, |
|
| 807 | + | "end": "(?=[\\n@#])" |
|
| 808 | + | }, |
|
| 809 | + | { |
|
| 810 | + | "begin": "(?<=---)[ \\t]*@version", |
|
| 811 | + | "beginCaptures": { |
|
| 812 | + | "0": { |
|
| 813 | + | "name": "storage.type.annotation.lua" |
|
| 814 | + | } |
|
| 815 | + | }, |
|
| 816 | + | "end": "(?=[\\n@#])", |
|
| 817 | + | "patterns": [ |
|
| 818 | + | { |
|
| 819 | + | "match": "\\b(5\\.1|5\\.2|5\\.3|5\\.4|JIT)\\b", |
|
| 820 | + | "name": "support.class.lua" |
|
| 821 | + | }, |
|
| 822 | + | { |
|
| 823 | + | "match": ",|\\>|\\<", |
|
| 824 | + | "name": "keyword.operator.lua" |
|
| 825 | + | } |
|
| 826 | + | ] |
|
| 827 | + | }, |
|
| 828 | + | { |
|
| 829 | + | "begin": "(?<=---)[ \\t]*@see", |
|
| 830 | + | "beginCaptures": { |
|
| 831 | + | "0": { |
|
| 832 | + | "name": "storage.type.annotation.lua" |
|
| 833 | + | } |
|
| 834 | + | }, |
|
| 835 | + | "end": "(?=[\\n@#])", |
|
| 836 | + | "patterns": [ |
|
| 837 | + | { |
|
| 838 | + | "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", |
|
| 839 | + | "name": "support.class.lua" |
|
| 840 | + | }, |
|
| 841 | + | { |
|
| 842 | + | "match": "#", |
|
| 843 | + | "name": "keyword.operator.lua" |
|
| 844 | + | } |
|
| 845 | + | ] |
|
| 846 | + | }, |
|
| 847 | + | { |
|
| 848 | + | "begin": "(?<=---)[ \\t]*@diagnostic", |
|
| 849 | + | "beginCaptures": { |
|
| 850 | + | "0": { |
|
| 851 | + | "name": "storage.type.annotation.lua" |
|
| 852 | + | } |
|
| 853 | + | }, |
|
| 854 | + | "end": "(?=[\\n@#])", |
|
| 855 | + | "patterns": [ |
|
| 856 | + | { |
|
| 857 | + | "begin": "([a-zA-Z_\\-0-9]+)[ \\t]*(:)?", |
|
| 858 | + | "beginCaptures": { |
|
| 859 | + | "1": { |
|
| 860 | + | "name": "keyword.other.unit" |
|
| 861 | + | }, |
|
| 862 | + | "2": { |
|
| 863 | + | "name": "keyword.operator.unit" |
|
| 864 | + | } |
|
| 865 | + | }, |
|
| 866 | + | "end": "(?=\\n)", |
|
| 867 | + | "patterns": [ |
|
| 868 | + | { |
|
| 869 | + | "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\-]*)", |
|
| 870 | + | "name": "support.class.lua" |
|
| 871 | + | }, |
|
| 872 | + | { |
|
| 873 | + | "match": ",", |
|
| 874 | + | "name": "keyword.operator.lua" |
|
| 875 | + | } |
|
| 876 | + | ] |
|
| 877 | + | } |
|
| 878 | + | ] |
|
| 879 | + | }, |
|
| 880 | + | { |
|
| 881 | + | "begin": "(?<=---)[ \\t]*@module", |
|
| 882 | + | "beginCaptures": { |
|
| 883 | + | "0": { |
|
| 884 | + | "name": "storage.type.annotation.lua" |
|
| 885 | + | } |
|
| 886 | + | }, |
|
| 887 | + | "end": "(?=[\\n@#])", |
|
| 888 | + | "patterns": [ |
|
| 889 | + | { |
|
| 890 | + | "include": "#string" |
|
| 891 | + | } |
|
| 892 | + | ] |
|
| 893 | + | }, |
|
| 894 | + | { |
|
| 895 | + | "match": "(?<=---)[ \\t]*@(async|nodiscard)", |
|
| 896 | + | "name": "storage.type.annotation.lua" |
|
| 897 | + | }, |
|
| 898 | + | { |
|
| 899 | + | "begin": "(?<=---)\\|\\s*[\\>\\+]?", |
|
| 900 | + | "beginCaptures": { |
|
| 901 | + | "0": { |
|
| 902 | + | "name": "storage.type.annotation.lua" |
|
| 903 | + | } |
|
| 904 | + | }, |
|
| 905 | + | "end": "(?=[\\n@#])", |
|
| 906 | + | "patterns": [ |
|
| 907 | + | { |
|
| 908 | + | "include": "#string" |
|
| 909 | + | } |
|
| 910 | + | ] |
|
| 911 | + | } |
|
| 912 | + | ] |
|
| 913 | + | }, |
|
| 914 | + | "emmydoc.type": { |
|
| 915 | + | "patterns": [ |
|
| 916 | + | { |
|
| 917 | + | "begin": "\\bfun\\b", |
|
| 918 | + | "beginCaptures": { |
|
| 919 | + | "0": { |
|
| 920 | + | "name": "keyword.control.lua" |
|
| 921 | + | } |
|
| 922 | + | }, |
|
| 923 | + | "end": "(?=[\\s#])", |
|
| 924 | + | "patterns": [ |
|
| 925 | + | { |
|
| 926 | + | "match": "[\\(\\),\\:\\?\\[\\]\\<\\>][ \\t]*", |
|
| 927 | + | "name": "keyword.operator.lua" |
|
| 928 | + | }, |
|
| 929 | + | { |
|
| 930 | + | "match": "([a-zA-Z_][a-zA-Z0-9_\\.\\*\\-]*)(?<!,)[ \\t]*(?=\\??:)", |
|
| 931 | + | "name": "entity.name.variable.lua" |
|
| 932 | + | }, |
|
| 933 | + | { |
|
| 934 | + | "include": "#emmydoc.type" |
|
| 935 | + | }, |
|
| 936 | + | { |
|
| 937 | + | "include": "#string" |
|
| 938 | + | } |
|
| 939 | + | ] |
|
| 940 | + | }, |
|
| 941 | + | { |
|
| 942 | + | "match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>", |
|
| 943 | + | "name": "storage.type.generic.lua" |
|
| 944 | + | }, |
|
| 945 | + | { |
|
| 946 | + | "match": "\\basync\\b", |
|
| 947 | + | "name": "entity.name.tag.lua" |
|
| 948 | + | }, |
|
| 949 | + | { |
|
| 950 | + | "match": "[\\{\\}\\:\\,\\?\\|\\`][ \\t]*", |
|
| 951 | + | "name": "keyword.operator.lua" |
|
| 952 | + | }, |
|
| 953 | + | { |
|
| 954 | + | "begin": "(?=[a-zA-Z_\\.\\*\"'\\[])", |
|
| 955 | + | "end": "(?=[\\s\\)\\,\\?\\:\\}\\|#])", |
|
| 956 | + | "patterns": [ |
|
| 957 | + | { |
|
| 958 | + | "match": "([a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]+)(?<!,)[ \\t]*", |
|
| 959 | + | "name": "support.type.lua" |
|
| 960 | + | }, |
|
| 961 | + | { |
|
| 962 | + | "match": "(\\.\\.\\.)[ \\t]*", |
|
| 963 | + | "name": "constant.language.lua" |
|
| 964 | + | }, |
|
| 965 | + | { |
|
| 966 | + | "include": "#string" |
|
| 967 | + | } |
|
| 968 | + | ] |
|
| 969 | + | } |
|
| 970 | + | ] |
|
| 971 | + | }, |
|
| 972 | + | "ldoc_tag": { |
|
| 973 | + | "match": "\\G[ \\t]*(@)(alias|annotation|author|charset|class|classmod|comment|constructor|copyright|description|example|export|factory|field|file|fixme|function|include|lfunction|license|local|module|name|param|pragma|private|raise|release|return|script|section|see|set|static|submodule|summary|tfield|thread|tparam|treturn|todo|topic|type|usage|warning|within)\\b", |
|
| 974 | + | "captures": { |
|
| 975 | + | "1": { |
|
| 976 | + | "name": "punctuation.definition.block.tag.ldoc" |
|
| 977 | + | }, |
|
| 978 | + | "2": { |
|
| 979 | + | "name": "storage.type.class.ldoc" |
|
| 980 | + | } |
|
| 981 | + | } |
|
| 982 | + | } |
|
| 983 | + | } |
|
| 984 | + | } |
crates/highlight/tests/syntaxes.rs
+26 -0
| 9 | 9 | fn built_in_syntaxes_compile() { |
|
| 10 | 10 | for source in [ |
|
| 11 | 11 | syntaxes::C, |
|
| 12 | 12 | syntaxes::CSS, |
|
| 13 | 13 | syntaxes::ERB, |
|
| 14 | + | syntaxes::FISH, |
|
| 14 | 15 | syntaxes::GO, |
|
| 15 | 16 | syntaxes::HTML, |
|
| 16 | 17 | syntaxes::JAVASCRIPT, |
|
| 18 | + | syntaxes::LUA, |
|
| 17 | 19 | syntaxes::MAKE, |
|
| 18 | 20 | syntaxes::MARKDOWN, |
|
| 19 | 21 | syntaxes::PYTHON, |
|
| 20 | 22 | syntaxes::RUBY, |
|
| 21 | 23 | syntaxes::RUST, |
| 32 | 34 | #[test] |
|
| 33 | 35 | fn scripting_syntaxes_match_shebangs() { |
|
| 34 | 36 | let ruby = Grammar::from_str(syntaxes::RUBY).unwrap(); |
|
| 35 | 37 | let python = Grammar::from_str(syntaxes::PYTHON).unwrap(); |
|
| 36 | 38 | let shell = Grammar::from_str(syntaxes::SHELL).unwrap(); |
|
| 39 | + | let fish = Grammar::from_str(syntaxes::FISH).unwrap(); |
|
| 37 | 40 | ||
| 38 | 41 | assert!(ruby.matches_head("#!/usr/bin/env ruby3.3")); |
|
| 39 | 42 | assert!(python.matches_head("#!/usr/bin/env python3.11")); |
|
| 40 | 43 | assert!(shell.matches_head("#!/bin/sh")); |
|
| 44 | + | assert!(fish.matches_head("#!/usr/bin/env fish")); |
|
| 41 | 45 | } |
|
| 42 | 46 | ||
| 43 | 47 | #[test] |
|
| 44 | 48 | fn erb_embeds_html_and_ruby_scopes() { |
|
| 45 | 49 | let erb: rustik_highlight::RawGrammar = syntaxes::ERB.parse().unwrap(); |
| 114 | 118 | ||
| 115 | 119 | assert!(scopes.contains(&"string.quoted.single.js")); |
|
| 116 | 120 | assert!(scopes.contains(&"storage.type.function.js")); |
|
| 117 | 121 | } |
|
| 118 | 122 | ||
| 123 | + | #[test] |
|
| 124 | + | fn fish_highlights_keywords_variables_and_strings() { |
|
| 125 | + | let grammar = Grammar::from_str(syntaxes::FISH).unwrap(); |
|
| 126 | + | let scopes = tokenize_scopes(&grammar, "if test -n \"$argv\""); |
|
| 127 | + | ||
| 128 | + | assert!(scopes.contains(&"keyword.control.fish")); |
|
| 129 | + | assert!(scopes.contains(&"source.option.fish")); |
|
| 130 | + | assert!(scopes.contains(&"string.quoted.double.fish")); |
|
| 131 | + | assert!(scopes.contains(&"variable.language.fish")); |
|
| 132 | + | } |
|
| 133 | + | ||
| 134 | + | #[test] |
|
| 135 | + | fn lua_highlights_keywords_booleans_and_strings() { |
|
| 136 | + | let grammar = Grammar::from_str(syntaxes::LUA).unwrap(); |
|
| 137 | + | let scopes = tokenize_scopes(&grammar, "local ok = true and \"done\""); |
|
| 138 | + | ||
| 139 | + | assert!(scopes.contains(&"keyword.local.lua")); |
|
| 140 | + | assert!(scopes.contains(&"constant.language.lua")); |
|
| 141 | + | assert!(scopes.contains(&"keyword.operator.logical.lua")); |
|
| 142 | + | assert!(scopes.contains(&"string.quoted.double.lua")); |
|
| 143 | + | } |
|
| 144 | + | ||
| 119 | 145 | #[test] |
|
| 120 | 146 | fn css_root_comments_are_highlighted() { |
|
| 121 | 147 | let grammar = Grammar::from_str(syntaxes::CSS).unwrap(); |
|
| 122 | 148 | let mut state = LineState::default(); |
|
| 123 | 149 | let line = "/**/"; |