Upgrade rescript tree sitter & highlights (#4356)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
Jared Ramirez 2022-10-20 14:30:16 -07:00 committed by GitHub
parent eee8362015
commit de607830a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 169 additions and 24 deletions

View File

@ -1140,7 +1140,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "rescript" name = "rescript"
source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "4cd7ba91696886fdaca086fb32b5fd8cc294a129" } source = { git = "https://github.com/jaredramirez/tree-sitter-rescript", rev = "65609807c628477f3b94052e7ef895885ac51c3c" }
[[language]] [[language]]
name = "erlang" name = "erlang"

View File

@ -10,20 +10,23 @@
[ [
(type_identifier) (type_identifier)
(unit_type) (unit_type)
"list"
] @type ] @type
(list ["list{" "}"] @type)
(list_pattern ["list{" "}"] @type)
[ [
(variant_identifier) (variant_identifier)
(polyvar_identifier) (polyvar_identifier)
] @constant ] @constructor
(property_identifier) @variable.other.member (record_type_field (property_identifier) @type)
(object_type (field (property_identifier) @type))
(record_field (property_identifier) @variable.other.member)
(object (field (property_identifier) @variable.other.member))
(member_expression (property_identifier) @variable.other.member)
(module_identifier) @namespace (module_identifier) @namespace
(jsx_identifier) @tag
(jsx_attribute (property_identifier) @variable.parameter)
; Parameters ; Parameters
;---------------- ;----------------
@ -42,8 +45,8 @@
"${" @punctuation.bracket "${" @punctuation.bracket
"}" @punctuation.bracket) @embedded "}" @punctuation.bracket) @embedded
(character) @constant.character (character) @string.special
(escape_sequence) @constant.character.escape (escape_sequence) @string.special
; Other literals ; Other literals
;--------------- ;---------------
@ -60,11 +63,13 @@
; Functions ; Functions
;---------- ;----------
; parameter(s) in parens
[ [
(formal_parameters (value_identifier)) (parameter (value_identifier))
(labeled_parameter (value_identifier)) (labeled_parameter (value_identifier))
] @variable.parameter ] @variable.parameter
; single parameter with no parens
(function parameter: (value_identifier) @variable.parameter) (function parameter: (value_identifier) @variable.parameter)
; Meta ; Meta
@ -74,7 +79,7 @@
"@" "@"
"@@" "@@"
(decorator_identifier) (decorator_identifier)
] @label ] @keyword.directive
(extension_identifier) @keyword (extension_identifier) @keyword
("%") @keyword ("%") @keyword
@ -82,13 +87,13 @@
; Misc ; Misc
;----- ;-----
(subscript_expression index: (string) @variable.other.member) ; (subscript_expression index: (string) @attribute)
(polyvar_type_pattern "#" @constant) (polyvar_type_pattern "#" @constant)
[ [
("include") ("include")
("open") ("open")
] @keyword ] @keyword.control.import
[ [
"as" "as"
@ -96,25 +101,43 @@
"external" "external"
"let" "let"
"module" "module"
"mutable"
"private" "private"
"rec" "rec"
"type" "type"
"and" "and"
] @keyword "assert"
"async"
"await"
"with"
"unpack"
] @keyword.storage.type
"mutable" @keyword.storage.modifier
[ [
"if" "if"
"else" "else"
"switch" "switch"
] @keyword "when"
] @keyword.control.conditional
[ [
"exception" "exception"
"try" "try"
"catch" "catch"
"raise" ] @keyword.control.exception
] @keyword
(call_expression
function: (value_identifier) @keyword.control.exception
(#eq? @keyword.control.exception "raise"))
[
"for"
"in"
"to"
"downto"
"while"
] @keyword.control.conditional
[ [
"." "."
@ -129,17 +152,15 @@
"-" "-"
"-." "-."
"*" "*"
"**"
"*." "*."
"/"
"/." "/."
"<"
"<=" "<="
"==" "=="
"===" "==="
"!" "!"
"!=" "!="
"!==" "!=="
">"
">=" ">="
"&&" "&&"
"||" "||"
@ -151,6 +172,10 @@
(uncurry) (uncurry)
] @operator ] @operator
; Explicitly enclose these operators with binary_expression
; to avoid confusion with JSX tag delimiters
(binary_expression ["<" ">" "/"] @operator)
[ [
"(" "("
")" ")"
@ -172,7 +197,24 @@
"~" "~"
"?" "?"
"=>" "=>"
".."
"..." "..."
] @punctuation ] @punctuation.special
(ternary_expression ["?" ":"] @operator) (ternary_expression ["?" ":"] @operator)
; JSX
;----------
(jsx_identifier) @tag
(jsx_element
open_tag: (jsx_opening_element ["<" ">"] @punctuation.special))
(jsx_element
close_tag: (jsx_closing_element ["<" "/" ">"] @punctuation.special))
(jsx_self_closing_element ["/" ">" "<"] @punctuation.special)
(jsx_fragment [">" "<" "/"] @punctuation.special)
(jsx_attribute (property_identifier) @attribute)
; Error
;----------
(ERROR) @keyword.control.exception

View File

@ -0,0 +1,7 @@
(switch_expression) @local.scope
(if_expression) @local.scope
; Definitions
;------------
(type_declaration) @local.defintion
(let_binding) @local.defintion

View File

@ -3,14 +3,110 @@
(module_declaration definition: ((_) @class.inside)) @class.around (module_declaration definition: ((_) @class.inside)) @class.around
; Blocks
;-------
(block (_) @function.inside) @function.around
; Functions ; Functions
;---------- ;----------
(function body: (_) @function.inside) @function.around (function body: (_) @function.inside) @function.around
; Calls
;------
(call_expression arguments: ((_) @parameter.inside)) @parameter.around
; Comments ; Comments
;--------- ;---------
(comment) @comment.inside (comment) @comment.inside
(comment)+ @comment.around (comment)+ @comment.around
; Parameters
;-----------
(function parameter: (_) @parameter.inside @parameter.around)
(formal_parameters
","
. (_) @parameter.inside
@parameter.around)
(formal_parameters
. (_) @parameter.inside
. ","?
@parameter.around)
(arguments
"," @_arguments_start
. (_) @parameter.inside
@parameter.around)
(arguments
. (_) @parameter.inside
. ","?
@parameter.around)
(function_type_parameters
","
. (_) @parameter.inside
@parameter.around)
(function_type_parameters
. (_) @parameter.inside
. ","?
@parameter.around)
(functor_parameters
","
. (_) @parameter.inside
@parameter.around)
(functor_parameters
. (_) @parameter.inside
. ","?
@parameter.around)
(type_parameters
","
. (_) @parameter.inside
@parameter.around)
(type_parameters
. (_) @parameter.inside
. ","?
@parameter.around)
(type_arguments
","
. (_) @parameter.inside
@parameter.around)
(type_arguments
. (_) @parameter.inside
. ","?
@parameter.around)
(decorator_arguments
","
. (_) @parameter.inside
@parameter.around)
(decorator_arguments
. (_) @parameter.inside
. ","?
@parameter.around)
(variant_parameters
","
. (_) @parameter.inside
@parameter.around)
(variant_parameters
. (_) @parameter.inside
. ","?
@parameter.around)
(polyvar_parameters
","
. (_) @parameter.inside
@parameter.around)
(polyvar_parameters
. (_) @parameter.inside
. ","?
@parameter.around)