Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bass language + highlighting #3771

Merged
merged 3 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
| astro | ✓ | | | |
| awk | ✓ | ✓ | | `awk-language-server` |
| bash | ✓ | | | `bash-language-server` |
| bass | ✓ | | | `bass` |
| beancount | ✓ | | | |
| c | ✓ | ✓ | ✓ | `clangd` |
| c-sharp | ✓ | ✓ | | `OmniSharp` |
Expand Down
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1766,3 +1766,17 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "astro"
source = { git = "https://github.com/virchau13/tree-sitter-astro", rev = "5f5c3e73c45967df9aa42f861fad2d77cd4e0900" }

[[language]]
name = "bass"
scope = "source.bass"
injection-regex = "bass"
file-types = ["bass"]
roots = []
comment-token = ";"
indent = { tab-width = 2, unit = " " }
language-server = { command = "bass", args = ["--lsp"] }

[[grammar]]
name = "bass"
source = { git = "https://github.com/vito/tree-sitter-bass", rev = "333dc1365535d12d94f83d409304fb433c5e3800" }
79 changes: 79 additions & 0 deletions runtime/queries/bass/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
; GENERATED VIA https://github.com/vito/tree-sitter-bass

(comment) @comment.line

["(" ")" "[" "]" "{" "}"] @punctuation.bracket

[(ignore) (null) (bool)] @constant.builtin
vito marked this conversation as resolved.
Show resolved Hide resolved

(int) @constant.numeric
vito marked this conversation as resolved.
Show resolved Hide resolved

(string (string_escape) @constant.character.escape)

(string) @string

[(command) (path) (relpath)] @namespace
vito marked this conversation as resolved.
Show resolved Hide resolved

(keyword) @string.special.symbol


;;; specific queries take precedence

;; classification based highlighting

(list . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$"))
(cons . (symbol) @keyword.control.conditional (#match? @keyword.control.conditional "^(if|case|cond|when)$"))

(list . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$"))
(cons . (symbol) @keyword.control.repeat (#match? @keyword.control.repeat "^(each)$"))

(list . (symbol) @label (#match? @label "^(def|defop|defn)$"))
(cons . (symbol) @label (#match? @label "^(def|defop|defn)$"))

(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)$"))
(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)$"))

(list . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$"))
(cons . (symbol) @function.macro (#match? @function.macro "^(op|fn|current-scope|quote|let|provide|module|or|and|->|curryfn|for|\\$|linux)$"))

(list . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$"))
(cons . (symbol) @keyword.builtin (#match? @keyword.builtin "^(do|doc)$"))

(list . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$"))
(cons . (symbol) @keyword.control.import (#match? @keyword.control.import "^(use|import|load)$"))


;; special cases

; [a & b] highlights & as operator rather than a regular symbol
(list (symbol) @operator (#match? @operator "&"))
(cons (symbol) @operator (#match? @operator "&"))

; (-> x y z) highlights first x as var, y z as function
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(symbol) @variable.parameter
(symbol) @function)

; (-> 42 x y) highlights 42 as regular number
(list
.
(symbol) @function.macro
(#eq? @function.macro "->")
.
(_)
(symbol) @function)

;;; generic highlight rules

; first symbol in a list form is a combiner call
(list . (symbol) @function)

; highlight symbols as vars only when they're clearly vars
(cons (symbol) @variable)
(scope (symbol) @variable)
(subpath form: (symbol) @variable)
(subbind form: (symbol) @variable)