Giter Site home page Giter Site logo

vim-ansible-yaml's Introduction

vim-ansible-yaml

Adds additional syntax highlighting and fixes indentation for Ansible's dialect of YAML.

Allows the use of the K key in normal mode to search the ansible docs for the keyword underneath the current cursor position.

Ansible YAML files are detected based on the presence of a modeline or a structure following Ansible's Playbook Best Practices. For details, see the Detection section below.

Install

Using Vundle

  1. Add the following to your .vimrc where other bundles are located:

     Bundle 'chase/vim-ansible-yaml'
    
  2. Run from command line:

     $ vim +BundleInstall
    

Using pathogen

  1. Check out the repository into your bundle path:

     $ cd ~/.vim/bundle
     $ git clone git://github.com/chase/vim-ansible-yaml.git
    
  2. Install the help file. (Repeat this step if you get an updated version.) From inside vim,

    :Helptags

Normal

  1. Check out the repository and copy the following to .vim/ directory or any other run time path, keeping their directory structure intact:

     doc/ansible.txt
     ftdetect/ansible.vim
     syntax/ansible.vim
     syntax/include/jinja.vim
     syntax/include/yaml.vim
     indent/ansible.vim
    
  2. Install the help file. From inside vim, :helptags ~/.vim/doc.

Detection

You can tell vim to recognize a file as Ansible by adding a modeline near the top or bottom of the file:

# vim:ft=ansible:

A file is recognized as an Ansible YAML file, and its filetype is set to ansible, if

  1. The extensions is .yml
  2. AND one of the following conditions holds:
  3. The file is somewhere under a directory named roles.
  4. The file is in the same directory as a directory (or file) named group_vars, host_vars, or roles.

Configuration

So far, there is only one option. Others may be added later.

If you define

let g:ansible_options = {'ignore_blank_lines': 0}

in your vimrc file, then the indent function will remove all indent after a blank line. The default behavior is to ignore blank lines when calculating the indent of the current line. This is helpful if your style is to insert blank lines, as in

tasks:
  - name: Say hello.
    command: echo Hello, world.

  - name: Say good night, Dick.
    command: echo Good night, Dick.

If g:ansible_options is not defined, or if the ignore_blank_lines key is not present, or the value is not 0, then the indent function uses the default behavior.

Thanks

A huge thanks to Igor Vergeichik and Nikolai Weibull for their work on the YAML syntax that this bundle uses.
Also, thank you, Armin Ronacher, for the simple and effective Jinja syntax file.

vim-ansible-yaml's People

Contributors

chase avatar benjifisher avatar jorgeegomez avatar komuta avatar certifiedloud avatar serialdoom avatar gabesullice avatar

Watchers

James Cloos avatar Chad Ostler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.