fzf.vim 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. \ fzf#vim#with_preview(), <bang>0)
  45. " Ripgrep advanced
  46. function! RipgrepFzf(query, fullscreen)
  47. let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
  48. let initial_command = printf(command_fmt, shellescape(a:query))
  49. let reload_command = printf(command_fmt, '{q}')
  50. let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
  51. call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
  52. endfunction
  53. command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
  54. " Git grep
  55. command! -bang -nargs=* GGrep
  56. \ call fzf#vim#grep(
  57. \ 'git grep --line-number '.shellescape(<q-args>), 0,
  58. \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)