dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

vimrc (12142B)


      1 " plug-ins{{{1
      2 
      3 let g:loaded_matchparen = 1
      4 
      5 " run separate bundles vimrc
      6 if filereadable(expand("~/dotfiles/vimrc.bundles"))
      7   source ~/dotfiles/vimrc.bundles
      8 endif
      9 
     10 filetype plugin indent on
     11 
     12 " use matchit plug-in for jumping to HTML/XML tags with %
     13 runtime! macros/matchit.vim
     14 
     15 " turn on colors
     16 set t_Co=256
     17 
     18 " different color schemes to choose from
     19 set background=dark
     20 " let s:color = 'badwolf'
     21 " let s:color = 'hybrid'
     22 " let s:color = 'jellybeans'
     23 " let s:color = 'molokai'
     24 " let s:color = 'zenburn'
     25 " let s:color = 'skittles_berry'
     26 let s:color = 'solarized'
     27 
     28 execute 'colorscheme '.s:color
     29 
     30 " options{{{2
     31 " Neocomplete options
     32 let g:acp_enableAtStartup = 0
     33 let g:neocomplete#enable_at_startup = 1
     34 let g:neocomplete#enable_smart_case = 1
     35 let g:neocomplete#sources#syntax#min_keyword_length = 3
     36 let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
     37 autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
     38 autocmd FileType html setlocal omnifunc=htmlcomplete#CompleteTags
     39 autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
     40 autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
     41 
     42 " allow for neocomplete and eclim/tmuxcomplete to work
     43 let g:tmuxcomplete#trigger  = 'omnifunc'
     44 
     45 " Neosnippet options
     46 let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
     47 
     48 " change netrw style to a tree
     49 let g:netrw_liststyle = 3
     50 " man netrw show numbers
     51 let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
     52 
     53 let g:rainbow_conf = {
     54   \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
     55   \ 'ctermfgs': ['red', 'darkred', 'brown'],
     56   \ 'operators': '_,_',
     57   \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
     58   \ 'separately': {
     59   \   '*': {},
     60   \   'markdown': {
     61   \     'parentheses_options': 'containedin=markdownCode contained',
     62   \   },
     63   \   'lisp': {
     64   \     'ctermfgs': ['darkred', 'darkmagenta', 'darkcyan', 'darkgreen', 'darkblue', 'magenta'],
     65   \   },
     66   \   'tisp': {
     67   \     'ctermfgs': ['darkred', 'darkmagenta', 'brown', 'darkgreen', 'darkblue', 'magenta'],
     68   \   },
     69   \   'vim': {
     70   \     'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
     71   \   },
     72   \ }
     73   \}
     74 let g:rainbow_active = 1
     75 
     76 " catium.vim options
     77 let g:catium#trail = 0
     78 let g:catium#body  = 0
     79 let g:catium#face  = 0
     80 let g:catium#space = 0
     81 
     82 " syntastic options
     83 let g:syntastic_always_populate_loc_list = 1
     84 let g:syntastic_auto_loc_list = 1
     85 let g:syntastic_check_on_open = 1
     86 let g:syntastic_vim_checkers = ['vint']
     87 let g:syntastic_c_compiler_options="--std=gnu99 -DVERSION"
     88 
     89 " gitgutter options
     90 let g:gitgutter_max_signs = 1000
     91 
     92 " commentary extra languages
     93 autocmd FileType matlab setlocal commentstring=%\ %s
     94 
     95 " mappings{{{2
     96 " turn on Tagbar plug-in
     97 nmap <silent> <F3> :TagbarToggle<CR>
     98 
     99 " GoldenView stuff
    100 let g:goldenview__enable_default_mapping = 0
    101 nmap <silent> <C-O>     <Plug>GoldenViewSplit
    102 nmap <silent> <leader>o <Plug>GoldenViewSwitchMain
    103 
    104 " Neocomplete tab to select
    105 imap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
    106 imap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
    107 inoremap <expr><Left>  neocomplete#close_popup() . "\<Left>"
    108 inoremap <expr><Right> neocomplete#close_popup() . "\<Right>"
    109 inoremap <expr><Up>    neocomplete#close_popup() . "\<Up>"
    110 inoremap <expr><Down>  neocomplete#close_popup() . "\<Down>"
    111 
    112 " tmux-navigator plug-in mappings
    113 let g:tmux_navigator_no_mappings = 1
    114 nnoremap <silent> <M-h> :TmuxNavigateLeft<CR>
    115 nnoremap <silent> <M-j> :TmuxNavigateDown<CR>
    116 nnoremap <silent> <M-k> :TmuxNavigateUp<CR>
    117 nnoremap <silent> <M-l> :TmuxNavigateRight<CR>
    118 nnoremap <silent> <M-\> :TmuxNavigatePrevious<CR>
    119 
    120 nnoremap <leader>a :AS<CR>
    121 
    122 nnoremap <silent> <leader>s :SyntasticToggleMode<CR>
    123 
    124 nmap <leader>f :DmenuFile "e"<CR>
    125 nmap <leader>b :DmenuBuf  "e"<CR>
    126 nmap <leader>t :DmenuTag<CR>
    127 
    128 map <Leader>l <Plug>TaskList
    129 
    130 " useful mapping for Vundle
    131 au BufRead,BufNewFile *vimrc* nmap gb :w<CR>:source %<CR>:VundleInstall<CR>
    132 au BufRead,BufNewFile *vimrc* nmap gB :w<CR>:source %<CR>:VundleClean<CR>
    133 
    134 vmap <C-A> <Plug>VisualIncrement
    135 vmap <C-X> <Plug>VisualDecrement
    136 
    137 "}}}
    138 " basic{{{1
    139 syntax on
    140 set autoindent                  " I hope you know what this does
    141 set autowrite                   " automatically write before running commands that need it to be written
    142 set nohlsearch                  " turn off highlighting of searches
    143 set ignorecase                  " make search non case sensitive
    144 set incsearch                   " show the search result before you finish typing
    145 set noshowmode                  " turn off '--INSERT--' at bottom of screen
    146 set nowrap                      " do not wrap text to newline when it gets to the end of the screen
    147 set shiftround                  " make indents always be at a multiple of the tab width
    148 set showcmd                     " show normal mode commands that you are typing
    149 set showmatch                   " when a bracket is inserted, briefly highlight the matching one.
    150 set smartcase                   " allow you to search with more charters
    151 set hidden                      " keep buffers loaded when not visible
    152 set splitbelow                  " create new splits under current window
    153 set splitright                  " create new vertical splits to the right
    154 set timeout                     " set timeout for mappings
    155 set notitle                     " stop Vim from setting the terminal's title
    156 set ttyfast                     " makes Vim faster
    157 set novisualbell                " disable screen flashes for error
    158 set backspace=2                 " turn on backspace
    159 set completeopt-=preview        " disable pop-up when using Neocomplete
    160 set cryptmethod=blowfish        " change the way Vim encrypts files to blowfish from zip
    161 set formatoptions+=w            " when text get over the number set by `set textwidth`, wrap it to next line
    162 set foldmethod=marker           " set the folding method to use three { to start and three } to end
    163 set laststatus=2                " always turn on status line
    164 set modelines=5                 " number of lines down Vim checks for set commands
    165 set mouse=a                     " turn on the mouse
    166 set nrformats=octal,hex,alpha   " allow you to ctrl-a/ctrl-x to increase/decrease letters and numbers
    167 set scrolloff=7                 " make Vim have 7 lines below cursor when moving down
    168 set t_ut=                       " needed if using Vim inside of tmux
    169 set textwidth=98                " wrap lines which exceed 100 charters long
    170 set ttimeoutlen=50              " change wait time for `timeout`
    171 set spell spelllang=en_us       " set language for spell check to United States
    172 set clipboard=unnamedplus       " Vim yanks go to OS's clipboard as well
    173                                 " remove 'plus' if not on Linux
    174 
    175 " set up menu stuff
    176 set wildmenu
    177 set wildmode=list,longest,full
    178 
    179 " make line numbers go 1,2,3,4...
    180 set number
    181 " make the line your cursor is on 0
    182 " set relativenumber
    183 
    184 " extra chars like the end of line one and when text raps to next line
    185 set list
    186 set listchars=tab:\|\ ,eol:¬,extends:❯,precedes:❮
    187 
    188 " make Vim's clipboard the same as OS's clipboard
    189 let g:clipbrdDefaultReg = '+'
    190 
    191 if has("autocmd")
    192   " make Vim save every time it leaves insert mode
    193   autocmd InsertLeave * if &mod && expand('%')!=''|write|endif
    194 
    195   " save line number line when reopening file
    196   autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
    197   " don't for git commit file
    198   autocmd FileType gitcommit normal gg
    199 
    200   " remove trailing whitespace
    201   autocmd BufWritePre * %s/\s\+$//e
    202 endif
    203 
    204 " turn on alt key
    205 let c='a'
    206 while c <= 'z'
    207   exec "set <A-".c.">=\e".c
    208   exec "imap \e".c." <A-".c.">"
    209   let c = nr2char(1+char2nr(c))
    210 endw
    211 
    212 " highlighting{{{1
    213 " highlight the 100th column so you know when your line is to long
    214 call matchadd('Error', '\%100v', 100)
    215 
    216 au BufRead,BufNewFile *.md  set filetype=markdown
    217 au BufRead,BufNewFile *bash_profile* set filetype=sh
    218 au BufRead,BufNewFile *tmux.conf*    set filetype=sh
    219 au BufRead,BufNewFile *conkyrc*      set filetype=sh
    220 au BufRead,BufNewFile *gitconfig*    set filetype=gitconfig
    221 au BufRead,BufNewFile TODO           set filetype=markdown
    222 
    223 " spell check
    224 hi SpellBad ctermfg=red cterm=underline
    225 if version >= 700
    226   set spl=en spell
    227   set nospell
    228 endif
    229 
    230 " better highlighting for solarized
    231 if s:color == 'solarized'
    232   hi CursorLine   ctermbg=23
    233   hi CursorColumn ctermbg=23
    234   hi Normal       ctermbg=none
    235   hi SignColumn   ctermbg=0
    236   hi Folded       cterm=bold
    237   hi VertSplit    ctermbg=0
    238   hi TabLine      term=none cterm=none
    239   hi TabLineFill  term=none cterm=none
    240   hi TabLineSel   term=none cterm=none
    241 endif
    242 
    243 " better highlighting for molokai
    244 if s:color == 'molokai'
    245   hi NonText ctermbg=none
    246   hi Folded  ctermbg=none ctermfg=59
    247 endif
    248 
    249 " fix highlighting of special symbols
    250 function! C_Syntax()
    251   syntax match _Operator "[-+&|<>=!\*~.,:%&^?]"
    252   syntax match _Operator "/ \|/="
    253   syntax match _Semicolon "[;]"
    254   hi link _Operator Operator
    255   hi _Semicolon ctermfg=red
    256   set sw=8
    257   set ts=8
    258   set noexpandtab
    259 endfunction
    260 autocmd! BufRead,BufNewFile,BufEnter *.{c,cpp,h,hpp,} call C_Syntax()
    261 
    262 " status line{{{1
    263 function! InsertStatuslineColor(mode)
    264   if a:mode == 'i'
    265     hi statusline ctermfg=4   ctermbg=15
    266     hi SLgreen    ctermfg=0 ctermbg=4
    267     hi SLblue     ctermfg=0 ctermbg=4
    268     hi SLcyan     ctermfg=0 ctermbg=4
    269   elseif a:mode == 'r'
    270     hi statusline ctermfg=9 ctermbg=15
    271     hi SLgreen    ctermfg=0 ctermbg=9
    272     hi SLblue     ctermfg=0 ctermbg=9
    273     hi SLcyan     ctermfg=0 ctermbg=9
    274   else
    275     hi statusline ctermfg=0 ctermbg=15
    276   endif
    277 endfunction
    278 
    279 au InsertEnter * call InsertStatuslineColor(v:insertmode)
    280 au InsertLeave * hi statusline ctermfg=0 ctermbg=15
    281 au InsertLeave * hi SLgreen    ctermfg=2 ctermbg=0
    282 au InsertLeave * hi SLblue     ctermfg=4 ctermbg=0
    283 au InsertLeave * hi SLcyan     ctermfg=6 ctermbg=0
    284 
    285 hi statusline ctermfg=0 ctermbg=15
    286 hi SLgreen    ctermfg=2 ctermbg=0
    287 hi SLblue     ctermfg=4 ctermbg=0
    288 hi SLcyan     ctermfg=6 ctermbg=0
    289 
    290 set statusline=%#SLblue#%f       " file name
    291 set statusline+=%#SLgreen#\ %Y   " filetype
    292 set statusline+=%#SLcyan#\ %M    " modified flag
    293 set statusline+=\ %{g:Catium()}
    294 
    295 set statusline+=\ %=             " move to right side
    296 
    297 set statusline+=%#SLcyan#%p%%    " percent of file
    298 set statusline+=%#SLgreen#\ %v   " column
    299 set statusline+=%#SLblue#\ %l/%L " current line/total lines
    300 set statusline+=%#ErrorMsg#%{SyntasticStatuslineFlag()} " Syntastic Error
    301 
    302 " mapping{{{1
    303 " make jj typed quickly while in insert mode switch to normal mode :D
    304 inoremap jj <Esc>
    305 
    306 " make ctrl+c completely like ESC
    307 inoremap <C-c> <Esc><Esc>
    308 
    309 " extend ESC to also clear search highlight
    310 nnoremap <silent> <ESC> :noh<CR>
    311 nnoremap <ESC>[ <ESC>[
    312 
    313 " ZZ is save and quit and ZQ is just quit, so...
    314 " make ZS to save without closing
    315 nnoremap ZS :w<CR>
    316 " make ZA save and quit all windows
    317 nnoremap ZA :wqall<CR>
    318 
    319 " C changes until end of line and D deletes until end of line, so why not Y?
    320 noremap Y y$
    321 
    322 " repeat colon commands
    323 nnoremap Q :<Up><CR>
    324 
    325 " keep selected area when indenting
    326 vnoremap > >gv
    327 vnoremap < <gv
    328 
    329 " easily change buffers
    330 nnoremap <C-H> :bprev<CR>
    331 nnoremap <C-L> :bnext<CR>
    332 
    333 " improve up and down shortcuts
    334 nnoremap <C-J> <C-D>
    335 nnoremap <C-K> <C-U>
    336 
    337 nnoremap <silent> <leader>m :silent! make<CR>
    338 nnoremap <silent> <leader>c :!ctags -R .<CR>
    339 
    340 " pair completion{{{2
    341 inoremap {        {}<Left>
    342 inoremap {<CR>    {<CR>}<Esc>O
    343 inoremap {<Space> {<Space><Space>}<Left><Left>
    344 inoremap {{       {
    345 inoremap {}       {}
    346 
    347 inoremap (        ()<Left>
    348 inoremap (<CR>    (<CR>)<Esc>O
    349 inoremap (<Space> (<Space><Space>)<Left><Left>
    350 inoremap ((       (
    351 inoremap ()       ()
    352 
    353 inoremap [        []<Left>
    354 inoremap [<CR>    [<CR>]<Esc>O
    355 inoremap [<Space> [<Space><Space>]<Left><Left>
    356 inoremap [[       [
    357 inoremap []       []
    358 
    359 inoremap <>       <><Left>
    360 inoremap ""       ""<Left>
    361 inoremap ''       ''<Left>
    362 inoremap ``       ``<Left>
    363 inoremap `<CR>    ```<CR>```<Esc>O
    364 inoremap $$       $$<Left>
    365 inoremap %%       %%<Left>
    366 
    367 inoremap /*       /*  */<Left><Left><Left>