I’ve just set up syntax highlighting for Puppet manifest files,
and thought I’d share the simple steps. The first thing to do is
download the syntax file from http://www.reductivelabs.com/downloads/puppet/puppet.vim
and save this to ~/.vim/syntax/puppet.vim. Now when the
filetype is set to “puppet”, vim will use this syntax file.
That’s useful, it it would be even nicer if we could make vim know
that files ending in .pp were puppet files. Turns out this is
very easy to do. You need to create a file to detect the correct
filetype when you open a file. You need to put the following lines in
~/.vim/ftdetect/puppet.vim:
au BufRead,BufNewFile *.pp setfiletype puppet
Now when you load a file ending in .pp, you should get nice syntax
highlighting. You can also make vim use special settings for the puppet
filetype by creating a vim script file in one of
~/.vim/ftplugin/puppet.vim, ~/.vim/ftplugin/puppet_*.vim and/or
~/.vim/ftplugin/puppet/*.vim. Vim has a lot of flexible hooks
to enable file type specific configuration; hopefully it should be
fairly easy to modify these examples for other file formats.
on said:
I’m using vim 7.1 on Debian Lenny.
In order to get this to work I first had to apt-get install vim.
According to http://ubuntuforums.org/showthread.php?t=845919 Lenny starts with vim tiny which does not have syntax highlighting.
I then put “au BufNewFile,BufRead *.pp setf puppet” in ~/.vim/filetype.vim
on said:
Thanks for posting this. I’m using Syntastic but it wasn’t doing anything due to the missing filetype .
Thanks again !