Skip to content

Instantly share code, notes, and snippets.

@AfonsoTsukamoto
Last active February 1, 2018 13:27
Show Gist options
  • Save AfonsoTsukamoto/4615659479dd5d337bd457b7d610f2fb to your computer and use it in GitHub Desktop.
Save AfonsoTsukamoto/4615659479dd5d337bd457b7d610f2fb to your computer and use it in GitHub Desktop.
vim navigate to import
" From https://damien.pobel.fr/post/configure-neovim-vim-gf-javascript-import/
set path=.,src
set suffixesadd=.js,.jsx
function! LoadMainNodeModule(fname)
let nodeModules = "./node_modules/"
let packageJsonPath = nodeModules . a:fname . "/package.json"
if filereadable(packageJsonPath)
return nodeModules . a:fname . "/" . json_decode(join(readfile(packageJsonPath))).main
else
return nodeModules . a:fname
endif
endfunction
set includeexpr=LoadMainNodeModule(v:fname)
#!/usr/bin/env bash
DIR="~/.vim/ftdetect"
THIS="https://gist.githubusercontent.com/AfonsoTsukamoto/4615659479dd5d337bd457b7d610f2fb/raw/0a5538fdfb6c28273963dcdf6c1b108e746b2dac/js.vim"
mkdir -p $DIR
curl -L $THIS > "$DIR/js.vim"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment