Dalius's blog

Monday, January 6, 2020

Goodbye Nvim-Typescript

UPDATE 2021-07-19: Check “Typescript and ALE” for a more up-to-date information.

Until now I was using nvim-typscript plugin for Typescript development. However the most recent version became unusable and nvim-typescript author seems to be focused on other projects (he is active in github but this project gets less of his attention).

Yes, I know it is open source and I could have fixed the problems potentially myself. Actually, I have even tried to create pull request to solve one of the problems but Mike addressed the same problem in another pull request… and then stopped working on it.

I still think that Mike did amazing job on nvim-typescript and I might come back to nvim-typescript in the future if the need arises. However now I have found that ALE and other plugins can do everything what I need.

There are several reasons why I was using nvim-typescript. Here I will address my use cases one by one and how I address them.

Auto-complete - it looks like ALE supports tsserver and auto-complete works out of the box. Nothing extra to configure.

Import - this one is a little bit trickier. As I’m using ctags anyway, I have started using kristijanhusak/vim-js-file-import for imports.

As well ALE seems to have tsserver autoimport (not sure how that works):

let g:ale_completion_tsserver_autoimport = 1

Go to definition

In nvim-typescript we have command TSDef. ALE has ALEGoToDefinition that works with tsserver as well. I am using mappings that override my tags mappings:

autocmd FileType typescript map <buffer> <leader>d g<c-]>
autocmd FileType typescriptreact map <buffer> <leader>d g<c-]>

autocmd FileType typescript map <buffer> <c-]> :ALEGoToDefinition<cr>
autocmd FileType typescriptreact <buffer> <c-]> :ALEGoToDefinition<cr>

Getting type of variable

Sometimes you want to see if typescript gets the type of variable under cursor correctly. In nvim-typescript TSType command and ALE has ALEHover command:

autocmd FileType typescript map <buffer> <leader>t :ALEHover<cr>
autocmd FileType typescriptreact map <buffer> <leader>t :ALEHover<cr>

I’m still missing some minor functionality but I think this will be fixed in the future as ALE has issue for code actions: https://github.com/dense-analysis/ale/issues/1466

That’s it for now.