LoginSignup
3
1

More than 3 years have passed since last update.

coc-typescriptで最初に開いたtsxのファイルだけtsとして認識される問題の対処法

Posted at

vim起動後最初に開いたtsxのファイルだけtsとして認識されてしまい、正しくtsserverに解析されない問題が発生していた。

原因

vim側のfiletypetypescriptに設定されてしまっていた。
2ファイル目以降もtypescriptとして認識されていたが、いい感じに解析してくれていた。

対策

typescriptのハイライトをしてくれるleafgarland/typescript-vimfiletypetypescriptに設定していたので消去した。
ハイライトはmaxmellon/vim-jsx-prettyだけで十分してくれたので消しても問題なかった。

~/.config/nvim/init.vim に以下の設定を追記し、tsxfiletypetypescript.tsxとして認識されるようにする。

autocmd BufNewFile,BufRead *.tsx let b:tsx_ext_found = 1
autocmd BufNewFile,BufRead *.tsx set filetype=typescript.tsx

参考

https://github.com/neoclide/coc.nvim/issues/48
https://github.com/ianks/vim-tsx/blob/master/ftdetect/typescript.vim

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1