Ⅰ. 插件描述
Effortlessly jump between source and test filesⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'psychollama/alternaut-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'psychollama/alternaut-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'psychollama/alternaut-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/psychollama/alternaut.vim
Ⅳ. 文档说明
# Alternaut.vim
Project Status
:warning: Experimental
Mission
Instantly jump between your test files and your source files.
Example
Say you've got a project structure like this:
src/
__tests__/
logic.test.js
foo.test.js
logic.js
foo.jsand you're editing src/foo.js. You want to open the test file.
That's where alternaut comes in. Call alternaut#Toggle() and you're insrc/__tests__/foo.test.js. Toggle again and you're right back in the other
file.
Configuration
Alternaut doesn't make any assumptions about your project structure. You need
to tell it your conventions. What do you name your test directories? What do
you name your test files? That kind of thing.
" A typical JavaScript setup.
call alternaut#RegisterLanguage('javascript', {
\ 'directory_naming_conventions': ['__tests__', 'tests'],
\ 'file_naming_conventions': ['{name}.test.{ext}', '{name}.spec.{ext}'],
\ 'file_extensions': ['js', 'jsx'],
\ })Once that's registered, any time you open a javascript file, you can call
:call alternaut#Toggle()and it'll toggle between the corresponding test and source file. If you're
feeling lazy, put it in a mapping:
nnoremap <silent><leader>a <esc>:call alternaut#Toggle()<cr>Issues
The plugin is pretty new. If you experience some rough edges, feel free to
open an issue :thumbsup: