Skip to content

Latest commit

 

History

History
186 lines (115 loc) · 9.86 KB

README.md

File metadata and controls

186 lines (115 loc) · 9.86 KB

vimrc

This is my vim configuration to work with Git + Puppet manifests, mostly it's based on some good articles about this that I found online:

  1. Using vim and Debian to do puppet development
  2. Puppet editing like a pro
  3. Using Vim to edit Puppet code

Using this repository you'll enable the following plugins:

  • pathogen Makes it super easy to install plugins and runtime files in their own private directories.
  • snipmate.vim snipMate.vim aims to be an unobtrusive, concise vim script that implements some of TextMate's snippets features in Vim.
  • syntastic Syntastic is a syntax checking plugin that runs files through external syntax checkers and displays any resulting errors to the user. This can be done on demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them.
  • tabular Sometimes, it's useful to line up text. Naturally, it's nicer to have the computer do this for you, since aligning things by hand quickly becomes unpleasant.
  • vim-puppet Make vim more Puppet friendly!
  • vim-fugitive Provides an amazingly deep Git integration for vim.
  • vim-markdown Syntax highlighting, matching rules and mappings for Markdown
  • nerdtree File manager under vim
  • vim-nerdtree-tabs Add automatically nerdtree on every new tab.
  • tcomment_vim Easily manage comments in every programming language.
  • lucius theme My favorite theme for vim.

Also you'll find a snippets directory with a custom list of snippet for Puppet.

Installation

The easiest way it's to clone this repository into your .vim directory (make a backup first if you have something in it).

git clone https://github.com/ricciocri/vimrc .vim

You should see an output similar to this one:

Cloning into '.vim'...
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 17 (delta 1), reused 13 (delta 1)
Unpacking objects: 100% (17/17), done.

Install the submodule

Move into the new .vim directory and run this command:

git pull && git submodule init && git submodule update && git submodule status

This will pull all the submodules used in this bundle.

vimrc file

Inside the repository there are also 2 .vimrc files that you can use, to use one of them you just have to link it in your $HOME, to do this just run the following commands in the terminal

Basic .vimrc that enable most of the plugins:

cd
ln -s .vim/.vimrc .

Full .vimrc that enable most of the plugins + nerdtree and tabs + lucius theme + use of the mouse under vim.

cd
ln -s .vim/.vimrc_full .vimrc

Longer Description of the plugin used:

This is a longer list of the plugin used in this bundle:

Manage your 'runtimepath' with ease. In practical terms, pathogen.vim makes it super easy to install plugins and runtime files in their own private directories. Pathogen is written by Vim plugin guru Tim Pope, it lets you isolate plugin scripts under their own directories. This means easy installs, uninistalls and upgrades.

So in short with this plugin you just have to install it in the "traditional way" and add this line in the .vimrc file

    execute pathogen#infect()

Now any plugins you wish to install can be extracted to a subdirectory under ~/.vim/bundle, and they will be added to the 'runtimepath'.

Syntastic is a syntax checking plugin that runs files through external syntax checkers and displays any resulting errors to the user. This can be done on demand, or automatically as files are saved. If syntax errors are detected, the user is notified and is happy because they didn't have to compile their code or execute their script to find them.

For puppet Syntastic can run both the command puppet parser validate for syntax errors and the command puppet-lint that will analyze your manifests and look for deviatins from the Puppet style guide, please note that both command must be present on the machine and available in your path, once you save the file you'll get a screen similar to this if there are some errors:

syntastic error

Also both checkers are enabled in this configuration, if you want to disable the parser or puppet-lint just edit your .vimrc file and check for that commented directive:

    "To enable Just puppet-lint and disable the parser uncomment next line
    "let g:syntastic_puppet_checkers=['puppetlint']

Uncommenting it will disable the parser, if you want to disable puppet-lint substitute ['puppet'] to ['puppetlint'].

Make vim more Puppet friendly! This plugin provide the following features:

  • Formatting based on the latest Puppetlabs Style Guide
  • Syntax highlighting
  • Automatic => alignment (when the tabular plugin is also installed)

This plugin it's great to have an automatic alignment of all your => and can be really useful also in other situations, check this short video for an introduction to tabular plugin.

This plugin it's probably my favourite in this bundle, with it you can just type the name of a puppet resourcd such as file, press the tab key and get you'll get a result like this:

file { "filename": ensure => "file", source => "puppet:///source", owner => "root", group => "root", mode => '0755';

Pressing tab again you'll move through the various stop point that are defined in the snippet, usually they are the values for the various keys. You can manage the snippets editing them directly, they are located in the file ~/.vim/snippets/puppet.snippets

A video it's probably the best way to see this small plugin in action, so check this small video, when you see the code appear it means that the operator has pressed the tab key.

Another great plugin, with this you can control directly from vim the status of the file you are editing in git, basically you can give in vim some Gcommand and work directly on git, some example are:

  • :Gstatus that bring up the output of git status
  • :Gblame brings up an interactive vertical split with git blame output. Press enter on a line to edit the commit where the line changed, or o to open it in a split. When you're done, use :Gedit in the historic buffer to go back to the work tree version.
  • :Gmove does a git mv on a file and simultaneously renames the buffer.
  • :Gremove does a git rm on a file and simultaneously deletes the buffer.
  • :Gread is a variant of git checkout -- filename that operates on the buffer rather than the filename. This means you can use u to undo it and you never get any warnings about the file changing outside Vim.
  • :Gwrite writes to both the work tree and index versions of a file, making it like git add when called from a work tree file and like git checkout when called from the index or a blob in history.

If you are interested I suggest to watch this small video to get an idea of the potential of this great plugin: Fugitive.vim - a complement to command line git

Syntax highlighting, matching rules and mappings for Markdown.

Options

Disable Folding

Add the following line to your .vimrc to disable folding.

let g:vim_markdown_folding_disabled=1 Set Initial Foldlevel

Add the following line to your .vimrc to set the initial foldlevel. This option defaults to 0 (i.e. all folds are closed) and is ignored if folding is disabled.

let g:vim_markdown_initial_foldlevel=1

The NERD tree allows you to explore your filesystem and to open files and directories. It presents the filesystem to you in the form of a tree which you manipulate with the keyboard and/or mouse.

tcomment provides easy to use, file-type sensible comments for Vim. It can handle embedded syntax.

TComment works like a toggle, i.e., it will comment out text that contains uncommented lines, and it will remove comment markup for already commented text (i.e. text that contains no uncommented lines).

If the file-type is properly defined, TComment will figure out which comment string to use. Otherwise you use |tcomment#DefineType()| to override the default choice.

TComment can properly handle an embedded syntax, e.g., ruby/python/perl regions in vim scripts, HTML or JavaScript in php code etc.

If you use my .vimrc just select a block of text and use the keys ctrl-- (the key ctrl and 2 times the key -) to add comments/uncomments all the lines.

git submodule

This project use git submodule, to track some of the vim plugin I used: