X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=vim%2Fvimrc;h=94d8fbb141de115b86380e245e8060e19ff2ec0a;hb=d55acc1b64520f34128669919e04e020b7fd6fe4;hp=68d687ef6d73e46999cac6e705f640799e3e4b52;hpb=b4b5b5dcc5cff6d35255cf9230426ba1a07c2b8e;p=smckown%2Fdotfiles.git diff --git a/vim/vimrc b/vim/vimrc index 68d687e..94d8fbb 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -70,15 +70,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 StripTrailingWhitespace() @@ -90,9 +99,7 @@ endif " Setup swap/backup/undo " Note that as of vim 7.4, backupdir // will not expand backup files to a full " path as is the case with directory and undodir. -let s:dir = expand(has('win32') ? '~/Application Data/Vim' : has('mac') ? - \ '~/Library/Vim' : '~/.local/share/vim') -execute 'set directory^=' . s:dir . '/swap//' +let s:dir = expand(has('win32') ? '$HOME/vimfiles' : '$HOME/.vim') if !isdirectory(s:dir . '/') call mkdir(s:dir) endif @@ -105,6 +112,7 @@ endif if !isdirectory(s:dir . '/undo/') call mkdir(s:dir . '/undo') endif +execute 'set directory^=' . s:dir . '/swap//' if isdirectory(s:dir . '/backup/') execute 'set backupdir=' . s:dir . '/backup//' set backup @@ -174,12 +182,6 @@ set tags=tags;/ " %% on an ex command line expands to the dir path of the current buffer cnoremap %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' -" Create some edit maps for opening new files -map ew :e %% -map es :sp %% -map ev :vsp %% -map et :tabe %% - " Make and g] work like g, which uses :tjump nnoremap g] g nnoremap g @@ -211,6 +213,19 @@ if has("autocmd") \ endif endif +" Fugitive shortcuts +nnoremap gs :Gstatus +nnoremap gd :Gdiff +nnoremap gc :Gcommit +nnoremap gb :Gblame +nnoremap gl :Git log +nnoremap gp :Git push +nnoremap gr :Gread +nnoremap gw :Gwrite +"nnoremap ge :Gedit +nnoremap gi :Git add -p % +nnoremap gg :Ggrep + " EasyGrep " To ignore tags file, use system grep. let g:EasyGrepCommand=1 @@ -255,10 +270,10 @@ nmap w (easymotion-bd-w) nmap b (easymotion-bd-w) nmap W (easymotion-bd-W) nmap B (easymotion-bd-W) -nmap e (easymotion-bd-e) -nmap E (easymotion-bd-E) -nmap ge (easymotion-bd-e) -nmap gE (easymotion-bd-E) +"nmap e (easymotion-bd-e) +"nmap E (easymotion-bd-E) +"nmap ge (easymotion-bd-e) +"nmap gE (easymotion-bd-E) nmap j (easymotion-bd-jk) nmap k (easymotion-bd-jk) nmap n (easymotion-bd-n) @@ -334,10 +349,18 @@ let g:delimitMate_matchpairs = "{:},[:],(:)" let g:delimitMate_autoclose = 1 let g:delimitMate_expand_cr = 1 let g:delimitMate_expand_space = 1 -nnoremap coa :DelimitMateSwitch +" cop means to toggle auto pairing +nnoremap cop :DelimitMateSwitch " Rainbow Parenthesis -- off by default but set toggle -nnoremap cop :RainbowParenthesesToggle +nnoremap co( :RainbowParenthesesToggle + +" Toggle git gutter +nnoremap cog :GitGutterToggle + +" mkbuild tools +nnoremap e :Unite -start-insert -buffer-name=files mkbfiles +nnoremap x :Unite -buffer-name=xrefs xrefs " Turn on doxygen syntax highlighting for C, C++, C# and IDL files. let g:load_doxygen_syntax=1 @@ -371,8 +394,50 @@ function! ToggleFormatOptionT() endif endfunction +" Implement 'coa' -- Toggle formatoption 'a' -- auto-wrap paragraphs +nnoremap coa :call ToggleFormatOptionA() +function! ToggleFormatOptionA() + let tmp = substitute(&formatoptions, 'a', '', '') + if &formatoptions == tmp + set fo+=a + :echo "Enable auto-wrap paragraphs" + else + set fo-=a + :echo "Disable auto-wrap paragraphs" + endif +endfunction + " Insert date and time in insert mode. Have to use the native , not " its re-mapped version -imap d =strftime("%Y%m%d") -imap D =strftime("%Y-%m-%d") -imap t =strftime("%H:%M:%S") +"nmap dd "=strftime('%Y%m%d')p +"imap dd =strftime('%Y%m%d') +"nmap dD "=strftime('%Y-%m-%d')p +"imap dD =strftime('%Y-%m-%d') +"nmap dt "=strftime('%H:%M:%S')p +"imap dt =strftime('%H:%M:%S') + +" Unite +let g:unite_source_history_yank_enable = 1 +"call unite#filters#matcher_default#use(['matcher_fuzzy']) +nnoremap uf :Unite -no-split -start-insert -buffer-name=files file_rec +nnoremap uy :Unite -no-split -buffer-name=yank history/yank +nnoremap ub :Unite -no-split -start-insert -buffer-name=buffer buffer +nnoremap uo :Unite -no-split -start-insert -buffer-name=outline outline +nnoremap ul :Unite -no-split -start-insert -buffer-name=lines line +nnoremap uc :Unite -no-split -start-insert -buffer-name=quicklist qf +nnoremap ut :Unite -no-split -start-insert -buffer-name=tags tag +nnoremap : :Unite -start-insert -buffer-name=command history/command +nnoremap / :Unite -start-insert -buffer-name=search history/search + +" 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 (unite_select_next_line) + imap (unite_select_previous_line) + imap (unite_do_default_action) + nmap (unite_exit) +endfunction