Open noahbrenner opened 2 years ago
I'm also running into this.
Here's a hacky one-line patch to broaden it to at least accept [A-Z]
instead of just T
:
diff --git a/after/syntax/jsx_pretty.vim b/after/syntax/jsx_pretty.vim
index 74b200c..71e97d3 100644
--- a/after/syntax/jsx_pretty.vim
+++ b/after/syntax/jsx_pretty.vim
@@ -3,5 +3,5 @@ let s:highlight_close_tag = get(g:, 'vim_jsx_pretty_highlight_close_tag', 0)
" detect jsx region
syntax region jsxRegion
- \ start=+\%(\%(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\%(>\|\z(\%(script\|\s*\<T\>\)\@!\<[_$A-Za-z][-:._$A-Za-z0-9]*\>\)\%(\_s*\%([-+*)\]}&|?,]\|/\%([/*]\|\_s*>\)\@!\)\)\@!\)+
+ \ start=+\%(\%(\_[([,?:=+\-*/>{}]\|<\s\+\|&&\|||\|=>\|\<return\|\<default\|\<await\|\<yield\)\_s*\)\@<=<\_s*\%(>\|\z(\%(script\|\s*\<[A-Z]\>\)\@!\<[_$A-Za-z][-:._$A-Za-z0-9]*\>\)\%(\_s*\%([-+*)\]}&|?,]\|/\%([/*]\|\_s*>\)\@!\)\)\@!\)+
\ end=++
\ contains=jsxElement
I'm running into inconsistencies in highlighting between
ft=typescript
andft=typescriptreact
.I'm using
yats.vim
,vim-javascript
, and of coursevim-jsx-pretty
, all just updated usingvim-plug
.Some example code:
When filetype is
typescript
:When filetype is
typescriptreact
:Surprisingly (to me :smile:), the behavior is affected by the name of the generic variable. If I use
T
instead ofK
, I get this:For simple generics, I can get away with just using
T
for now, but that's not always the best type variable to use, doesn't cover functions that need more than one generic parameter, and is still missing highlighting for the type parameters themselves.