moll / vim-node

Tools and environment to make Vim superb for developing with Node.js. Like Rails.vim for Node.
http://www.vim.org/scripts/script.php?script_id=4674
Other
807 stars 59 forks source link

Shortcut for installing npm package `require()` #28

Open gillescastel opened 8 years ago

gillescastel commented 8 years ago

It would be nice to install npm packages within vim. E.g.

var foo = require('body-parser');

When I press the shortcut anywhere on this line, it would execute npm install --save body-parser.

Would that be possible and doable?

chemzqm commented 8 years ago

It would be terrible if the install process is not async.

tandrewnichols commented 8 years ago

If you use Vimux (vim+tmux), you can do this with something like:

"Or <leader>npm or whatever you prefer
nnoremap <leader>i :exec ":call VimuxRunCommand('npm i --save '.expand('<cword>'))"<CR>

If you don't use tmux, maybe you can adapt that to do what you need. I agree that the install not being async is a deal breaker.

gillescastel commented 8 years ago

I use tmux, and I think that your solution is great!

If the installation is sync, but the progress bar etc is shown (which is the case when vim is used in the terminal), then I don't think this is really a deal breaker.

recording1454611266

Anyway I don't think this plugin should include this functionality, so we can close this issue I think.