Ⅰ. 插件描述
Vim for Ansible playbooks: omni-completion, abbreviations, syntax, folding, K-docs, and colorschemeⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'micahelliott/rocannon'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'micahelliott/rocannon'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'micahelliott/rocannon'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/micahelliott/rocannon
Ⅳ. 文档说明
# Rocannon: Operator of the Ansible
Command the Ansible, Relish the Rainbow. Never visit the Ansible docs again.

Ansible is a unique DSL with semantics way beyond an editor’s simple
built-in YAML treatment. Thus, Ansible files need a totally different type of
syntax highlighting — and of course completion of actions and their args.
Features
- Completion system that’s aware of all ansible modules/actions and their
args, and even the uniquestate=values - Syntax for semantics of Ansible, way beyond vanilla YAML
- A 256-color scheme to make use of the extended syntax
- Local, comprehensive documentation system that mirrors online docs (use
K) - Folding regions to collapse task blocks into simple, readable lists
- Simple skeleton for new
.ans/.yamlfiles - “Bouncing” between related roles files
- Execution of individual plays (via implicit tags and
:make)
(This is a somewhat simplistic Vim implementation, but mostly works if you
stick to Ansible best practices
[http://docs.ansible.com/playbooks_best_practices.html]().)
Demo
- Vanilla YAML file with default highlighting
- Change the filetype to ansible (can be done in other ways)
- Reopen file to reflect filetype
- Notice the folding
- Create a new "stat" play to not install pbzip2 otherwise
- Notice the completion of action and arg (other args also completable)
- Pull up documentation for
statwithK

Installation
Here I’m using Vundle (but
Pathogen should also work):
% vim ~/.vimrc " add line inside vundle block
Plugin 'MicahElliott/Rocannon'
Then install it with Vundle.
% vim +PluginInstall +qa
I recommend the above, but — just for fun — you could even use Ansible to get
it! (This also assumes Vundle is managing your ~/.vim/bundle area, and that
you’ve added the Plugin line above to your ~/.vimrc.)
% ansible localhost -m git -a 'repo=https://github.com/MicahElliott/Rocannon dest=~/.vim/bundle/Rocannon'
Rocannon should automatically detect a file with extension .yaml (but not.yml) as an Ansible file type. If you want to be explicit, though, you could
add to the top (or bottom) of each Ansible YAML file:
# vim:ft=ansible:
Now open an Ansible file and your should notice that the filetype is
“ansible”, and you’ll see some fancy colors, completions, etc:
% vim foo.yaml
(It would be really nice if Ansible supported a *.ans file extension.)
Comprehensive Help
This README is just to get you started. Use the extensive [vim
help](https://github.com/MicahElliott/Rocannon/blob/master/doc/rocannon.txt)
to learn the important details:
:help rocannon
Every Ansible module’s online documentation is also available via vim’s K.
Completions
All known Ansible actions are omni-completed, and a short description is
- Actions also have abbreviations, so that when you type
yum:it will - to
yum: name=. There are also completions for each arg, so if you
type yum: name=zsh <C-x><C-o> you will see a list of all possible args. Evenstate values are completed.
Syntax/Highlighting (colorscheme)
Yes, it’s very colorful. Although initially jarring, I find this quite
- The scheme is called _rocannon_. I recommend that you embrace this
- (though it can be turned off).
Folding
Plays can be folded into a single line containing just the name:
description.
Jumping between files (like vim-rails)
Several files in a role often need to be bounced around between. Vim-Rails
supports this nicely, bouncing between controllers, views, models, tests, etc.
Rocannon should do the same between tasks, handlers, templates, files, and
vars.
To its fullest
It’s helpful to have a terminal and font that fully support 256 colors, bold,
underline, italic, etc. If you don't already have that covered, I recommend
Urxvt and
Orp-Font (if you like bitmapped).
License
Copyright © Micah Elliott. Distributed under the same terms as Vim itself. See:help license.