dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit d7f029ffac4ded4fcdefcdda317b683daff3024d
parent e2c5ff72663031308d07e680f029735a1fd2e5f7
Author: Anders Damsgaard <andersd@riseup.net>
Date:   Thu, 19 Oct 2017 11:41:14 -0400

add grep-like fzf search with rg or ag

Diffstat:
Mlinks/.vim/keybinds.vim | 20++++++++++++++++++--
Mlinks/.vim/plugins.vim | 10+++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/links/.vim/keybinds.vim b/links/.vim/keybinds.vim @@ -1,4 +1,8 @@ """ Keyboard shortcuts +" +" Formatting options are prefixed by backslash +nmap \A :set formatoptions+=a<CR>:echo "autowrap enabled"<CR> +nmap \a :set formatoptions-=a<CR>:echo "autowrap disabled"<CR> " Save with ZX nmap ZX :w<CR> @@ -22,7 +26,7 @@ nmap <Leader>W :w !sudo tee > /dev/null %<CR>:e!<CR> nmap <Leader>q :q<CR> " Native (fast) buffer switching -nnoremap ,b :ls<CR>:buffer<Space> +"nnoremap ,b :ls<CR>:buffer<Space> " Close buffer nmap <leader>Q :bd<CR> @@ -60,7 +64,6 @@ nmap <leader>C :e $MYVIMRC<CR> "nmap <leader>T :e ~/doc/todo.org<CR> nmap <leader>T :e ~/doc/todo.md<CR> nmap <leader>B :e `kpsexpand '$TEXMFHOME'`/bibtex/bib/myfiles/BIB.bib<CR> -nmap <leader>A :e ~/articles/articles.rst<CR> nmap <leader>r :read !scholarref.py @@ -192,6 +195,19 @@ nmap <leader>c :Start ctags -R --python-kinds=-i --langmap=c++:.cu,c++:.cuh .<CR "nmap <leader>O :CtrlPMRUFiles<CR> "nmap <leader>o :CtrlP<CR> +" file search +if executable("rg") + command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --no-heading --color=always --ignore-case '.shellescape(<q-args>), 1, + \ <bang>0 ? fzf#vim#with_preview('up:60%') + \ : fzf#vim#with_preview('right:50%:hidden', '?'), + \ <bang>0) + nmap <Leader>a :Rg<CR> +elseif executable("ag") + nmap <Leader>a :Ag<CR> +end + " using fzf.vim nmap <leader>b :Buffers<CR> nmap <leader>O :History<CR> diff --git a/links/.vim/plugins.vim b/links/.vim/plugins.vim @@ -29,7 +29,7 @@ Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'junegunn/fzf.vim' Plug 'majutsushi/tagbar' " ctags overview :TagBarToggle Plug 'ludovicchabant/vim-gutentags' " automatic tag generation - +Plug 'mileszs/ack.vim' " file search, using rg or ag (specified below) """""" Syntax checking """""" Plug 'w0rp/ale' " asynchronous syntax check @@ -119,3 +119,11 @@ let g:rainbow_active = 1 " toggle with :RainbowToggle " create a navigation table with :Toc, :Toch, :Tocv let g:vim_markdown_folding_disabled=1 let g:vim_markdown_math=1 + +" Tell ack.vim to use rg (ripgrep) or ag (the Silver Searcher) instead +if executable("rg") + let g:ackprg = 'rg --vimgrep --no-heading' +elseif executable("ag") + let g:ackprg = 'ag --vimgrep' +end +