fzf.vim 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. " This is the default extra key bindings
  2. let g:fzf_action = {
  3. \ 'ctrl-t': 'tab split',
  4. \ 'ctrl-x': 'split',
  5. \ 'ctrl-v': 'vsplit' }
  6. " Enable per-command history.
  7. " CTRL-N and CTRL-P will be automatically bound to next-history and
  8. " previous-history instead of down and up. If you don't like the change,
  9. " explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
  10. let g:fzf_history_dir = '~/.local/share/fzf-history'
  11. let g:fzf_buffers_jump = 1
  12. " map <C-f> :Files<CR>
  13. " map <leader>b :Buffers<CR>
  14. " nnoremap <leader>g :Rg<CR>
  15. " nnoremap <leader>t :Tags<CR>
  16. " nnoremap <leader>m :Marks<CR>
  17. let g:fzf_tags_command = 'ctags -R'
  18. " Border color
  19. let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
  20. let $FZF_DEFAULT_OPTS = '--layout=reverse --inline-info'
  21. let $FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/**'"
  22. "-g '!{node_modules,.git}'
  23. " Customize fzf colors to match your color scheme
  24. let g:fzf_colors =
  25. \ { 'fg': ['fg', 'Normal'],
  26. \ 'bg': ['bg', 'Normal'],
  27. \ 'hl': ['fg', 'Comment'],
  28. \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
  29. \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
  30. \ 'hl+': ['fg', 'Statement'],
  31. \ 'info': ['fg', 'PreProc'],
  32. \ 'border': ['fg', 'Ignore'],
  33. \ 'prompt': ['fg', 'Conditional'],
  34. \ 'pointer': ['fg', 'Exception'],
  35. \ 'marker': ['fg', 'Keyword'],
  36. \ 'spinner': ['fg', 'Label'],
  37. \ 'header': ['fg', 'Comment'] }
  38. "Get Files
  39. command! -bang -nargs=? -complete=dir Files
  40. \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--inline-info']}), <bang>0)
  41. " Get text in files with Rg
  42. " command! -bang -nargs=* Rg
  43. " \ call fzf#vim#grep(
  44. " \ "rg --column --line-number --no-heading --color=always --smart-case --glob '!.git/**' ".shellescape(<q-args>), 1,
  45. " Make Ripgrep ONLY search file contents and not filenames
  46. command! -bang -nargs=* Rg
  47. \ call fzf#vim#grep(
  48. \ 'rg --column --line-number --hidden --smart-case --no-heading --color=always '.shellescape(<q-args>), 1,
  49. \ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
  50. \ : fzf#vim#with_preview({'options': '--delimiter : --nth 4.. -e'}, 'right:50%', '?'),
  51. \ <bang>0)
  52. " Ripgrep advanced
  53. function! RipgrepFzf(query, fullscreen)
  54. let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
  55. let initial_command = printf(command_fmt, shellescape(a:query))
  56. let reload_command = printf(command_fmt, '{q}')
  57. let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
  58. call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
  59. endfunction
  60. command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
  61. " Git grep
  62. command! -bang -nargs=* GGrep
  63. \ call fzf#vim#grep(
  64. \ 'git grep --line-number '.shellescape(<q-args>), 0,
  65. \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)