Vim plugin to run tradeship, which automatically imports missing JS dependencies and removes unused ones.
Ensure you have tradeship installed:
$ npm install -g tradeship
# or use yarn:
$ yarn global add tradeship
Install tradeship-vim with your favorite package manager. For
vim-plug, add this to your ~/.vimrc
:
Plug 'karthikv/tradeship-vim'
And then run :PlugInstall
.
To run tradeship, you may either:
-
Execute
:Tradeship
-
To run on save, add the following to your
~/.vimrc
:autocmd BufWritePre *.js,*.jsx Tradeship
-
To run using a keyboard shortcut (e.g. ctrl + alt + i), add the following to your
~/.vimrc
:nnoremap <C-A-i> :Tradeship<CR>
The first time tradeship runs in a project directory with many JavaScript files, it'll take some time to parse and cache dependencies. Future runs will be much faster.