Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsuquyomi is not enabled for TS files with JSX in vim 8.2 #300

Open
willdurand opened this issue Dec 17, 2019 · 4 comments
Open

tsuquyomi is not enabled for TS files with JSX in vim 8.2 #300

willdurand opened this issue Dec 17, 2019 · 4 comments

Comments

@willdurand
Copy link

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.

@willdurand willdurand changed the title tsuquyomi is not enabled in vim 8.2 tsuquyomi is not enabled for TS files with JSX in vim 8.2 Dec 17, 2019
@greenymcgee
Copy link

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.

@Narsil
Copy link

Narsil commented Jan 15, 2020

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

@greenymcgee
Copy link

I’ve been using your script all day @Narsil! It’s a great temporary fix and has definitely saved me some time today.

@willfrew
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants