]> oss.titaniummirror.com Git - smckown/dotfiles.git/blobdiff - vim/vimrc
ssh: add agent forwarding for negadon
[smckown/dotfiles.git] / vim / vimrc
index 549623d607ba3f8aca59b405537dd7627453e369..ab4b160229d06d0d29f1244438cd0bfdaf3aa039 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -23,6 +23,9 @@ call pathogen#helptags()
 runtime! plugin/sensible.vim
 nnoremap Y Y
 
+" Update wildmenu from sensible defaults
+set wildmode=longest:full,full
+
 " Set the correct font for gvim
 if has("gui_running")
   if has("gui_gtk2")
@@ -70,15 +73,24 @@ set list
 " Set default indent policy.  smarttab, roundshift enabled by sensible
 set softtabstop=2 shiftwidth=2 expandtab
 
+" cinoptions for code formatting
+set cinoptions=t0,U1,k2s,j1,J1
+
 " File type specific settings.
 if has("autocmd")
+  autocmd BufNewFile,BufRead /run/shm/* set nobackup nowritebackup noundofile
+    \ noswapfile viminfo="" noshelltemp history=0 nomodeline secure
   autocmd filetype make setlocal sts=0 sw=8 noexpandtab tw=80 fo-=t fo+=j
   autocmd filetype sh,ld setlocal sts=4 sw=4 tw=80 fo-=t fo+=j
   autocmd filetype python setlocal sts=4 sw=4 tw=79 fo-=t fo+=j
   autocmd filetype html,xml setlocal listchars-=tab:>. tw=80 fo-=t fo+=j
-  autocmd filetype text,markdown,mkd,md setlocal tw=80 fo-=t fo+=j
-  autocmd filetype c,cpp,java setlocal tw=80 fo-=t fo+=j
-  autocmd filetype nesc setlocal syntax=c.doxygen tw=80 fo-=t fo+=j
+  autocmd filetype markdown,mkd,md setlocal tw=80 fo-=t fo+=j
+  autocmd filetype c,cpp,java setlocal tw=80 fo+=jt
+  autocmd filetype nesc setlocal syntax=c.doxygen tw=80 fo+=jt
+  autocmd filetype text setlocal tw=80 fo+=jt
+  autocmd filetype tex setlocal tw=80 fo+=jt
+
+  autocmd BufReadPre README*,TODO*,INSTALL* setlocal tw=80 fo+=t
 
   " Whitelist for auto-stripping trailing whitespace on buffer write
   autocmd BufWritePre *.c,*.h,*.nesc,*.py,*.java,*.sh,make :call <SID>StripTrailingWhitespace()
@@ -173,12 +185,6 @@ set tags=tags;/
 " %% on an ex command line expands to the dir path of the current buffer
 cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
 
-" Create some edit maps for opening new files
-map <leader>ew :e %%<CR>
-map <leader>es :sp %%<CR>
-map <leader>ev :vsp %%<CR>
-map <leader>et :tabe %%<CR>
-
 " Make <C-]> and g] work like g<C-]>, which uses :tjump
 nnoremap g] g<C-]>
 nnoremap <C-]> g<C-]>
@@ -215,14 +221,13 @@ nnoremap <silent> <leader>gs :Gstatus<CR>
 nnoremap <silent> <leader>gd :Gdiff<CR>
 nnoremap <silent> <leader>gc :Gcommit<CR>
 nnoremap <silent> <leader>gb :Gblame<CR>
-nnoremap <silent> <leader>gl :Glog<CR>
+nnoremap <silent> <leader>gl :Git log<CR>
 nnoremap <silent> <leader>gp :Git push<CR>
 nnoremap <silent> <leader>gr :Gread<CR>
 nnoremap <silent> <leader>gw :Gwrite<CR>
 "nnoremap <silent> <leader>ge :Gedit<CR>
 nnoremap <silent> <leader>gi :Git add -p %<CR>
 nnoremap <leader>gg :Ggrep<SPACE>
-nnoremap <leader>G :Git<SPACE>
 
 " EasyGrep
 " To ignore tags file, use system grep.
@@ -268,10 +273,10 @@ nmap <Leader>w <Plug>(easymotion-bd-w)
 nmap <Leader>b <Plug>(easymotion-bd-w)
 nmap <Leader>W <Plug>(easymotion-bd-W)
 nmap <Leader>B <Plug>(easymotion-bd-W)
-nmap <Leader>e <Plug>(easymotion-bd-e)
-nmap <Leader>E <Plug>(easymotion-bd-E)
-nmap <Leader>ge <Plug>(easymotion-bd-e)
-nmap <Leader>gE <Plug>(easymotion-bd-E)
+"nmap <Leader>e <Plug>(easymotion-bd-e)
+"nmap <Leader>E <Plug>(easymotion-bd-E)
+"nmap <Leader>ge <Plug>(easymotion-bd-e)
+"nmap <Leader>gE <Plug>(easymotion-bd-E)
 nmap <Leader>j <Plug>(easymotion-bd-jk)
 nmap <Leader>k <Plug>(easymotion-bd-jk)
 nmap <Leader>n <Plug>(easymotion-bd-n)
@@ -314,22 +319,6 @@ nmap <leader>7 <Plug>AirlineSelectTab7
 nmap <leader>8 <Plug>AirlineSelectTab8
 nmap <leader>9 <Plug>AirlineSelectTab9
 
-" Highlight only long lines
-" This solution has two problems:
-" 1. On first file edit, the status bar does not render until a key is pressed
-" 2. When creating new lines the last column isn't known until it's arrived
-"augroup collumnLimit
-"  autocmd!
-"  autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make
-"        \ highlight CollumnLimit ctermbg=LightGrey guibg=LightGrey
-"  let collumnLimit = 79
-"  let pattern =
-"        \ '\%<' . (collumnLimit+1) . 'v.\%>' . collumnLimit . 'v'
-"  autocmd BufEnter,WinEnter,FileType scala,java,c,nesc,make
-"        \ let w:m1=matchadd('CollumnLimit', pattern, -1)
-"augroup END
-
-" The simpler solution to the above, which generates a column
 if exists('+colorcolumn')
   if v:version >= 703
     " Set color column relative to defined textwidth.
@@ -347,10 +336,16 @@ let g:delimitMate_matchpairs = "{:},[:],(:)"
 let g:delimitMate_autoclose = 1
 let g:delimitMate_expand_cr = 1
 let g:delimitMate_expand_space = 1
-nnoremap coa :DelimitMateSwitch<CR>
+" cop means to toggle auto pairing
+nnoremap cop :DelimitMateSwitch<CR>
+
+" Toggle git gutter
+nnoremap cog :GitGutterToggle<CR>
 
-" Rainbow Parenthesis -- off by default but set toggle
-nnoremap cop :RainbowParenthesesToggle<CR>
+" mkbuild code search tools
+nnoremap <leader>e :<C-u>Unite -start-insert -buffer-name=files mkbuild/file_xref<CR>
+nnoremap <leader>E :<C-u>Unite -start-insert -buffer-name=files mkbuild/file<CR>
+nnoremap <leader>x :<C-u>Unite -buffer-name=xrefs mkbuild/xref<cr>
 
 " Turn on doxygen syntax highlighting for C, C++, C# and IDL files.
 let g:load_doxygen_syntax=1
@@ -377,15 +372,57 @@ function! ToggleFormatOptionT()
   let tmp = substitute(&formatoptions, 't', '', '')
   if &formatoptions == tmp
     set fo+=t
-    :echo "Enable text wrap"
+    :echo ":set fo+=t"
   else
     set fo-=t
-    :echo "Disable text wrap"
+    :echo ":set fo-=t"
+  endif
+endfunction
+
+" Implement 'coa' -- Toggle formatoption 'a' -- auto-wrap paragraphs
+nnoremap coa :call ToggleFormatOptionA()<CR>
+function! ToggleFormatOptionA()
+  let tmp = substitute(&formatoptions, 'a', '', '')
+  if &formatoptions == tmp
+    set fo+=a
+    :echo ":set fo+=a"
+  else
+    set fo-=a
+    :echo ":set fo-=a"
   endif
 endfunction
 
 " Insert date and time in insert mode.  Have to use the native <Leader>, not
 " its re-mapped version <space>
-imap <leader>d <C-R>=strftime("%Y%m%d")<CR>
-imap <leader>D <C-R>=strftime("%Y-%m-%d")<CR>
-imap <leader>t <C-R>=strftime("%H:%M:%S")<CR>
+"nmap <leader>dd "=strftime('%Y%m%d')<CR>p
+"imap <leader>dd <C-R>=strftime('%Y%m%d')<CR>
+"nmap <leader>dD "=strftime('%Y-%m-%d')<CR>p
+"imap <leader>dD <C-R>=strftime('%Y-%m-%d')<CR>
+"nmap <leader>dt "=strftime('%H:%M:%S')<CR>p
+"imap <leader>dt <C-R>=strftime('%H:%M:%S')<CR>
+
+" Unite
+let g:unite_source_history_yank_enable = 1
+"call unite#filters#matcher_default#use(['matcher_fuzzy'])
+nnoremap <leader>uf :<C-u>Unite -no-split -start-insert -buffer-name=files file_rec<cr>
+nnoremap <leader>uy :<C-u>Unite -no-split -buffer-name=yank history/yank<cr>
+nnoremap <leader>ub :<C-u>Unite -no-split -start-insert -buffer-name=buffer buffer<cr>
+nnoremap <leader>uo :<C-u>Unite -no-split -start-insert -buffer-name=outline outline<cr>
+nnoremap <leader>ul :<C-u>Unite -no-split -start-insert -buffer-name=lines line<cr>
+nnoremap <leader>uc :<C-u>Unite -no-split -start-insert -buffer-name=quicklist qf<cr>
+nnoremap <leader>ut :<C-u>Unite -no-split -start-insert -buffer-name=tags tag<cr>
+nnoremap <leader>: :<C-u>Unite -start-insert -buffer-name=command history/command<cr>
+nnoremap <leader>/ :<C-u>Unite -start-insert -buffer-name=search history/search<cr>
+
+" Custom mappings for the unite buffer
+autocmd FileType unite call s:unite_settings()
+function! s:unite_settings()
+  "setlocal noswapfile undolevels=-1
+  " Play nice with supertab
+  let b:SuperTabDisabled=1
+  " Enable navigation with control-j and control-k in insert mode
+  imap <buffer> <C-n> <Plug>(unite_select_next_line)
+  imap <buffer> <C-p> <Plug>(unite_select_previous_line)
+  imap <buffer> <CR> <Plug>(unite_do_default_action)
+  nmap <buffer> <ESC> <Plug>(unite_exit)
+endfunction