tsuquyomi is not enabled for TS files with JSX in vim 8.2
willdurand opened this issue · comments
In vim 8.2, a new built-in filetype for TypeScript files has been added according to this issue: vim/vim#4830. The new file type is typescriptreact
.
Files previously detected as typescript
are now detected as typescriptreact
. This causes the tsuquyomi plugin to remain disabled when editing a file in a react-based project (for instance).
My current workaround is to force the filetype to be set to typescript
:
" ftplugin/typescriptreact.vim
"
" This is needed because tsuquyomi does not seem to support the
" `typescriptreact` filetype.
set ft=typescript
That being said, this is a workaround and it'd be nice if this plugin could support the new filetype.
I'm experiencing this as well. I currently have to set my .tsx
files to a filetype of javascript
or my syntax highlighting mostly disappears in .tsx
files. This leads to Tsu commands not working until I run :set ft=typescript
, and then I immediately run set ft=javascript
again to get sort of decent syntax highlighting. The syntax highlighting is a totally different issue, but combined with this it creates some real issues for me.
I can confirm it's quite annoying
For a full workaround I personnally added in my .vimrc
.
augroup typescriptreact
au!
autocmd BufNewFile,BufRead *.tsx set filetype=typescript
autocmd BufNewFile,BufRead *.tsx set filetype=javascript
augroup END
I’ve been using your script all day @Narsil! It’s a great temporary fix and has definitely saved me some time today.
Thanks for the config @Narsil! I still had a few extra difficulties with syntax highlighting and type checking, specifically when switching between .tsx and .ts files, so in case anyone else is having issues, this worked better for me:
augroup typescript
au!
autocmd BufNewFile,BufRead *.tsx set filetype=typescript
autocmd BufNewFile,BufRead *.tsx set syntax=typescriptreact
autocmd BufNewFile,BufRead *.ts set filetype=typescript
autocmd BufNewFile,BufRead *.ts set syntax=javascript
augroup END
Note: I'm using leafgarland/typescript-vim for syntax highlighting so if you're using something else, it might behave differently.