build(tree-sitter): update javascript, typescript and tsx (#7852)

* build(tree-sitter): update javascript, typescript and tsx

* update revision of tree-sitter parsers for these languages.
* rename `?.` to `optional_chain`, introduced in tree-sitter/tree-sitter-javascript@186f2adbf7.

* fix(highlight): change jsx queries to match latest tree-sitter

Latest tree-sitter/tree-sitter-javascript@bb1f97b643 added some breaking changes that broke highlighting.
* Remove some queries with `nested_identifier`.
* Remove deprecated `jsx_fragment` from indent query.
* Count `</` and `/>` as a single token.
This commit is contained in:
woojiq 2023-08-07 22:07:56 +03:00 committed by GitHub
parent 7af37bb3b9
commit 7cda5b8592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 20 deletions

View File

@ -563,7 +563,7 @@ args = { program = "{0}" }
[[grammar]] [[grammar]]
name = "javascript" name = "javascript"
source = { git = "https://github.com/tree-sitter/tree-sitter-javascript", rev = "4a95461c4761c624f2263725aca79eeaefd36cad" } source = { git = "https://github.com/tree-sitter/tree-sitter-javascript", rev = "f772967f7b7bc7c28f845be2420a38472b16a8ee" }
[[language]] [[language]]
name = "jsx" name = "jsx"
@ -590,7 +590,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "typescript" name = "typescript"
source = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259", subpath = "typescript" } source = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "b1bf4825d9eaa0f3bdeb1e52f099533328acfbdf", subpath = "typescript" }
[[language]] [[language]]
name = "tsx" name = "tsx"
@ -604,7 +604,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "tsx" name = "tsx"
source = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259", subpath = "tsx" } source = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "b1bf4825d9eaa0f3bdeb1e52f099533328acfbdf", subpath = "tsx" }
[[language]] [[language]]
name = "css" name = "css"

View File

@ -4,9 +4,6 @@
(jsx_opening_element ((identifier) @constructor (jsx_opening_element ((identifier) @constructor
(#match? @constructor "^[A-Z]"))) (#match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - <My.Component>
(jsx_opening_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
(jsx_opening_element (identifier) @tag) (jsx_opening_element (identifier) @tag)
; Closing elements ; Closing elements
@ -15,9 +12,6 @@
(jsx_closing_element ((identifier) @constructor (jsx_closing_element ((identifier) @constructor
(#match? @constructor "^[A-Z]"))) (#match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - </My.Component>
(jsx_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
(jsx_closing_element (identifier) @tag) (jsx_closing_element (identifier) @tag)
; Self-closing elements ; Self-closing elements
@ -26,9 +20,6 @@
(jsx_self_closing_element ((identifier) @constructor (jsx_self_closing_element ((identifier) @constructor
(#match? @constructor "^[A-Z]"))) (#match? @constructor "^[A-Z]")))
; Handle the dot operator effectively - <My.Component />
(jsx_self_closing_element ((nested_identifier (identifier) @tag (identifier) @constructor)))
(jsx_self_closing_element (identifier) @tag) (jsx_self_closing_element (identifier) @tag)
; Attributes ; Attributes
@ -39,17 +30,14 @@
; Punctuation ; Punctuation
; ----------- ; -----------
; Handle attribute delimiter ; Handle attribute delimiter (<Component color="red"/>)
(jsx_attribute "=" @punctuation.delimiter) (jsx_attribute "=" @punctuation.delimiter)
; <Component> ; <Component>
(jsx_opening_element ["<" ">"] @punctuation.bracket) (jsx_opening_element ["<" ">"] @punctuation.bracket)
; </Component> ; </Component>
(jsx_closing_element ["<" "/" ">"] @punctuation.bracket) (jsx_closing_element ["</" ">"] @punctuation.bracket)
; <Component /> ; <Component />
(jsx_self_closing_element ["<" "/" ">"] @punctuation.bracket) (jsx_self_closing_element ["<" "/>"] @punctuation.braket)
; <> ... </>
(jsx_fragment ["<" "/" ">"] @punctuation.bracket)

View File

@ -1,5 +1,4 @@
[ [
(jsx_fragment)
(jsx_element) (jsx_element)
(jsx_self_closing_element) (jsx_self_closing_element)
] @indent ] @indent

View File

@ -109,7 +109,7 @@
[ [
";" ";"
"?." (optional_chain) ; ?.
"." "."
"," ","
] @punctuation.delimiter ] @punctuation.delimiter