Skip to content

Commit

Permalink
Add initial support for SuperCollider
Browse files Browse the repository at this point in the history
  • Loading branch information
pnelson committed Jan 13, 2024
1 parent 17dd102 commit 51767ce
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
| sshclientconfig || | | |
| starlark ||| | |
| strace || | | |
| supercollider || || |
| svelte || || `svelteserver` |
| sway |||| `forc` |
| swift || | | `sourcekit-lsp` |
Expand Down
12 changes: 12 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3027,3 +3027,15 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "hocon"
source = { git = "https://github.com/antosha417/tree-sitter-hocon", rev = "c390f10519ae69fdb03b3e5764f5592fb6924bcc" }

[[language]]
name = "supercollider"
scope = "source.supercollider"
injection-regex = "supercollider"
file-types = ["scd", "sc", "quark"]
comment-token = "//"
indent = { tab-width = 4, unit = "\t" }

[[grammar]]
name = "supercollider"
source = { git = "https://github.com/madskjeldgaard/tree-sitter-supercollider", rev = "3b35bd0fded4423c8fb30e9585c7bacbcd0e8095" }
7 changes: 7 additions & 0 deletions runtime/queries/supercollider/folds.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
(function_call)
(code_block)
(function_block)
(control_structure)
] @fold

101 changes: 101 additions & 0 deletions runtime/queries/supercollider/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
; highlights.scm
; See this for full list: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md

; comments
(line_comment) @comment
(block_comment) @comment

; Argument definition
(argument name: (identifier) @parameter)

; Variables
(local_var name: (identifier) @variable)
(environment_var name:(identifier) @variable.builtin)
(builtin_var) @constant.builtin

; (variable) @variable

; Functions
(function_definition
name: (variable) @function)

; For function calls
(named_argument
name: (identifier) @property)

; Methods
(method_call
name: (method_name) @method)

; Classes
(class) @type

; Literals
(number) @number
;(pi_statement) @constant.builtin
(float) @float

(string) @string
(symbol) @string.special

; Operators
[
"&&"
"||"
"&"
"|"
"^"
"=="
"!="
"<"
"<="
">"
">="
"<<"
">>"
"+"
"-"
"*"
"/"
"%"
"="
"|@|"
"@@"
"@|@"
] @operator

; Keywords
[
"arg"
"classvar"
"const"
; "super"
; "this"
"var"
] @keyword

; Brackets
[
"("
")"
"["
"]"
"{"
"}"
"|"
] @punctuation.bracket

; Delimeters
[
";"
"."
","
] @punctuation.delimiter

; control structure
(control_structure) @conditional

(escape_sequence) @string.special

; SinOsc.ar()!2
(duplicated_statement) @repeat
31 changes: 31 additions & 0 deletions runtime/queries/supercollider/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
(function_block)
(binary_expression)
(collection)
(indexed_collection)
(parameter_call_list)
(function_call)
(class_def)
(classvar)
(const)
(instance_var)
(variable_definition)
(variable_definition_sequence (variable_definition))
(control_structure)
(return_statement)
] @indent

[
(parameter_call_list (argument_calls))
"("
")"
"{"
"}"
"["
"]"
] @branch

[
(block_comment)
(line_comment)
] @ignore
27 changes: 27 additions & 0 deletions runtime/queries/supercollider/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; Scopes
[
(function_call)
(code_block)
(function_block)
(control_structure)
] @scope

; Definitions
(argument
name: (identifier) @definition.parameter
(set! "definition.var.scope" "local")
)

(variable_definition
name: (variable (local_var (identifier) @definition.var
)))

(variable_definition
name: (variable (environment_var (identifier) @definition.var))
(set! "definition.var.scope" "global"))

(function_definition name: (variable) @definition.var
(set! "definition.var.scope" "parent")
)

(identifier) @reference

0 comments on commit 51767ce

Please sign in to comment.