denite.vim 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. " === Denite setup ==="
  2. " Use ripgrep for searching current directory for files
  3. " By default, ripgrep will respect rules in .gitignore
  4. " --files: Print each file that would be searched (but don't search)
  5. " --glob: Include or exclues files for searching that match the given glob
  6. " (aka ignore .git files)
  7. "
  8. call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git'])
  9. " Use ripgrep in place of "grep"
  10. call denite#custom#var('grep', 'command', ['rg'])
  11. " Custom options for ripgrep
  12. " --vimgrep: Show results with every match on it's own line
  13. " --hidden: Search hidden directories and files
  14. " --heading: Show the file name above clusters of matches from each file
  15. " --S: Search case insensitively if the pattern is all lowercase
  16. call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S'])
  17. " Recommended defaults for ripgrep via Denite docs
  18. call denite#custom#var('grep', 'recursive_opts', [])
  19. call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
  20. call denite#custom#var('grep', 'separator', ['--'])
  21. call denite#custom#var('grep', 'final_opts', [])
  22. " Remove date from buffer list
  23. call denite#custom#var('buffer', 'date_format', '')
  24. " Custom options for Denite
  25. " auto_resize - Auto resize the Denite window height automatically.
  26. " prompt - Customize denite prompt
  27. " direction - Specify Denite window direction as directly below current pane
  28. " winminheight - Specify min height for Denite window
  29. " highlight_mode_insert - Specify h1-CursorLine in insert mode
  30. " prompt_highlight - Specify color of prompt
  31. " highlight_matched_char - Matched characters highlight
  32. " highlight_matched_range - matched range highlight
  33. let s:denite_options = {'default' : {
  34. \ 'split': 'floating',
  35. \ 'start_filter': 1,
  36. \ 'auto_resize': 1,
  37. \ 'source_names': 'short',
  38. \ 'prompt': 'λ ',
  39. \ 'highlight_matched_char': 'QuickFixLine',
  40. \ 'highlight_matched_range': 'Visual',
  41. \ 'highlight_window_background': 'Visual',
  42. \ 'highlight_filter_background': 'DiffAdd',
  43. \ 'winrow': 1,
  44. \ 'vertical_preview': 1
  45. \ }}
  46. " Loop through denite options and enable them
  47. function! s:profile(opts) abort
  48. for l:fname in keys(a:opts)
  49. for l:dopt in keys(a:opts[l:fname])
  50. call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt])
  51. endfor
  52. endfor
  53. endfunction
  54. call s:profile(s:denite_options)
  55. echo 'Denite not installed. It should work after running :PlugInstall'
  56. nmap ; :Denite buffer<CR>
  57. nmap <leader>t :DeniteProjectDir file/rec<CR>
  58. nnoremap <leader>g :<C-u>Denite grep:. -no-empty<CR>
  59. nnoremap <leader>j :<C-u>DeniteCursorWord grep:.<CR>
  60. " Define mappings while in 'filter' mode
  61. " <C-o> - Switch to normal mode inside of search results
  62. " <Esc> - Exit denite window in any mode
  63. " <CR> - Open currently selected file in any mode
  64. " <C-t> - Open currently selected file in a new tab
  65. " <C-v> - Open currently selected file a vertical split
  66. " <C-h> - Open currently selected file in a horizontal split
  67. autocmd FileType denite-filter call s:denite_filter_my_settings()
  68. function! s:denite_filter_my_settings() abort
  69. imap <silent><buffer> <C-o>
  70. \ <Plug>(denite_filter_quit)
  71. inoremap <silent><buffer><expr> <Esc>
  72. \ denite#do_map('quit')
  73. nnoremap <silent><buffer><expr> <Esc>
  74. \ denite#do_map('quit')
  75. inoremap <silent><buffer><expr> <CR>
  76. \ denite#do_map('do_action')
  77. inoremap <silent><buffer><expr> <C-t>
  78. \ denite#do_map('do_action', 'tabopen')
  79. inoremap <silent><buffer><expr> <C-v>
  80. \ denite#do_map('do_action', 'vsplit')
  81. inoremap <silent><buffer><expr> <C-h>
  82. \ denite#do_map('do_action', 'split')
  83. endfunction
  84. " Define mappings while in denite window
  85. " <CR> - Opens currently selected file
  86. " q or <Esc> - Quit Denite window
  87. " d - Delete currenly selected file
  88. " p - Preview currently selected file
  89. " <C-o> or i - Switch to insert mode inside of filter prompt
  90. " <C-t> - Open currently selected file in a new tab
  91. " <C-v> - Open currently selected file a vertical split
  92. " <C-h> - Open currently selected file in a horizontal split
  93. autocmd FileType denite call s:denite_my_settings()
  94. function! s:denite_my_settings() abort
  95. nnoremap <silent><buffer><expr> <CR>
  96. \ denite#do_map('do_action')
  97. nnoremap <silent><buffer><expr> q
  98. \ denite#do_map('quit')
  99. nnoremap <silent><buffer><expr> <Esc>
  100. \ denite#do_map('quit')
  101. nnoremap <silent><buffer><expr> d
  102. \ denite#do_map('do_action', 'delete')
  103. nnoremap <silent><buffer><expr> p
  104. \ denite#do_map('do_action', 'preview')
  105. nnoremap <silent><buffer><expr> i
  106. \ denite#do_map('open_filter_buffer')
  107. nnoremap <silent><buffer><expr> <C-o>
  108. \ denite#do_map('open_filter_buffer')
  109. nnoremap <silent><buffer><expr> <C-t>
  110. \ denite#do_map('do_action', 'tabopen')
  111. nnoremap <silent><buffer><expr> <C-v>
  112. \ denite#do_map('do_action', 'vsplit')
  113. nnoremap <silent><buffer><expr> <C-h>
  114. \ denite#do_map('do_action', 'split')
  115. endfunction