aboutsummaryrefslogtreecommitdiffstats
path: root/vim
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-06-02 06:52:35 +0100
committerMatthew Lemon <y@yulqen.org>2024-06-02 06:52:35 +0100
commit6a20e9a526ca1ab981eb75c620f6027f0b8e67ab (patch)
tree69264385bf23fd6b2d6ef93e6acad3ee8d22a6b9 /vim
parent691edb730a3c7ff2931fe62fa601f12ac561ca97 (diff)
Adds back grep.vim
Diffstat (limited to 'vim')
-rw-r--r--vim/grep.vim17
1 files changed, 17 insertions, 0 deletions
diff --git a/vim/grep.vim b/vim/grep.vim
new file mode 100644
index 0000000..93f52fb
--- /dev/null
+++ b/vim/grep.vim
@@ -0,0 +1,17 @@
+set grepprg=ag\ --vimgrep
+
+function! Grep(...)
+ return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' '))
+endfunction
+
+command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>)
+command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>)
+
+cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep'
+cnoreabbrev <expr> lgrep (getcmdtype() ==# ':' && getcmdline() ==# 'lgrep') ? 'LGrep' : 'lgrep'
+
+augroup quickfix
+ autocmd!
+ autocmd QuickFixCmdPost cgetexpr cwindow
+ autocmd QuickFixCmdPost lgetexpr lwindow
+augroup END