vmware-archive / vim-config

This is the Vim configuration we use on pairing machines at Neo, as well as many Neons' personal machines. It's pretty okay.
BSD 2-Clause "Simplified" License
64 stars 41 forks source link

Pivotal-sg Vim Config

You should give it a try.

Pre-requisites

This config is build primarily to work with neovim, but should work nicely with MacVim and normal vim as well.

Font Requirement

This vim configuration requires one of the Powerline fonts https://github.com/Lokaltog/powerline-fonts

Install

  1. git clone git@github.com:neo/vim-config.git
  2. cd vim-config
  3. rake (This will symlink the necessary files to your home directory, asking for permission before clobbering anything.)
  4. vim
  5. :NeoBundleClean (if you have previously used this Vim config)
  6. :NeoBundleInstall (This will clone and install all of the plugins from github.)

Customizing

Customizations can be added to the folder .vim/custom_preconfig/ or .vim/custom_config/

The custom_preconfig settings are loaded prior to the common config. A common usecase for this is to reset mapleader. Most of the rest of the customizations are placed in custom_config.

You can add custom plugins by registering them in a .vim file in the custom_config folder with the following syntax, and then performing steps 3 & 4 from the install steps above.

" Custom plugins must be registered within a neobundle#append()/neobundle#end() block
call neobundle#append()

NeoBundle '<plugin-repository-location>'

call neobundle#end()

Common practice is to symlink a folder containing your custom configuration files as the .vim/custom_config folder.

Key mappings (remember case matters!)

Whitespace key mappings

Buffers & Navigation key mappings

Ruby key mappings

Rails key mappings

Macros (from within insert mode type abbreviation followed by punctuation or space)

CtrlP

Provides convenient ways to quickly reach the buffer/file/command/bookmark/tag you want. CtrlP searches with the fuzzy/partial pattern to which it converted an entered pattern.

Unimpaired

Utility functions for working with lines, files, and elements.

Customizations

Syntastic

Syntastic is a syntax checking plugin that runs buffers through external syntax checkers as they are saved and opened. 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.

Gundo

Awesome visual representation of vim undo tree.

Customizations

T-Comment

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 |TCommentDefineType()| 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.

Fugitive

I'm not going to lie to you; fugitive.vim may very well be the best Git wrapper of all time. Check out these features:

View any blob, tree, commit, or tag in the repository with :Gedit (and :Gsplit, :Gvsplit, :Gtabedit, ...). Edit a file in the index and write to it to stage the changes. Use :Gdiff to bring up the staged version of the file side by side with the working tree version and use Vim's diff handling capabilities to stage a subset of the file's changes.

Bring up the output of git status with :Gstatus. Press - to add/reset a file's changes, or p to add/reset --patch that mofo. And guess what :Gcommit does!

:Gblame brings up an interactive vertical split with git blame output. Press enter on a line to reblame the file as it stood in that commit, or o to open that commit 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.

Use :Ggrep to search the work tree (or any arbitrary commit) with git grep, skipping over that which is not tracked in the repository. :Glog loads all previous revisions of a file into the quickfix list so you can iterate over them and watch the file evolve!

: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.

Use :Gbrowse to open the current file on GitHub, with optional line range (try it in visual mode!). If your current repository isn't on GitHub, git instaweb will be spun up instead.

Add %{fugitive#statusline()} to 'statusline' to get an indicator with the current branch in (surprise!) your statusline.

Oh, and of course there's :Git for running any arbitrary command.

Ruby focused unit test

Makes it easy to run a focused set of ruby tests from within vim.

This plugin currently supports

Customizations:

"Project Drawer" aka NERDTree

NERDTree is a file explorer plugin that provides "project drawer" functionality to your vim projects. You can learn more about it with :help NERDTree.

Customizations: Use <leader>g to toggle NERDTree

Tabular

Lets you align statements on their equal signs, make comment boxes, align comments, align declarations, etc.

Tabular's commands are based largely on regular expressions. The basic technique used by Tabular is taking some regex to match field delimiters, splitting the input lines at those delimiters, trimming unnecessary spaces from the non-delimiter parts, padding the non-delimiter parts of the lines with spaces to make them the same length, and joining things back together again.

For instance, consider starting with the following lines:

Some short phrase,some other phrase
A much longer phrase here,and another long phrase

Let's say we want to line these lines up at the commas. We can tell Tabularize to do this by passing a pattern matching , to the Tabularize command:

:Tabularize /,

Some short phrase         , some other phrase
A much longer phrase here , and another long phrase

Customizations

The following tabular patterns have been added:

indent_object

Indent object creates a "text object" that is relative to the current indent. Text objects work inside of visual mode, and with c (change), d (delete) and y (yank). For instance, try going into a method in normal mode, and type v ii. Then repeat ii.

text-object-ruby-block

When textobj-rubyblock is installed you will gain two new text objects, which are triggered by ar and ir respectively. These follow Vim convention, so that ar selects all of a ruby block, and ir selects the inner portion of a rubyblock.

In ruby, a block is always closed with the end keyword. Ruby blocks may be opened using one of several keywords, including module, class, def, if, and do.

surround

Surround allows you to modify "surroundings" around the current text. For instance, if the cursor was inside "foo bar", you could type cs"' to convert the text to 'foo bar'.

There's a lot more; check it out at :help surround

SuperTab

In insert mode, start typing something and hit <TAB> to tab-complete based on the current context.

Tagbar

Plugin for browsing the tags of source code files. It provides a sidebar that displays the ctags-generated tags of the current file, ordered by their scope. This means that for example methods in C++ are displayed under the class they are defined in.

Customizations: Binds <leader>rt to the ctags command to update tags. Bind <leader>. to toggle the taglist window

Note: For full language support, run brew install ctags to install exuberant-ctags. Also if using OSX you may need to rename the system installed ctags version so that vim correctly finds the exuberant ctags version instead, sudo mv /usr/bin/ctags /usr/bin/ctags_orig. In addition, TagBar supports doctorjs/jsctags if installed for awesome tag support for javascript.

Tip: Check out :help ctags for information about VIM's built-in ctag support. Tag navigation creates a stack which can traversed via <C-]> (to find the source of a token) and <C-T> (to jump back up one level).

Matchit / ruby-matchit

Improves vim ability to jump back and forth between matching pairs of opening and ending items with %.

Gist-vim

Nice gist integration by mattn. Requires exporting your GITHUB_TOKEN and GITHUB_USER as environment variables or setup your GitHub token config.

Try :Gist, :Gist -p and visual blocks.

ZoomWin

When working with split windows, ZoomWin lets you zoom into a window and out again using <C-W> o

Customizations: Binds <leader>z to :ZoomWin

Markdown Preview

Markdown preview takes the current buffer, converts the Markdown to HTML, and opens it in your default browser.

Customizations: Binds <leader>mp to this plugin.

Other goodies

Additional Syntaxes / Language Support

Ships with a few additional syntaxes:

Color schemes

Includes the vim color sampler pack, which includes over 100 popular color themes:

Use :color vibrantink to switch to a color scheme.

Searching with VIM

We have a shortcut to search the entire current working directory for a given query.

g/ will result in :Ack! and you type in your query g* will result in :Ack! <word> depending on the location of your cursor.

For example, if I place my cursor on the word "foo" then type g* it will return :Ack! -w foo

This search functionality might not work until you install Ack or Ag. You can install these easily with brew.

Powerline Fonts

If you would like to use powerline fonts for vim and you use iTerm, make sure to set your Non ASCII Font in the iTerm settings.

Contributing

If you are going to contribute to our config, please make sure you are not overriding any common defaults. Also remember that we have a custom_config directory if you want to make a change for just yourself.

All PRs must be reviewed by at least one other person before being merged.