From 704c1aabc843a8d9c1950afcc68daf796304b116 Mon Sep 17 00:00:00 2001 From: tankorsmash Date: Mon, 16 Mar 2020 17:20:09 -0400 Subject: [PATCH 1/2] add rg_highlight_type to use for result highlighting --- README.md | 9 +++++++-- plugin/vim-ripgrep.vim | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bbcd646..b7a2323 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # vim-ripgrep - :Rg +```vim +:Rg +``` Word under cursor will be searched if no argument is passed to `Rg` @@ -13,6 +15,7 @@ Word under cursor will be searched if no argument is passed 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_highlight_type | identifier | if `rg_highlight` is set, use this syntax color to highlight the result | 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 @@ -21,4 +24,6 @@ Word under cursor will be searched if no argument is passed to `Rg` Show root search dir - :RgRoot +```vim +:RgRoot +``` diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 9bc029d..532a81d 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -24,6 +24,10 @@ if !exists('g:rg_window_location') let g:rg_window_location = 'botright' endif +if !exists('g:rg_highlight_type') + let g:rg_highlight_type = 'keyword' +endif + fun! g:RgVisual() range call s:RgGrepContext(function('s:RgSearch'), '"' . s:RgGetVisualSelection() . '"') endfun @@ -110,8 +114,7 @@ fun! s:RgPathContext(search, txt) endfun fun! s:RgHighlight(txt) - let @/=escape(substitute(a:txt, '"', '', 'g'), '|') - call feedkeys(":let &hlsearch=1\", 'n') + call matchadd(g:rg_highlight_type, a:txt) endfun fun! s:RgRootDir() From 0ebd07d01d369489ed4389163ac9212902b2dbb2 Mon Sep 17 00:00:00 2001 From: tankorsmash Date: Mon, 16 Mar 2020 17:24:32 -0400 Subject: [PATCH 2/2] README syntax highlighting --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b7a2323..fe1abf1 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ Word under cursor will be searched if no argument is passed to `Rg` | 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_highlight_type | identifier | if `rg_highlight` is set, use this syntax color to highlight the result -| 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 +| `g:rg_binary` | `rg` | path to the `rg` binary +| `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_highlight_type` | `identifier` | if `rg_highlight` is set, use this syntax color to highlight the result +| `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