Escape some characters in vim rip-grep search
This commit is contained in:
parent
12969578aa
commit
9e07b24cf7
17
vimrc
17
vimrc
|
@ -197,7 +197,7 @@ call plug#begin('~/.vim/plugged')
|
||||||
" MISC
|
" MISC
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Plug 'bling/vim-airline' " Enhanced status/tabline.
|
Plug 'vim-airline/vim-airline' " Enhanced status/tabline.
|
||||||
Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config.
|
Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config.
|
||||||
Plug 'tpope/vim-obsession' " Continuously updated session files (tracks window positions, open folds, etc).
|
Plug 'tpope/vim-obsession' " Continuously updated session files (tracks window positions, open folds, etc).
|
||||||
Plug 'tpope/vim-fugitive' " Git wrapper (I particularly like :Gblame, which I've wrapped as :Blame)
|
Plug 'tpope/vim-fugitive' " Git wrapper (I particularly like :Gblame, which I've wrapped as :Blame)
|
||||||
|
@ -352,7 +352,9 @@ set wildmenu
|
||||||
set wildmode=longest,list,full
|
set wildmode=longest,list,full
|
||||||
set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/*
|
set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/*
|
||||||
|
|
||||||
set grepprg=rg\ --vimgrep " Requires ripgrep to be installed.
|
if executable('rg')
|
||||||
|
set grepprg=rg\ --vimgrep\ --hidden " Requires ripgrep to be installed.
|
||||||
|
endif
|
||||||
|
|
||||||
set list listchars=tab:»·,trail:· " Show trailing whitespace.
|
set list listchars=tab:»·,trail:· " Show trailing whitespace.
|
||||||
|
|
||||||
|
@ -1419,15 +1421,20 @@ function! Search(path, search_args, case_insensitive=0)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
" @note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
||||||
"quickfix window doesn't seem to parse the ansi color codes.
|
" quickfix window doesn't seem to parse the ansi color codes.
|
||||||
let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" -g \"!.git/\" -g \"!AppData/\" " . a:search_args
|
let l:rg_args = "--column --line-number --no-heading --fixed-strings --no-ignore --hidden --follow --trim -g \"!tags\" -g \"!.git/\" -g \"!AppData/\" " . a:search_args
|
||||||
|
|
||||||
if a:case_insensitive
|
if a:case_insensitive
|
||||||
let l:rg_args .= " --ignore-case"
|
let l:rg_args .= " --ignore-case"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
exec 'Rg ' . l:rg_args . ' -e "' . l:term . '"' . ' ' . a:path
|
" Some characters need to be escaped.
|
||||||
|
let l:escaped_term = substitute(l:term, '[#%]', '\\\\\\&', 'g')
|
||||||
|
|
||||||
|
let l:format = 'Rg ' . l:rg_args . ' ' . a:path . ' -e %s'
|
||||||
|
let l:cmd = printf(l:format, shellescape(l:escaped_term))
|
||||||
|
exec l:cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user