Ⅰ. 插件描述
:flashlight: Follow JavaScript imports to their sourceⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'psychollama/further-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'psychollama/further-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'psychollama/further-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/psychollama/further.vim
Ⅳ. 文档说明
# Further.vim
Follow JavaScript imports to their source
Purpose
The gf
mapping in vim edits the file under your cursor, but it doesn't work
well in JavaScript. File extensions are implied, node_modules
directories
can be nested beneath themselves, and there can be different package versions
depending on what symlink you follow.
further.vim
aims for seamless JavaScript imports traversal, replacing the
built-in gf
mapping with the JS module resolution algorithm. But, you know,
only in JavaScript files.
Redirects
Most libraries will resolve to a babel-compiled file. Efficient, but not easily
readable by humans.
further.vim
exposes a hook for this. Defining a special function allows you
to intercept the resolved file path and change it to something else.
The easiest way is just replacing dist/
with src/
and seeing if it
resolves to an actual file. If not, just return it unchanged.
" Replace 'dist/' with 'src/', unless that results in an unreadable file.
function! g:FurtherMapModuleName(file_path, module_name)
let l:sourcified = substitute(a:file_path, '/dist/', '/src/', '')
if filereadable(l:sourcified)
return l:sourcified
endif
return a:file_path
endfunction
Intercepts are even more useful when the pathname can't be known without
app-specific knowledge, like the location of AngularJS html templates, or
a config file with implied directory prefixes.
If you're unsure how to use the intercept function, open an issue. I'm more
than willing to help!
Installation
vim-plug
Plug 'PsychoLlama/further.vim'
vundle
Plugin 'PsychoLlama/further.vim'
pathogen
git clone https://github.com/psychollama/further.vim ~/.vim/bundle/
Documentation
All the docs are in the further
help page. Install the plugin then run:
:help further
Contributing
Find a bug or have a question? I'd love to help! Submit an issue and we can
brainstorm a solution.
Thanks for being a cool user. High five :raised_hand: