Skip to content

Commit

Permalink
update to newest rescript treesitter library and queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Freddie Ridell authored and FreddieGilbraith committed Jul 20, 2024
1 parent c9b4840 commit e603634
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 24 deletions.
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "rescript"
source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "467dcf99f68c47823d7b378779a6b282d7ef9782" }
source = { git = "https://github.com/rescript-lang/tree-sitter-rescript", rev = "5e2a44a9d886b0a509f5bfd0437d33b4871fbac5" }

[[language]]
name = "erlang"
Expand Down
31 changes: 18 additions & 13 deletions runtime/queries/rescript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
[
(type_identifier)
(unit_type)
(list)
(list_pattern)
] @type

(list ["list{" "}"] @type)
(list_pattern ["list{" "}"] @type)

[
(variant_identifier)
(polyvar_identifier)
Expand Down Expand Up @@ -72,22 +71,24 @@
; single parameter with no parens
(function parameter: (value_identifier) @variable.parameter)

; first-level descructuring (required for nvim-tree-sitter as it only matches direct
; children and the above patterns do not match destructuring patterns in NeoVim)
(parameter (tuple_pattern (tuple_item_pattern (value_identifier) @variable.parameter)))
(parameter (array_pattern (value_identifier) @variable.parameter))
(parameter (record_pattern (value_identifier) @variable.parameter))

; Meta
;-----

[
"@"
"@@"
(decorator_identifier)
] @keyword.directive
(decorator_identifier) @keyword.directive

(extension_identifier) @keyword
("%") @keyword

; Misc
;-----

; (subscript_expression index: (string) @attribute)
(subscript_expression index: (string) @attribute)
(polyvar_type_pattern "#" @constant)

[
Expand All @@ -101,18 +102,21 @@
"external"
"let"
"module"
"mutable"
"private"
"rec"
"type"
"and"
"assert"
"async"
"await"
"with"
"unpack"
] @keyword.storage.type
"lazy"
"constraint"
] @keyword

((function "async" @keyword.storage))

"mutable" @keyword.storage.modifier
(module_unpack "unpack" @keyword)

[
"if"
Expand Down Expand Up @@ -169,6 +173,7 @@
"->"
"|>"
":>"
"+="
(uncurry)
] @operator

Expand Down
33 changes: 27 additions & 6 deletions runtime/queries/rescript/injections.scm
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
((comment) @injection.content
(#set! injection.language "comment"))
((comment) @injection.content (#set! injection.language "comment"))

((raw_js) @injection.content
(#set! injection.language "javascript"))
; %re
(extension_expression
(extension_identifier) @_name
(#eq? @_name "re")
(expression_statement (_) @injection.content (#set! injection.language "regex")))

; %raw
(extension_expression
(extension_identifier) @_name
(#eq? @_name "raw")
(expression_statement
(_ (_) @injection.content (#set! injection.language "javascript"))))

; %graphql
(extension_expression
(extension_identifier) @_name
(#eq? @_name "graphql")
(expression_statement
(_ (_) @injection.content (#set! injection.language "graphql"))))

; %relay
(extension_expression
(extension_identifier) @_name
(#eq? @_name "relay")
(expression_statement
(_ (_) @injection.content (#set! injection.language "graphql") )))

((raw_gql) @injection.content
(#set! injection.language "graphql"))
6 changes: 3 additions & 3 deletions runtime/queries/rescript/locals.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(switch_expression) @local.scope
(if_expression) @local.scope

; Definitions
;------------
(type_declaration) @local.defintion
(let_binding) @local.defintion
(type_declaration) @local.definition
(let_binding) @local
(module_declaration) @local.namespace
2 changes: 1 addition & 1 deletion runtime/queries/rescript/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; Classes (modules)
;------------------

(module_declaration definition: ((_) @class.inside)) @class.around
(module_binding definition: ((_) @class.inside)) @class.around

; Blocks
;-------
Expand Down

0 comments on commit e603634

Please sign in to comment.