Skip to content

Commit

Permalink
Improve wren support (helix-editor#7819)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jummit authored and Schuyler Mortimer committed Jul 10, 2024
1 parent 9d08e82 commit 21b5a2b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 6 deletions.
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
| webc || | | |
| wgsl || | | `wgsl_analyzer` |
| wit || || |
| wren ||| | |
| wren ||| | |
| xit || | | |
| xml || || |
| yaml || || `yaml-language-server` |
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2704,7 +2704,7 @@ grammar = "html"

[[grammar]]
name = "wren"
source = { git = "https://git.sr.ht/~jummit/tree-sitter-wren", rev = "7f576e8ccadac226f6a37cbefe95be3fee9f0a66"}
source = { git = "https://git.sr.ht/~jummit/tree-sitter-wren", rev = "793d58266924e6efcc40e411663393e9d72bec87"}

[[language]]
name = "wren"
Expand Down
10 changes: 6 additions & 4 deletions runtime/queries/wren/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
((identifier) @variable.builtin
((name) @variable.builtin
(#match? @variable.builtin "^(Bool|Class|Fiber|Fn|List|Map|Null|Num|Object|Range|Sequence|String|System)$"))

(call_expression
(identifier) @function)
(name) @function)

(method_definition
(identifier) @function.method)
(name) @function.method)

((parameter) @variable.parameter)

(comment) @comment
(string) @string
(raw_string) @string
(number) @constant.numeric.integer
(identifier) @variable
(name) @variable
(field) @variable
(static_field) @variable
(null) @constant.builtin
(boolean) @constant.builtin.boolean

Expand Down
29 changes: 29 additions & 0 deletions runtime/queries/wren/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
(list)
(map)
(call_body)
(parameter_list)
(call_expression)
(getter_definition)
(setter_definition)
(prefix_operator_definition)
(subscript_operator_definition)
(subscript_setter_definition)
(infix_operator_definition)
(method_definition)
(constructor)
(static_method_definition)
(static_getter_definition)
(attribute)
(conditional)
(class_body)
(if_statement)
(for_statement)
(while_statement)
] @indent

[
"}"
"]"
")"
] @outdent
3 changes: 3 additions & 0 deletions runtime/queries/wren/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
((comment) @injection.content
(#set! injection.language "comment")
(#set! injection.include-children))
21 changes: 21 additions & 0 deletions runtime/queries/wren/locals.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
(method_definition)
] @local.scope

(name) @local.reference
(field) @local.reference
(static_field) @local.reference

(for_statement
loop_variable: (name) @local.definition)

(variable_definition
name: (name) @local.definition)

(assignment
left: (field) @local.definition)

(assignment
left: (static_field) @local.definition)

(parameter) @local.definition
4 changes: 4 additions & 0 deletions runtime/queries/wren/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
(class_definition
(class_body) @class.inside) @class.around

(call_expression
(call_body
(_) @function.inside) @function.around)

(method_definition
body: (_) @function.inside) @function.around

Expand Down

0 comments on commit 21b5a2b

Please sign in to comment.