From 1e9f916d34497b1ff1b40c61898bfec1d9e4b0fd Mon Sep 17 00:00:00 2001 From: jremmen Date: Sun, 11 Mar 2018 14:02:21 -0700 Subject: [PATCH 1/8] Allow setting of quickfix window location --- plugin/vim-ripgrep.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 7e12922..3069eb2 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -20,6 +20,10 @@ if !exists('g:rg_root_types') let g:rg_root_types = ['.git'] endif +if !exists('g:rg_window_location') + let g:rg_window_location = 'botright' +endif + fun! s:Rg(txt) call s:RgGrepContext(function('s:RgSearch'), s:RgSearchTerm(a:txt)) endfun @@ -35,7 +39,7 @@ endfun fun! s:RgSearch(txt) silent! exe 'grep! ' . a:txt if len(getqflist()) - copen + exe g:rg_window_location 'copen' redraw! if exists('g:rg_highlight') call s:RgHighlight(a:txt) From 6e2fdfe1898b26a69e6af5794570fbb68803446d Mon Sep 17 00:00:00 2001 From: John Remmen Date: Sun, 11 Mar 2018 14:31:28 -0700 Subject: [PATCH 2/8] Update README.md --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 915183c..bbcd646 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,15 @@ Word under cursor will be searched if no argument is passed to `Rg` ## configuration -| Setting | Default | Details -| -----------------|---------------------------|---------- -| g:rg_binary | rg | path to rg -| g:rg_format | %f:%l:%c:%m | value of grepformat -| g:rg_command | g:rg_binary --vimgrep | search command -| g:rg_highlight | false | true if you want matches highlighted -| g:rg_derive_root | false | true if you want to find project root from cwd -| g:rg_root_types | ['.git'] | list of files/dir found in project root +| Setting | Default | Details +| ---------------------|---------------------------|---------- +| g:rg_binary | rg | path to rg +| g:rg_format | %f:%l:%c:%m | value of grepformat +| g:rg_command | g:rg_binary --vimgrep | search command +| g:rg_highlight | false | true if you want matches highlighted +| g:rg_derive_root | false | true if you want to find project root from cwd +| g:rg_root_types | ['.git'] | list of files/dir found in project root +| g:rg_window_location | botright | quickfix window location ## misc From 7d01d6976b1932e289d82cd1ee063313adea5a7b Mon Sep 17 00:00:00 2001 From: = Date: Tue, 20 Mar 2018 23:43:12 -0700 Subject: [PATCH 3/8] Add function for searching a visual selection --- plugin/vim-ripgrep.vim | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 3069eb2..0a1cd16 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -24,10 +24,27 @@ if !exists('g:rg_window_location') let g:rg_window_location = 'botright' endif +fun! g:RgVisual() range + call s:RgGrepContext(function('s:RgSearch'), s:RgGetVisualSelection()) +endfun + fun! s:Rg(txt) call s:RgGrepContext(function('s:RgSearch'), s:RgSearchTerm(a:txt)) endfun +fun! s:RgGetVisualSelection() + " Why is this not a built-in Vim script function?! + let [line_start, column_start] = getpos("'<")[1:2] + let [line_end, column_end] = getpos("'>")[1:2] + let lines = getline(line_start, line_end) + if len(lines) == 0 + return '' + endif + let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)] + let lines[0] = lines[0][column_start - 1:] + return join(lines, "\n") +endfun + fun! s:RgSearchTerm(txt) if empty(a:txt) return expand("") @@ -37,7 +54,7 @@ fun! s:RgSearchTerm(txt) endfun fun! s:RgSearch(txt) - silent! exe 'grep! ' . a:txt + silent! exe 'grep! ' . '"' . a:txt . '"' if len(getqflist()) exe g:rg_window_location 'copen' redraw! From 0df3ac2c3e51d27637251a5849f892c3a0f0bce0 Mon Sep 17 00:00:00 2001 From: = Date: Tue, 20 Mar 2018 23:53:34 -0700 Subject: [PATCH 4/8] Respect vim's smartcase and ignorecase options. Resolve's https://github.com/jremmen/vim-ripgrep/issues/5 --- plugin/vim-ripgrep.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 0a1cd16..ba41aa8 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -54,7 +54,14 @@ fun! s:RgSearchTerm(txt) endfun fun! s:RgSearch(txt) - silent! exe 'grep! ' . '"' . a:txt . '"' + let l:rgopts = ' ' + if &ignorecase == 1 + let l:rgopts = l:rgopts . '-i ' + endif + if &smartcase == 1 + let l:rgopts = l:rgopts . '-S ' + endif + silent! exe 'grep! ' . l:rgopts . '"' . a:txt . '"' if len(getqflist()) exe g:rg_window_location 'copen' redraw! From 552232da7c1d992af0e0a98fcbfcca94d11af0a9 Mon Sep 17 00:00:00 2001 From: Zhang Kai Date: Tue, 14 Aug 2018 12:01:21 +0800 Subject: [PATCH 5/8] Hide display during search. --- plugin/vim-ripgrep.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 3069eb2..d46c57a 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -58,8 +58,10 @@ fun! s:RgGrepContext(search, txt) let &grepformat = g:rg_format let l:te = &t_te let l:ti = &t_ti + let l:shellpipe_bak=&shellpipe set t_te= set t_ti= + let &shellpipe="&>" if exists('g:rg_derive_root') call s:RgPathContext(a:search, a:txt) @@ -67,6 +69,7 @@ fun! s:RgGrepContext(search, txt) call a:search(a:txt) endif + let &shellpipe=l:shellpipe_bak let &t_te=l:te let &t_ti=l:ti let &grepprg = l:grepprgb From d112b6127f7fa3ec7aed467f73ab6401fc13ab06 Mon Sep 17 00:00:00 2001 From: Zhang Kai Date: Tue, 14 Aug 2018 12:34:41 +0800 Subject: [PATCH 6/8] Fix redirect shellpipe cause no match on windows platform bug. --- plugin/vim-ripgrep.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index d46c57a..332f11d 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -61,7 +61,9 @@ fun! s:RgGrepContext(search, txt) let l:shellpipe_bak=&shellpipe set t_te= set t_ti= - let &shellpipe="&>" + if !has("win32") + let &shellpipe="&>" + endif if exists('g:rg_derive_root') call s:RgPathContext(a:search, a:txt) From 8d27cd24cd2489650cb8e723e9a1723e479c6d36 Mon Sep 17 00:00:00 2001 From: Casey Watson Date: Fri, 24 Aug 2018 13:41:36 -0600 Subject: [PATCH 7/8] Allow passing arbitrary arguments and paths to Rg command - Only wrap the search string in quotes during visual search. As was the behavior prior to 7d01d697. - Restore the ability to use all ripgrep features from command mode: `:Rg --fixed-strings \.Model service/` fixes #25 --- plugin/vim-ripgrep.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 47e362b..9bc029d 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -25,7 +25,7 @@ if !exists('g:rg_window_location') endif fun! g:RgVisual() range - call s:RgGrepContext(function('s:RgSearch'), s:RgGetVisualSelection()) + call s:RgGrepContext(function('s:RgSearch'), '"' . s:RgGetVisualSelection() . '"') endfun fun! s:Rg(txt) @@ -61,7 +61,7 @@ fun! s:RgSearch(txt) if &smartcase == 1 let l:rgopts = l:rgopts . '-S ' endif - silent! exe 'grep! ' . l:rgopts . '"' . a:txt . '"' + silent! exe 'grep! ' . l:rgopts . a:txt if len(getqflist()) exe g:rg_window_location 'copen' redraw! From 84d148676e3649fce4db94424937df54b536addb Mon Sep 17 00:00:00 2001 From: Takahiro Yoshihara Date: Mon, 12 Jul 2021 09:59:55 +0900 Subject: [PATCH 8/8] Fix E1208 started showing up in Vim v8.2.3149 `-complete` is not needed since :RgRoot` takes no arguments. --- plugin/vim-ripgrep.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 9bc029d..7188001 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -146,4 +146,4 @@ fun! s:RgShowRoot() endfun command! -nargs=* -complete=file Rg :call s:Rg() -command! -complete=file RgRoot :call s:RgShowRoot() +command! RgRoot :call s:RgShowRoot()