peitalin / vim-jsx-typescript

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

Multiline Generic Declarations: Broken indentation + other problems #24

Open pappasam opened 4 years ago

pappasam commented 4 years ago

Thanks for this great plugin!

I've noticed that for users writing multi-line generics, the indentation inserts unnecessary characters. into the editor. There are obviously other problems here regarding multi-line / nested generics (notice that the syntax coloring is different that the single-line version), but please see below for a true workflow blocker. Any idea how to fix this?

GenericBugs

pappasam commented 4 years ago

I've fixed the annoying auto-insertion in my vimrc. This results from the fact that the vim "comments" option is never set. It defaults to treating ">" as a comment string. My hacky personal fix: set the value of "comments" to the same as C:

autocmd FileType typescript.tsx setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://

I recommend putting some thought into the ideal value for "comment" and providing that to users. If you want to use my example, by all means :smiley_cat:

Now, it'd be nice if we could fix the indentation of the closing ">" on multiline strings, and potentially fix the indentation of the closing ")". Not quite sure how to go about doing that.