vimrc / vimrc

" Ross's vimrc

" Load vim-addon-manager
function! s:InitAddons()
    let addons_base = expand('$HOME') . '/vim-addons'
    exec 'set runtimepath+='.escape(addons_base, ' \').'/vim-addon-manager'
    call vam#ActivateAddons(['UltiSnips', 'scss-syntax', 'SWIG_syntax', 'Gundo', 'Puppet_Syntax_Highlighting', 'Dart', 'Conque_Shell', 'github:ervandew/supertab'], {'auto_install': 0})

if !exists('vimrc_addons_inited')
    let vimrc_addons_inited = 1
    call s:InitAddons()

" Add Go stuff
function! s:InitGo()
    let goroot = substitute(system('go env GOROOT'), '\n$', '', '')
    if v:shell_error == 0
        exec 'set runtimepath+='.escape(goroot, ' \').'/misc/vim'

    let gocodeRoot = substitute(system('blackforest path gocode'), '\n$', '', '')
    if v:shell_error == 0 && isdirectory(gocodeRoot)
        exec 'set runtimepath+='.escape(gocodeRoot, ' \').'/vim'

if !exists('vimrc_go_inited')
    let vimrc_go_inited = 1
    call s:InitGo()

" Source the vimrc file after saving it
if has("autocmd") && !exists("vimrc_au_loaded")
    let vimrc_au_loaded = 1
    autocmd BufWritePost ~/.vim/vimrc runtime vimrc

" Enable file types/syntax highlighting
filetype plugin indent on
if has("syntax")
    syntax on

" Interface options
set modeline& modelines&    " allow modelines
set ruler                   " show cursor position
set laststatus=2            " always show status bar
set showcmd                 " display modifiers before a command
set backspace=indent,start  " what backspace can delete in insert mode
set nrformats=hex,alpha     " what CTRL-A/CTRL-X allows you to change
set gdefault                " use /g option by default in :s
set scrolloff=2             " number of lines to keep on screen around cursor

if has("statusline")
    function! StatusWinnum()
        if winnr("$") == 1
            return ""
            return "(" . winnr() . ") "
    function! StatusTabMode()
        if &expandtab
            return ""
            return "[tab]"

    set statusline=%{StatusWinnum()}%<%f    " (N) filename
    set statusline+=\ %m%h%r%=              " [+][help][RO]
    set statusline+=%y                      " [filetype]
    set statusline+=\ %-10.([%{&sts},%{&ts}]%{StatusTabMode()}%)    " [ts,sts][tab]
    set statusline+=\ %-10.(%l,%c%V%)       " LINE,COLUMN-VIRTUALCOLUMN
    if exists("*strftime")
        set statusline+=\ %-6.{strftime('%H:%M')}   " Current time

" Choose what should be saved during :mks
set sessionoptions=blank,buffers,curdir,folds,help,options,resize,tabpages,winsize

" Place swap files in system temp directory
if has('win32') || has('win64')
    set directory=.,C:\\tmp,C:\\temp
    set directory=/var/tmp,/tmp

" Ex command-line completion
set wildmode=longest,full
set wildmenu

" Keymaps
nnoremap Y y$
nnoremap K <Nop>

cabbr <expr> %% expand('%:h')
if has('win32') || has('win64')
    cabbr vrc ~/vimfiles/vimrc
    cabbr gvrc ~/vimfiles/gvimrc
    cabbr vrc ~/.vim/vimrc
    cabbr gvrc ~/.vim/gvimrc

" Common indentation modes
" Sets the indentation options to common settings.
" Usage: :Tabs 8
"        :Spaces 3
"        :Tabs      " same as Tabs 8
"        :Spaces    " same as Spaces 4
command! -bar -count=8 Tabs set ts=<count> sts=0 sw=<count> noet
command! -bar -count=4 Spaces set ts=8 sts=<count> sw=<count> et

" Command to replace carriage returns with newlines.
" Usage: :Cr        " for the whole file
"        :1,10Cr    " for a range
command! -bar -nargs=0 -range=% Cr <line1>,<line2>s/

" Run a command and put output in new buffer
command! -nargs=+ -complete=file Run call s:OutputBuffer(<q-args>)
function! s:OutputBuffer(line)
    setlocal bt=nofile bufhidden=wipe nobuflisted noswapfile nonu
    execute '$read !'.a:line
    silent execute 'file '.escape(a:line, ' \')
    1delete _
    filetype detect

" Indentation
set autoindent
Spaces 4 " Default to 4-space indents

" Wrapping
set wrap
set linebreak
let &showbreak='  '

" Gutter
" set number
set numberwidth=3
" set foldcolumn=3
" set relativenumber
" set colorcolumn=+0,80

" Python
let g:pyindent_open_paren = '&sw'
let g:pyindent_nested_paren = '&sw'
let g:pyindent_continue = '&sw'

" LaTeX
let g:tex_flavor='latex'

" Bash
let g:is_bash=1

" Go
let go_highlight_trailing_whitespace_error = 0

" Haskell
let hs_highlight_boolean = 1
let hs_highlight_types = 1
let hs_highlight_more_types = 1

" Java
let java_allow_cpp_keywords = 1

" Zen Coding
let g:user_zen_leader_key = '<c-h>'
let g:user_zen_settings = {
\   'indentation' : '    '

" UltiSnips
let g:snips_author = "Ross Light"
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"

" ConqueTerm
let g:ConqueTerm_EscKey = '<C-k>'
let g:ConqueTerm_CWInsert = 1
let g:ConqueTerm_CloseOnEnd = 0

command! -bar Zsh ConqueTerm zsh
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.