summaryrefslogtreecommitdiff
path: root/_config/105-fzf.vim
blob: e2b58c34e075c810dbf50aa1bcc76bb96a12cfad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
if empty(globpath(&rtp, 'autoload/fzf/vim.vim'))
  finish
endif

" fzf
" let $FZF_DEFAULT_COMMAND = 'rg --files --follow --hidden --no-ignore-vcs -g "!{.git,node_modules}/*" 2>/dev/null'
"
if executable('rg')
  let $FZF_DEFAULT_COMMAND = 'rg --files --follow --hidden -g "!{.git,node_modules}/*" 2>/dev/null'
  nmap <Leader>f :Files<CR>

  command! -bang -nargs=* Rg
    \ call fzf#vim#grep(
    \   'rg --column --line-number --no-heading --color=always --smart-case --hidden -g "!{.git,node_modules}/*" '.shellescape(<q-args>), 1,
    \   <bang>0 ? fzf#vim#with_preview('up:60%')
    \           : fzf#vim#with_preview('right:50%:hidden', '?'),
    \   <bang>0)
  nmap <Leader>r :Rg<CR>
else
  nmap <Leader>f :GFiles<CR>
endif

if executable('ag')
  autocmd VimEnter * command! -bang -nargs=* Ag
    \ call fzf#vim#ag(<q-args>, '--hidden --ignore .git --skip-vcs-ignores', <bang>0)
  nmap <Leader>a :Ag<CR>
endif

nmap <Leader>; :Buffers<CR>
imap <c-x><c-f> <plug>(fzf-complete-path)

" refs: https://github.com/junegunn/fzf.vim/issues/821#issuecomment-581481211
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Todo' } }