All Projects → pearofducks → Ansible Vim

pearofducks / Ansible Vim

Licence: mit
A vim plugin for syntax highlighting Ansible's common filetypes

Projects that are alternatives of or similar to Ansible Vim

Committia.vim
A Vim plugin for more pleasant editing on commit messages
Stars: ✭ 510 (-19.43%)
Mutual labels:  vim-plugin
Julia Vim
Vim support for Julia.
Stars: ✭ 556 (-12.16%)
Mutual labels:  vim-plugin
Phpcomplete.vim
Improved PHP omnicompletion
Stars: ✭ 582 (-8.06%)
Mutual labels:  vim-plugin
Terraform Provisioner Ansible
Ansible with Terraform 0.13.x
Stars: ✭ 520 (-17.85%)
Mutual labels:  ansible
Ios Dev Playbook
不会运维的 iOS 开发不是好设计师。这个 Ansible Playbook 能快速配置 iOS 开发需要的服务,安装如 Gogs、GitLab、Jenkins、Ghost、Ajenti 等常用服务。
Stars: ✭ 542 (-14.38%)
Mutual labels:  ansible
Vim Disapprove Deep Indentation
ಠ_ಠ Vim plugin to disapprove deeply indented code. ಠ_ಠ
Stars: ✭ 566 (-10.58%)
Mutual labels:  vim-plugin
Ops
基于centos6+python3.6+django2+ansible2.4+celery4.2 运维管理系统,目前实现功能:用户和用户组管理、资产管理、集成ansible2.4、简易堡垒机(主机分配支持rdp以及vnc、用户分配、文件上传下载、配置禁用命令清单、操作录像回放功能)、CI/CD(支持git仓库和svn仓库)、数据库管理(一部分)、celery任务编排、知识库及文件共享
Stars: ✭ 502 (-20.7%)
Mutual labels:  ansible
Alchemist.vim
Elixir Integration Into Vim
Stars: ✭ 632 (-0.16%)
Mutual labels:  vim-plugin
Streisand
Streisand sets up a new server running your choice of WireGuard, OpenConnect, OpenSSH, OpenVPN, Shadowsocks, sslh, Stunnel, or a Tor bridge. It also generates custom instructions for all of these services. At the end of the run you are given an HTML file with instructions that can be shared with friends, family members, and fellow activists.
Stars: ✭ 22,605 (+3471.09%)
Mutual labels:  ansible
Ansible Docker
Install / Configure Docker and Docker Compose using Ansible.
Stars: ✭ 577 (-8.85%)
Mutual labels:  ansible
Polemarch
Simple WEB gui for infrastructure management by ansible playbooks or modules. This is only mirror with bins in releases.
Stars: ✭ 530 (-16.27%)
Mutual labels:  ansible
Aspnet Core React Template
ASP.NET Core 3.1 / React SPA Template App
Stars: ✭ 539 (-14.85%)
Mutual labels:  ansible
Vim Gnupg
This script implements transparent editing of gpg encrypted files.
Stars: ✭ 566 (-10.58%)
Mutual labels:  vim-plugin
Srcery Vim
Dark colorscheme for gvim and vim
Stars: ✭ 518 (-18.17%)
Mutual labels:  vim-plugin
Vim Hexokinase
hexokinase.vim - (Neo)Vim plugin for asynchronously displaying the colours in the file (#rrggbb, #rgb, rgb(a)? functions, hsl(a)? functions, web colours, custom patterns)
Stars: ✭ 622 (-1.74%)
Mutual labels:  vim-plugin
Switch.vim
A simple Vim plugin to switch segments of text with predefined replacements
Stars: ✭ 506 (-20.06%)
Mutual labels:  vim-plugin
Books Recommendation
程序员进阶书籍(视频),持续更新(Programmer Books)
Stars: ✭ 558 (-11.85%)
Mutual labels:  ansible
Ansible Role Nginx
Ansible Role - Nginx
Stars: ✭ 632 (-0.16%)
Mutual labels:  ansible
Lightline.vim
A light and configurable statusline/tabline plugin for Vim
Stars: ✭ 5,886 (+829.86%)
Mutual labels:  vim-plugin
Traces.vim
Range, pattern and substitute preview for Vim
Stars: ✭ 568 (-10.27%)
Mutual labels:  vim-plugin

introduction

This is a vim syntax plugin for Ansible 2.x, it supports YAML playbooks, Jinja2 templates, and Ansible's hosts files.

  • YAML playbooks are detected if:
    • they are in the group_vars or host_vars folder
    • they are in the tasks, roles, or handlers folder and have either a .yml or .yaml suffix
    • they are named playbook.y(a)ml, site.y(a)ml, or main.y(a)ml
  • Jinja2 templates are detected if they have a .j2 suffix
  • Files named hosts will be treated as Ansible hosts files

You can also set the filetype to yaml.ansible, *.jinja2, or ansible_hosts if auto-detection does not work (e.g. :set ft=yaml.ansible or :set ft=ruby.jinja2). Note: If you want to detect a custom pattern of your own, you can easily add this in your .vimrc using something like this:

au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible

If you want to override the default file type detection you can easily do this in your .vimrc. For example if you use YAML syntax for hosts include something like this:

augroup ansible_vim_fthosts
  autocmd!
  autocmd BufNewFile,BufRead hosts setfiletype yaml.ansible
augroup END

This plugin should be quite reliable, as it sources the original formats and simply modifies the highlights as appropriate. This also enables a focus on simplicity and configurability instead of patching bad syntax detection.

examples (with solarized colorscheme)
Bright (and selective highlight) Dim
installation

Use your favorite plugin manager, or try vim-plug if you're looking for a really nice one!

vim-plug: Plug 'pearofducks/ansible-vim'

vim-plug with post-update hook: Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' }

Note: Because of Ansible API changes, generate.sh may require the latest (or near-latest) version of Ansible.

Note2: generate.sh can receive some parameters, for more info see its Readme

vundle: Plugin 'pearofducks/ansible-vim'

pathogen: git clone https://github.com/pearofducks/ansible-vim ~/.vim/bundle/ansible-vim

Arch Linux: Package vim-ansible is available in the community repository.

Fedora: The vim-ansible package is available in the default repository.

RHEL/CentOS: The vim-ansible package is available in the EPEL repository.

options

g:ansible_unindent_after_newline

let g:ansible_unindent_after_newline = 1

When this variable is set, indentation will completely reset (unindent to column 0) after two newlines in insert-mode. The normal behavior of YAML is to always keep the previous indentation, even across multiple newlines with no content.

g:ansible_yamlKeyName

let g:ansible_yamlKeyName = 'yamlKey'

This option exists to provide additional compatibility with stephpy/vim-yaml.

g:ansible_attribute_highlight

let g:ansible_attribute_highlight = "ob"

Ansible modules use a key=value format for specifying module-attributes in playbooks. This highlights those as specified. This highlight option is also used when highlighting key/value pairs in hosts files.

Available flags (bold are defaults):

  • a: highlight all instances of key=
  • o: highlight only instances of key= found on newlines
  • d: dim the instances of key= found
  • b: brighten the instances of key= found
  • n: turn this highlight off completely
g:ansible_name_highlight

let g:ansible_name_highlight = 'd'

Ansible modules commonly start with a name: key for self-documentation of playbooks. This option enables/changes highlight of this.

Available flags (this feature is off by default):

  • d: dim the instances of name: found
  • b: brighten the instances of name: found
g:ansible_extra_keywords_highlight

let g:ansible_extra_keywords_highlight = 1

Note: This option is enabled when set, and disabled when not set.

Highlight the following additional keywords in playbooks: register always_run changed_when failed_when no_log args vars delegate_to ignore_errors

By default we only highlight: include until retries delay when only_if become become_user block rescue always notify

g:ansible_normal_keywords_highlight

let g:ansible_normal_keywords_highlight = 'Constant'

Accepts any syntax group name from :help E669 - e.g. Comment, Constant, and Identifier

Note: Defaults to 'Statement' when not set.

This option change the highlight of the following common keywords in playbooks: include until retries delay when only_if become become_user block rescue always notify

g:ansible_with_keywords_highlight

let g:ansible_with_keywords_highlight = 'Constant'

Accepts any syntax group-name from :help E669 - e.g. Comment, Constant, and Identifier

Note: Defaults to 'Statement' when not set.

This option changes the highlight of all with_.+ keywords and loop in playbooks.

g:ansible_template_syntaxes

let g:ansible_template_syntaxes = { '*.rb.j2': 'ruby' }

Accepts a dictionary in the form of 'regex-for-file': 'filetype'.

  • regex-for-file will receive the full filepath, so directory matching can be done.
  • filetype is the root filetype to be applied, jinja2 will be automatically appended

All files ending in *.j2 that aren't matched will simply get the jinja2 filetype.

goto role under cursor (similar to gf)

This behavior is not supported out of the box, but you can use this snippet in your vimrc.

You'll then be able to go to a role's definition with <leader>gr.

bugs, suggestions/requests, & contributions

bugs

It's unlikely that there will be bugs in highlighting that don't exist in the core format. Where appropriate these will be fixed in this plugin, but if the problem is with the original syntax we should probably focus on fixing that instead.

Indenting a full document - e.g with gg=G - will not be supported and is not a goal of this plugin (unless someone else develops it!). Please do not file a bug report on this.

suggestions/requests

Suggestions for improvements are welcome, pull-requests with completed features even more so. :)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].