Skip to content

Commit 185b77f

Browse files
committed
add bass language + highlighting
1 parent b5be72b commit 185b77f

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

languages.toml

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

runtime/queries/bass/highlights.scm

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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

Comments
 (0)