Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

2 changed files with 11 additions and 45 deletions

View file

@ -7,15 +7,14 @@ 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
| g:rg_window_location | botright | quickfix window location
| 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
## misc

View file

@ -20,31 +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! 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>")
@ -54,16 +33,9 @@ fun! s:RgSearchTerm(txt)
endfun
fun! s:RgSearch(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
silent! exe 'grep! ' . a:txt
if len(getqflist())
exe g:rg_window_location 'copen'
copen
redraw!
if exists('g:rg_highlight')
call s:RgHighlight(a:txt)
@ -82,12 +54,8 @@ 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)
@ -95,7 +63,6 @@ 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
@ -146,4 +113,4 @@ fun! s:RgShowRoot()
endfun
command! -nargs=* -complete=file Rg :call s:Rg(<q-args>)
command! RgRoot :call s:RgShowRoot()
command! -complete=file RgRoot :call s:RgShowRoot()