Commit 30b441a7 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Correct vim's &grepprg escaping and add AsyncGrep

The `&grepprg` option is now corrected back to it's escaped form and
a new command `AsyncGrep` has been added to make use of it correctly in
AsyncRun commands.
parent d4135380
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -142,11 +142,19 @@ nmap <silent> th :set hlsearch!<CR>

" === GREPPING ===

noremap <silent> S :AsyncRun -program=grep '\b<cword>\b'<CR>
vnoremap <silent> S ""y:AsyncRun -program=grep '\b<C-R>"\b'<CR>
let s:grepargs='-n --binary-files=without-match'
command! -bang -nargs=1 AsyncGrep
			\ exe 'AsyncRun<bang> -auto=grep'
			\ substitute(&grepprg, '\\|', '|', 'g')
			\ <q-args>

noremap <silent> S :AsyncGrep '\b<cword>\b'<CR>
vnoremap <silent> S ""y:exe 'AsyncGrep'
			\ . shellescape(escape('<C-R>"', '#%<?+{\|()'))
			\ <CR>

let s:grepargs='-En --binary-files=without-match'
if executable("list-files")
	let &grepprg = 'list-files -z | xargs -r0 grep ' . s:grepargs
	let &grepprg = 'list-files -z\| xargs -r0 grep ' . s:grepargs
else
	let &grepprg = '~/.shell/bin/grep-auto-exclude grep $* -r . ' . s:grepargs
endif