peitalin / vim-jsx-typescript

React JSX syntax highlighting for vim and Typescript
The Unlicense
305 stars 29 forks source link

Support for JSX generics #9

Closed lucasecdb closed 5 years ago

lucasecdb commented 5 years ago

The support for generics in JSX landed in TypeScript 2.9. I've tried implementing this, but the syntax definition in vim is really confusing. I got it working in a very basic scenario, but if the inner type has any arguments of it's own the angular brackets looks messed up.

This is how it looks without my changes

image

And with the changes I've made

image

As you can see, the second > is colored wrong, it should be a plain white color.

lucasecdb commented 5 years ago

Also, I forgot this but, the colors after the generics are also wrong, the initialValues prop should be colored with a light blue, but I don't know what I messed up

image

lucasecdb commented 5 years ago

So far, what I've done is create a tsxGenerics region like the following

syntax region tsxGenerics
    \ start=+<+
    \ end=+>+
    \ contained
    \ contains=Type

and add a nextgroup=tsxGenerics to the tsxTagName

peitalin commented 5 years ago

Thanks for letting me know, I've added a few updates to your definition. Let's see if it works on your end. image

Try adding this in your .vimrc to change the colors to your liking.

hi tsxTypeBraces guifg=#BDA7CC
hi tsxTypes guifg=#8D779C
lucasecdb commented 5 years ago

it worked! thanks @peitalin!