dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit 4c4f66d9ac1d08def63e827662f346c29327c5c5 (patch)
parent 71cbbceeec3baf68a9fdc1150baa7e293175f53f
Author: Alex Karle <alex@karle.co>
Date:   Mon,  4 Nov 2019 17:27:26 -0500

vim: use tpope's :Ggrep over home-rolled :GitGrep, update mappings

My GitGrep served me very well over the years, but tpope added :Ggrep to
fugitive, and, well, his is of course more robust and more clever!

This commit removes my home-rolled solution in favor of the fugitive
plugin.

Additionally, two mapping changes:

1) inoremap <C-U> to save in the undo chain
2) Remove arrow key mappings -- these were throwing other vimmer's off
   when they used my setup!

Diffstat:
Mvim/autoload/vimrc.vim | 51---------------------------------------------------
Mvim/vimrc | 11++++-------
2 files changed, 4 insertions(+), 58 deletions(-)

diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim @@ -1,8 +1,6 @@ " autoload/vimrc.vim -- functions to be called in vimrc " " See `:h autoload-functions` for explanation of autoloading and performance - - function! vimrc#ToggleColorColumn() abort if &colorcolumn == "" set colorcolumn=80 @@ -11,55 +9,6 @@ function! vimrc#ToggleColorColumn() abort endif endfunction -" Searches all of project for word under cursor -function! vimrc#GitGrep(word) abort - if s:InGitRepo() - let raw = system('git grep -n ' . a:word) - let matches = split(raw, '\n') - let qfitems = [] - for m in matches - let items = split(m, ':') - " Rare case that we match a binary file - if len(items) < 3 - continue - endif - let d = { - \'filename': items[0], - \'lnum': items[1], - \'text': join(items[2:], '') - \} - - let qfitems += [d] - endfor - call setqflist(qfitems, 'r') - else - call utils#warn("called GitGrepWordUnderCursor outside of git repo") - endif -endfunction - -function! vimrc#GitGrepWordUnderCursor() abort - let word = substitute(expand('<cword>'), '#', '\\#', 'g') - call vimrc#GitGrep(word) -endfunction - -function! s:InGitRepo() abort - if has('win64') || has('win32') - let fsep = '\' - else - let fsep = '/' - endif - let dir_list = split(getcwd(), fsep) - let running_path = '' - for dir in dir_list - let running_path = join([running_path, dir], fsep) - let f = running_path . fsep . '.git' - if filereadable(f) || isdirectory(f) - return 1 - endif - endfor - return 0 -endfunction - function! vimrc#SetPasteAndPasteFromClipboard() abort set paste normal! "+p diff --git a/vim/vimrc b/vim/vimrc @@ -164,18 +164,12 @@ nnoremap <expr> <leader>C vimrc#ToggleColorColumn() nnoremap <leader>2 :setlocal softtabstop=2 shiftwidth=2<CR> nnoremap <leader>4 :setlocal softtabstop=4 shiftwidth=4<CR> -" Faster file navigation -nnoremap <LEFT> :cprev<CR> -nnoremap <RIGHT> :cnext<CR> -nnoremap <UP> :prev<CR> -nnoremap <DOWN> :next<CR> - " Clear that highlight! nnoremap <BS> :nohlsearch<CR> " Get greppin quick! --> search word under cursor (escape # for VimL autoload) nnoremap <leader>g :exe "grep " . substitute(expand('<cword>'), '#', '\\#', 'g')<CR> -nnoremap <silent> <leader>G :call vimrc#GitGrepWordUnderCursor()<CR>:copen<CR> +nnoremap <silent> <leader>G :Ggrep! <cword><CR>:copen<CR> " Toggle whitespace nnoremap <leader>w :set list!<CR> @@ -185,6 +179,9 @@ nnoremap <leader>y gg"+yG<C-O><C-O> " Edit vimrc nnoremap <leader>V :edit $HOME/.vim/vimrc<CR> + +" From defaults.vim: breaks the undo chain so we can undo <C-U> +inoremap <C-U> <C-G>u<C-U> " }}} " COMMANDS {{{