|
| 1 | +; GENERATED VIA https://github.com/vito/tree-sitter-bass |
| 2 | + |
| 3 | +(comment) @comment.line |
| 4 | + |
| 5 | +["(" ")" "[" "]" "{" "}"] @punctuation.bracket |
| 6 | + |
| 7 | +[(ignore) (null) (bool)] @constant.builtin |
| 8 | + |
| 9 | +(int) @constant.numeric |
| 10 | + |
| 11 | +(string (string_escape) @constant.character.escape) |
| 12 | + |
| 13 | +(string) @string |
| 14 | + |
| 15 | +[(command) (path) (relpath)] @namespace |
| 16 | + |
| 17 | +(keyword) @string.special.symbol |
| 18 | + |
| 19 | + |
| 20 | +;;; specific queries take precedence |
| 21 | + |
| 22 | +;; classification based highlighting |
| 23 | + |
| 24 | +(list . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$")) |
| 25 | +(cons . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$")) |
| 26 | + |
| 27 | +(list . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$")) |
| 28 | +(cons . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$")) |
| 29 | + |
| 30 | +(list . (symbol) @label (#match? @label "^(def|defop|defn)$")) |
| 31 | +(cons . (symbol) @label (#match? @label "^(def|defop|defn)$")) |
| 32 | + |
| 33 | +(list . (symbol) @function.builtin (#match? @function.builtin "^(dump|mkfs|json|log|error|now|cons|wrap|unwrap|eval|make-scope|bind|meta|with-meta|null\\?|ignore\\?|boolean\\?|number\\?|string\\?|symbol\\?|scope\\?|sink\\?|source\\?|list\\?|pair\\?|applicative\\?|operative\\?|combiner\\?|path\\?|empty\\?|thunk\\?|\\+|\\*|quot|-|max|min|=|>|>=|<|<=|list->source|across|emit|next|reduce-kv|assoc|symbol->string|string->symbol|str|substring|trim|scope->list|string->fs-path|string->cmd-path|string->dir|subpath|path-name|path-stem|with-image|with-dir|with-args|with-cmd|with-stdin|with-env|with-insecure|with-label|with-port|with-tls|with-mount|thunk-cmd|thunk-args|resolve|start|addr|wait|read|cache-dir|binds\\?|recall-memo|store-memo|mask|list|list\\*|first|rest|length|second|third|map|map-pairs|foldr|foldl|append|filter|conj|list->scope|merge|apply|id|always|vals|keys|memo|succeeds\\?|run|last|take|take-all|insecure!|from|cd|wrap-cmd|mkfile|path-base|not)$")) |
| 34 | +(cons . (symbol) @function.builtin (#match? @function.builtin "^(dump|mkfs|json|log|error|now|cons|wrap|unwrap|eval|make-scope|bind|meta|with-meta|null\\?|ignore\\?|boolean\\?|number\\?|string\\?|symbol\\?|scope\\?|sink\\?|source\\?|list\\?|pair\\?|applicative\\?|operative\\?|combiner\\?|path\\?|empty\\?|thunk\\?|\\+|\\*|quot|-|max|min|=|>|>=|<|<=|list->source|across|emit|next|reduce-kv|assoc|symbol->string|string->symbol|str|substring|trim|scope->list|string->fs-path|string->cmd-path|string->dir|subpath|path-name|path-stem|with-image|with-dir|with-args|with-cmd|with-stdin|with-env|with-insecure|with-label|with-port|with-tls|with-mount|thunk-cmd|thunk-args|resolve|start|addr|wait|read|cache-dir|binds\\?|recall-memo|store-memo|mask|list|list\\*|first|rest|length|second|third|map|map-pairs|foldr|foldl|append|filter|conj|list->scope|merge|apply|id|always|vals|keys|memo|succeeds\\?|run|last|take|take-all|insecure!|from|cd|wrap-cmd|mkfile|path-base|not)$")) |
| 35 | + |
| 36 | +(list . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$")) |
| 37 | +(cons . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$")) |
| 38 | + |
| 39 | +(list . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$")) |
| 40 | +(cons . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$")) |
| 41 | + |
| 42 | +(list . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$")) |
| 43 | +(cons . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$")) |
| 44 | + |
| 45 | + |
| 46 | +;; special cases |
| 47 | + |
| 48 | +; [a & b] highlights & as operator rather than a regular symbol |
| 49 | +(list (symbol) @operator (#match? @operator "&")) |
| 50 | +(cons (symbol) @operator (#match? @operator "&")) |
| 51 | + |
| 52 | +; (-> x y z) highlights first x as var, y z as function |
| 53 | +(list |
| 54 | + . |
| 55 | + (symbol) @function.macro |
| 56 | + (#eq? @function.macro "->") |
| 57 | + . |
| 58 | + (symbol) @variable.parameter |
| 59 | + (symbol) @function) |
| 60 | + |
| 61 | +; (-> 42 x y) highlights 42 as regular number |
| 62 | +(list |
| 63 | + . |
| 64 | + (symbol) @function.macro |
| 65 | + (#eq? @function.macro "->") |
| 66 | + . |
| 67 | + (_) |
| 68 | + (symbol) @function) |
| 69 | + |
| 70 | +;;; generic highlight rules |
| 71 | + |
| 72 | +; first symbol in a list form is a combiner call |
| 73 | +(list . (symbol) @function) |
| 74 | + |
| 75 | +; highlight symbols as vars only when they're clearly vars |
| 76 | +(cons (symbol) @variable) |
| 77 | +(scope (symbol) @variable) |
| 78 | +(subpath form: (symbol) @variable) |
| 79 | +(subbind form: (symbol) @variable) |
0 commit comments