VIM and Puppet

Digging more and more into Puppet I find myself exploring several different editor to play with.

After using Geppetto as the main editor, whenever I need to just quickly write a small manifest to “document” some stuff, I return to VIM.

By customization puppet syntax is supported and the Puppetlabs Styleguide implemented as well.

I just wanted to have a quick look into this topic and get VIM basically supporting the syntax and aligning the code for me. During this I also learned about pathogen.vim for managing those extension and quickly install other stuff as well. So this is covered here as well.

Pathogen

Pathogen takes over the handling of the variable ‘runtimepath’ in VIM. VIM searches a couple of paths for scripts and stuff that are defined in ‘runtimepath’. Adding more scripts/plugins requires to edit or extend this path as well. Pathogen does this automatically (More information here.

Since the installation is described detailed enough on the github project page I will only list the commands for the setup for my personal documentation purpose.

# Installation of pathogen
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
# Including it into the VIM configuration
echo 'execute pathogen#infect()' >> ~/.vimrc

Now any plugins you wish to install can be extracted to a sub-directory under ~/.vim/bundle, and they will be added to the ‘runtimepath’.

Vim-Puppet

Now with Pathogen.vim in place it is going very quick to install vim-puppet. This will give you syntax highlighting and formatting based on the puppetlabs styleguide.

cd ~/.vim/bundle && \
git clone git://github.com/rodjek/vim-puppet.git

Done.

Tabular

Next step: automatic alignment of the tabs for the puppet manifests with Tabular Again using pathogen.

cd ~/.vim/bundle && \
git clone git://github.com/godlygeek/tabular.git

Syntastic

Hell, since I am installing stuff anyway, I will just continue. Syntastic is a syntax checker for many different files and Puppet is just one of them. Just install it and it works:

cd ~/.vim/bundle && \
git clone https://github.com/scrooloose/syntastic.git

Supported Checkers (the ones currently running) are listed in VIM with

:SyntasticInfo

The syntax check executes when saving the file, not during entering the code.