]> git.rmz.io Git - dotfiles.git/blobdiff - vim/vimrc
vim: introduce characterize and replace easy align mapping
[dotfiles.git] / vim / vimrc
index 8a623f4c5a1ebdce65f146749c1f87625fa5d044..19208e52643c3680d70a9d0d3d9c12d46aa2afa8 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,8 +1,3 @@
-" My vimrc.
-"
-" Author:   Samir Benmendil <samir.benmendil[at]gmail[dot]com>
-"
-
 " runtimepath {{{1
 set runtimepath ^=$XDG_CONFIG_HOME/vim
 set runtimepath +=$XDG_CONFIG_HOME/vim/after
@@ -54,6 +49,7 @@ Plug 'sjl/gundo.vim'
 Plug 'thinca/vim-qfreplace'
 Plug 'tomtom/tcomment_vim'
 Plug 'tpope/vim-abolish'
+Plug 'tpope/vim-characterize'
 Plug 'tpope/vim-endwise'
 Plug 'tpope/vim-eunuch'
 Plug 'tpope/vim-fugitive'
@@ -397,10 +393,14 @@ augroup END
 map <space> <leader>
 
 " make
-function! Make()
+function! MakeWithOpt()
+  " TODO only do this if makeprg matches make
+  " if &makeprg =~ "make"
   let l:make_dir = ""
   if exists("b:make_dir")
     let l:make_dir = "-C ".b:make_dir
+  elseif exists("t:make_dir")
+    let l:make_dir = "-C ".t:make_dir
   elseif exists("g:make_dir")
     let l:make_dir = "-C ".g:make_dir
   endif
@@ -409,9 +409,9 @@ function! Make()
   if exists("g:make_targets")
     let l:make_targets = g:make_targets
   endif
-  execute "make! ".l:make_dir." ".l:make_targets
+  execute "Make ".l:make_dir." ".l:make_targets
 endf
-nnoremap <leader>r :call Make()<cr>
+nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
 
 " unhighlight search
 nnoremap <silent> <Leader>/ :silent nohl<CR>
@@ -608,7 +608,18 @@ nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 " delete fugitive buffers when closed
 autocmd BufReadPost fugitive://* set bufhidden=delete
 
-nnoremap <silent> <leader>gs :Git<CR>
+function! GitToggle()
+  if buflisted(bufname('.git/index'))
+    bdelete .git/index
+  else
+    Git
+    16wincmd_
+  endif
+endfunction
+command! GitToggle :call GitToggle()
+command! GToggle GitToggle
+nnoremap <silent> <leader>gs :GitToggle<CR>
+
 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR> 
 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
@@ -625,7 +636,8 @@ nnoremap <silent> <leader>gb :G blame<cr>
 
 augroup fugitive_gstatus
     au!
-    autocmd BufWinEnter */.git/index resize 16
+    autocmd User FugitiveIndex setlocal winfixheight
+    autocmd User FugitiveIndex nmap <buffer> <leader><space> =
 augroup end
 
 " Gundo {{{2
@@ -669,6 +681,9 @@ let g:SignatureMap = {
 
 " switch
 let g:switch_mapping = "<Leader>s"
+let g:switch_custom_definitions = [
+      \   ['yes', 'no']
+      \ ]
 
 " spellrotate
 nmap <silent> z] <Plug>(SpellRotateForward)
@@ -822,8 +837,9 @@ let g:ycm_language_server =
 
 " vim-easy-align {{{2
 " start interactive EasyAlign in visual mode
-vmap <Enter> <Plug>(EasyAlign)
-nmap ga <Plug>(EasyAlign)
+vmap <Enter>   <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to \16<leader>a now" \| echohl None<CR>
+vmap <leader>a <Plug>(EasyAlign)
+nmap <leader>a <Plug>(EasyAlign)
 
 " vim-gtest {{{2
 let g:gtest#highlight_failing_tests = 0