Compare commits

...

13 commits

Author SHA1 Message Date
John Remmen
2bb2425387
Merge pull request #56 from tacahiroy/fix-e1208
Fix E1208 started showing up in Vim v8.2.3149
2021-11-30 14:20:45 -08:00
Takahiro Yoshihara
84d148676e Fix E1208 started showing up in Vim v8.2.3149
`-complete` is not needed since :RgRoot` takes no arguments.
2021-07-12 10:03:02 +09:00
John Remmen
ec87af6b69
Merge pull request #28 from watsoncj/master
Allow passing arbitrary arguments and paths to Rg command, thanks @watsoncj
2018-09-08 19:26:08 -07:00
Casey Watson
8d27cd24cd 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
2018-08-24 13:50:49 -06:00
John Remmen
f7c1549c0b
Merge pull request #27 from kkpattern/master
Hide the search output during the search.
2018-08-13 21:59:00 -07:00
John Remmen
63df8132f5
Merge pull request #21 from craigjb/master
smartcase, ignorecase, and visual selection
2018-08-13 21:55:08 -07:00
Zhang Kai
d112b6127f Fix redirect shellpipe cause no match on windows platform bug. 2018-08-14 12:34:41 +08:00
Zhang Kai
552232da7c Hide display during search. 2018-08-14 12:01:21 +08:00
=
0df3ac2c3e Respect vim's smartcase and ignorecase options.
Resolve's https://github.com/jremmen/vim-ripgrep/issues/5
2018-03-20 23:53:34 -07:00
=
7d01d6976b Add function for searching a visual selection 2018-03-20 23:43:12 -07:00
John Remmen
88ce3691b6
Merge pull request #19 from jremmen/window-location
Allow setting of quickfix window location
2018-03-11 14:35:43 -07:00
John Remmen
6e2fdfe189
Update README.md 2018-03-11 14:31:28 -07:00
jremmen
1e9f916d34 Allow setting of quickfix window location 2018-03-11 14:27:32 -07:00
2 changed files with 45 additions and 11 deletions

View file

@ -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

View file

@ -20,10 +20,31 @@ 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! 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("<cword>")
@ -33,9 +54,16 @@ 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())
copen
exe g:rg_window_location 'copen'
redraw!
if exists('g:rg_highlight')
call s:RgHighlight(a:txt)
@ -54,8 +82,12 @@ 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=
if !has("win32")
let &shellpipe="&>"
endif
if exists('g:rg_derive_root')
call s:RgPathContext(a:search, a:txt)
@ -63,6 +95,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
@ -113,4 +146,4 @@ fun! s:RgShowRoot()
endfun
command! -nargs=* -complete=file Rg :call s:Rg(<q-args>)
command! -complete=file RgRoot :call s:RgShowRoot()
command! RgRoot :call s:RgShowRoot()