Use gf on JavaScript import/require statement to go to the imported file.
Requirements:
- Vim 8 or NeoVim v0.2.0
with vim-plug
Plug 'oesse/vim-nodegf'with pathogen
cd ~/.vim/bundle
git clone git://github.com/oesse/vim-nodegf.gitI know of Node.vim which contains similar functionality and more, as well as vim-javascript-gf.vim which does basically the same thing.
Node.vim includes features I personally do not use and I found the resolution mechanism to not always work. Also file paths are resolved with "." and ".." links still present, which I don't like, e.g. require('./foo/bar') when in file project-root/baz would open the correct file as project-root/baz/./foo/bar.
vim-javascript-gf.vim uses the npm module require-relative to resolve paths and I found it after I wrote this plugin.
This plugin is 100% vimscript, is unit tested, has no dependencies, and I tried to keep it very small.