Skip to content

Commit ea25ed6

Browse files
authored
add bass language + highlighting (#3771)
1 parent 08937fc commit ea25ed6

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| astro || | | |
44
| awk ||| | `awk-language-server` |
55
| bash || | | `bash-language-server` |
6+
| bass || | | `bass` |
67
| beancount || | | |
78
| c |||| `clangd` |
89
| c-sharp ||| | `OmniSharp` |

languages.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,3 +1767,17 @@ indent = { tab-width = 2, unit = " " }
17671767
[[grammar]]
17681768
name = "astro"
17691769
source = { git = "https://github.com/virchau13/tree-sitter-astro", rev = "5f5c3e73c45967df9aa42f861fad2d77cd4e0900" }
1770+
1771+
[[language]]
1772+
name = "bass"
1773+
scope = "source.bass"
1774+
injection-regex = "bass"
1775+
file-types = ["bass"]
1776+
roots = []
1777+
comment-token = ";"
1778+
indent = { tab-width = 2, unit = " " }
1779+
language-server = { command = "bass", args = ["--lsp"] }
1780+
1781+
[[grammar]]
1782+
name = "bass"
1783+
source = { git = "https://github.com/vito/tree-sitter-bass", rev = "501133e260d768ed4e1fd7374912ed5c86d6fd90" }

runtime/queries/bass/highlights.scm

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
; GENERATED VIA https://github.com/vito/tree-sitter-bass
2+
3+
;;; comments
4+
5+
(comment) @comment.line
6+
7+
;;; punctuation
8+
9+
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
10+
11+
;;; constants
12+
13+
[(ignore) (null)] @constant.builtin
14+
15+
(bool) @constant.builtin.boolean
16+
17+
(int) @constant.numeric.integer
18+
19+
;;; strings
20+
21+
;; string literals
22+
23+
(string) @string
24+
(string (string_escape) @constant.character.escape)
25+
26+
;; keywords (symbol literals)
27+
28+
(keyword) @string.special.symbol
29+
30+
;; paths
31+
32+
(dot) @string.special.path
33+
(dotdot) @string.special.path
34+
(command) @string.special.path
35+
(subpath (symbol) @string.special.path)
36+
37+
; slashes in a path denote a combiner call
38+
(subpath (slash) @function)
39+
40+
41+
42+
;;; specific highlighting for builtins & special forms
43+
44+
;; symbol classification based highlighting
45+
46+
(list . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$"))
47+
(cons . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$"))
48+
49+
(list . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$"))
50+
(cons . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$"))
51+
52+
(list . (symbol) @label (#match? @label "^(def|defop|defn)$"))
53+
(cons . (symbol) @label (#match? @label "^(def|defop|defn)$"))
54+
55+
(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)$"))
56+
(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)$"))
57+
58+
(list . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$"))
59+
(cons . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$"))
60+
61+
(list . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$"))
62+
(cons . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$"))
63+
64+
(list . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$"))
65+
(cons . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$"))
66+
67+
68+
;; special cases
69+
70+
; [a & b] highlights & as operator rather than a regular symbol
71+
(list (symbol) @operator (#match? @operator "&"))
72+
(cons (symbol) @operator (#match? @operator "&"))
73+
74+
; (-> x y z) highlights first x as var, y z as function
75+
(list
76+
.
77+
(symbol) @function.macro
78+
(#eq? @function.macro "->")
79+
.
80+
(symbol) @variable.parameter
81+
(symbol) @function)
82+
83+
; (-> 42 x y) highlights 42 as regular number
84+
(list
85+
.
86+
(symbol) @function.macro
87+
(#eq? @function.macro "->")
88+
.
89+
(_)
90+
(symbol) @function)
91+
92+
;;; generic highlighting for all forms
93+
94+
; first symbol in a list form is a combiner call
95+
(list . (symbol) @function)
96+
97+
; highlight symbols as vars only when they're clearly vars
98+
(cons (symbol) @variable)
99+
(scope (symbol) @variable)
100+
(path form: (symbol) @variable)
101+
(symbind form: (symbol) @variable)

0 commit comments

Comments
 (0)