Skip to content

Commit 46c8c80

Browse files
committed
fix(treesitter): JSX/TSX tags are missing highlights
Fixes: #360
1 parent 6025b63 commit 46c8c80

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic
66

77
## [unreleased]
88

9+
### Issues Fix
10+
11+
- Fixed JSX/TSX tags are missing highlights with nvim 0.10 (#360)
12+
913
## [v1.1.2] - 05 August 2024
1014

1115
_This release contains a crucial ***hotfix*** for a bug that prevented the ability to

lua/github-theme/group/modules/treesitter.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch
188188
--- XML Tags -----------------------------------------------------------------------------
189189

190190
['@tag'] = { fg = syn.tag }, -- Tags like HTML tag names
191+
['@tag.builtin'] = { link = '@tag' }, -- Tags, but only non-user-defined ones (e.g. `<a>`)
191192
['@tag.attribute'] = { link = '@variable.member' }, -- Tag attributes (e.g. HTML element attributes)
192193
['@tag.delimiter'] = FALLBACK_OR_NONE, -- Tag delimiter like `<`, `>`, `/`, etc.
193194

@@ -252,8 +253,8 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch
252253
-- ['@variable.javascript'] = { link = '@constant' },
253254

254255
-- JSX/TSX
255-
['@tag.javascript'] = FALLBACK_OR_NONE,
256-
['@tag.tsx'] = FALLBACK_OR_NONE,
256+
['@tag.javascript'] = { link = '@type.javascript' },
257+
['@tag.tsx'] = { link = '@type.tsx' },
257258
['@tag.delimiter.javascript'] = { link = '@tag.attribute.javascript' },
258259
['@tag.delimiter.tsx'] = { link = '@tag.attribute.tsx' },
259260

queries/ecma/highlights.scm

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
;; extends
2+
3+
; These fix an nvim-treesitter bug where the `Abc` in `Abc.Xyz` is captured as a
4+
; builtin tag. They also change the capture for `Xyz` to `@variable.member`
5+
; instead of e.g. `@tag` (which gives the property a different color).
6+
(jsx_opening_element
7+
name: (member_expression
8+
; If the tag name contains a dot (operator), it must always be a custom
9+
; tag? Therefore, we're not even going to try matching a `@tag.builtin`
10+
; here.
11+
object: (identifier) @tag (#set! "priority" 115)
12+
property: (property_identifier) @variable.member (#set! "priority" 115)))
13+
14+
(jsx_closing_element
15+
name: (member_expression
16+
object: (identifier) @tag (#set! "priority" 115)
17+
property: (property_identifier) @variable.member (#set! "priority" 115)))
18+
19+
(jsx_self_closing_element
20+
name: (member_expression
21+
object: (identifier) @tag (#set! "priority" 115)
22+
property: (property_identifier) @variable.member (#set! "priority" 115)))

0 commit comments

Comments
 (0)