pearofducks / ansible-vim

A vim plugin for syntax highlighting Ansible's common filetypes
MIT License
796 stars 98 forks source link

Add au ftdetects in augroups with example #73

Closed maxwell-k closed 5 years ago

maxwell-k commented 5 years ago

This is just https://github.com/pearofducks/ansible-vim/pull/57 with an example as requested in the discussion.

Example tested on Debian 9 stretch following the approach in the discussion of https://github.com/pearofducks/ansible-vim/pull/54:

$ head -n 1 /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
$ vim --version | head -n 1
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 18:21:38)
$ curl -sfLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
$ cat > ~/.vim/vimrc <<EOF
set nocp
call plug#begin('~/.vim/plugged')
Plug 'hurricanehrndz/ansible-vim', { 'branch': 'ft-augroup_ftdetect' }
call plug#end()
filetype plugin indent on
syntax on
set ai
set si
augroup ansible_vim_fthosts
  autocmd!
  autocmd BufNewFile,BufRead hosts setfiletype yaml.ansible
augroup END
EOF
$ vim -c ":PlugInstall|qall"
$ vim hosts -c ':echom &ft'

This covers the use case behind #54.