Follow JavaScript imports to their source.
The gf
mapping in vim edits the file under your cursor, but it doesn't work
in JavaScript. Node's module resolution is too complex for Vim to generalize.
further.vim
teaches Vim how to navigate JavaScript modules by replacing the
built-in gf
mapping with a full Vimscript implementation of Node's module
resolution
algorithm.
TL;DR:
- Put cursor over JavaScript import
- Press
gf
- Vim opens the file
vim-plug
Plug 'PsychoLlama/further.vim'
vundle
Plugin 'PsychoLlama/further.vim'
pathogen
git clone https://github.com/psychollama/further.vim ~/.vim/bundle/
- Does it work with TypeScript?
- Yeah
- How do I add support for new file extensions?
-
let g:further#extensions = ['.like-this']
- How do I open a file in a new split?
- Try
<c-w>gf
- Is there a programmatic API?
:help further-functions
- Does it work with Plug'n'Play?
- No.
- Anything else I should know?
- Sometimes dolphins use pufferfish to get high.
All the docs are in the further
help page. Install the plugin then run:
:help further.vim
Further works out of the box, but if you want, you can completely customize
resolution on a global or per-module basis. For instance: you could open
src/
instead of dist/
, rewrite monorepo imports, or resolve paths to
a different repository entirely.
Check out :help further-advanced
for details.
If something isn't working, send me an issue and I'll do my best to help.