]> git.rmz.io Git - dotfiles.git/blobdiff - vim/vimrc
vim: center after ^{O,I} jumps
[dotfiles.git] / vim / vimrc
index dd4b7b7cec69f1da2024d23fb0f2efb1e33ed6b3..e59de75bc58b49fc79d70d8c85b15cf7bccdde04 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -29,6 +29,8 @@ Plugin 'raimondi/delimitmate'
 " Plugin 'rking/ag.vim'
 Plugin 'scrooloose/nerdtree'
 Plugin 'scrooloose/syntastic'
+Plugin 'shougo/vimproc.vim'
+Plugin 'shougo/unite.vim'
 Plugin 'sjl/gundo.vim'
 Plugin 'tomtom/tcomment_vim'
 Plugin 'tpope/vim-endwise'
@@ -63,8 +65,6 @@ Plugin 'justinmk/vim-sneak'
 Plugin 'chrisbra/checkattach'
 Plugin 'nathanaelkane/vim-indent-guides'
 Plugin 'alx741/vinfo'
-Plugin 'shougo/vimproc.vim'
-Plugin 'shougo/unite.vim'
 
 " remove entries first
 set runtimepath -=$HOME/.vim
@@ -100,7 +100,7 @@ set showbreak=↪                 " show these chars for wrapped lines
 set lazyredraw                  " don't redraw while executing macros
 
 set list                        " show chars defined in 'listchars'
-set listchars=tab:â\96¸\            " list of strings used for list mode
+set listchars=tab:â\9d­\            " list of strings used for list mode
 set listchars+=extends:❯,precedes:❮
 " Only shown when not in insert mode
 augroup trailing
@@ -313,6 +313,8 @@ nmap <Leader># :%s:<C-R>/::gn<CR>
 " center cursor after search and open folds
 nnoremap n nzzzv
 nnoremap N Nzzzv
+nnoremap ^O ^Ozzzv
+nnoremap ^I ^Izzzv
 
 " same when jumping around
 nnoremap g; g;zzzv
@@ -381,10 +383,13 @@ map Q gq
 " break undo sequence before removing word
 inoremap <C-W> <C-G>u<C-W>
 
-nmap <Leader>b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
-nmap <Leader>B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4<CR>
-nmap <Leader>M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4<CR>
-nmap <Leader>m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
+nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
+nnoremap [oe :set expandtab<CR>
+nnoremap ]oe :set noexpandtab<CR>
+
+for idt in range(1,8)
+  exe 'nnoremap co'.idt.' :set tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
+endfor
 
 " space will toggle current fold in normal mode
 nnoremap <leader><Space> za
@@ -428,7 +433,7 @@ autocmd BufReadPost fugitive://* set bufhidden=delete
 
 nnoremap <silent> <leader>gs :Gstatus<CR>
 nnoremap <silent> <leader>gd :Gdiff<CR>
-nnoremap <silent> <leader>gc :tab Gcommit -v<CR>
+nnoremap <silent> <leader>gc :Gcommit -v<CR>
 nnoremap <silent> <leader>ga :Gwrite<cr>
 nnoremap <silent> <leader>gb :Gblame<cr>
 
@@ -513,11 +518,14 @@ let g:UltiSnipsListSnippets="<c-e>"
 " unite {{{2
 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 call unite#custom#profile('default', 'context', {
-            \ 'start_insert': 1,
             \ 'winheight': 20,
             \ 'direction': 'botright'
             \ })
 
+nnoremap [unite] <Nop>
+nmap <leader>u [unite]
+
+" unite-grep {{{3
 " seems not respected
 let g:unite_source_grep_max_candidates = 2000
 if executable('ag')
@@ -526,12 +534,33 @@ if executable('ag')
     let g:unite_source_grep_default_opts = '--smart-case -w --vimgrep --hidden --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
     let g:unite_source_grep_recursive_opt = ''
 end
-
-nnoremap [unite] <Nop>
-nmap <leader>u [unite]
-nnoremap <silent> [unite]f :<C-u>Unite buffer file_rec<CR>
 nnoremap <silent> [unite]a :<C-u>Unite grep -input=\12\17<CR>
 
+" unite-file_rec {{{3
+if executable('ag')
+    " Use ag in unite rec source
+    let g:unite_source_rec_async_command = 'ag --follow --nocolor --nogroup --hidden -g ""'
+end
+nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
+
+" unite-buffer {{{3
+call unite#custom#default_action('buffer', 'goto')
+nnoremap <silent> [unite]b :<C-u>Unite buffer<CR>
+
+" unite-menu {{{3
+let g:unite_source_menu_menus = {}
+let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
+let g:unite_source_menu_menus.fugitive.command_candidates = {
+            \ 'Gstatus <Leader>gs' : 'Gstatus',
+            \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
+            \ 'Glog' : 'Glog',
+            \}
+
+nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
+
+let g:unite_source_history_yank_enable = 1
+nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
+
 " yankring {{{2
 nnoremap <silent> <leader>p :YRShow<cr>
 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
@@ -613,7 +642,7 @@ nmap <leader>ev :call EditConfig('vimrc')<CR>
 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 nmap <leader>es :call EditConfig('syntax')<CR>
 nmap <leader>ei :call EditConfig('indent')<CR>
-nmap <leader>eu :UltiSnipsEdit<CR>
+nmap <leader>eu :UltiSnipsEdit<CR>:lcd %:p:h<CR>
 
 " spell check {{{2
 " http://tex.stackexchange.com/a/52932