fzf.vim 3.0 KB

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