From d0796e1cb3fc72f0e53bf4ad77e45e3bfe1e6156 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 1 Apr 2020 19:37:34 -0400 Subject: auto push --- modules/denite.vim | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ modules/general.vim | 1 + 2 files changed, 126 insertions(+) create mode 100644 modules/denite.vim (limited to 'modules') diff --git a/modules/denite.vim b/modules/denite.vim new file mode 100644 index 00000000..6b547f86 --- /dev/null +++ b/modules/denite.vim @@ -0,0 +1,125 @@ +" === Denite setup ===" +" Use ripgrep for searching current directory for files +" By default, ripgrep will respect rules in .gitignore +" --files: Print each file that would be searched (but don't search) +" --glob: Include or exclues files for searching that match the given glob +" (aka ignore .git files) +" +call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git']) + +" Use ripgrep in place of "grep" +call denite#custom#var('grep', 'command', ['rg']) + +" Custom options for ripgrep +" --vimgrep: Show results with every match on it's own line +" --hidden: Search hidden directories and files +" --heading: Show the file name above clusters of matches from each file +" --S: Search case insensitively if the pattern is all lowercase +call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S']) + +" Recommended defaults for ripgrep via Denite docs +call denite#custom#var('grep', 'recursive_opts', []) +call denite#custom#var('grep', 'pattern_opt', ['--regexp']) +call denite#custom#var('grep', 'separator', ['--']) +call denite#custom#var('grep', 'final_opts', []) + +" Remove date from buffer list +call denite#custom#var('buffer', 'date_format', '') + +" Custom options for Denite +" auto_resize - Auto resize the Denite window height automatically. +" prompt - Customize denite prompt +" direction - Specify Denite window direction as directly below current pane +" winminheight - Specify min height for Denite window +" highlight_mode_insert - Specify h1-CursorLine in insert mode +" prompt_highlight - Specify color of prompt +" highlight_matched_char - Matched characters highlight +" highlight_matched_range - matched range highlight +let s:denite_options = {'default' : { +\ 'split': 'floating', +\ 'start_filter': 1, +\ 'auto_resize': 1, +\ 'source_names': 'short', +\ 'prompt': 'λ ', +\ 'highlight_matched_char': 'QuickFixLine', +\ 'highlight_matched_range': 'Visual', +\ 'highlight_window_background': 'Visual', +\ 'highlight_filter_background': 'DiffAdd', +\ 'winrow': 1, +\ 'vertical_preview': 1 +\ }} + +" Loop through denite options and enable them +function! s:profile(opts) abort + for l:fname in keys(a:opts) + for l:dopt in keys(a:opts[l:fname]) + call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt]) + endfor + endfor +endfunction + +call s:profile(s:denite_options) + echo 'Denite not installed. It should work after running :PlugInstall' + +nmap ; :Denite buffer +nmap t :DeniteProjectDir file/rec +nnoremap g :Denite grep:. -no-empty +nnoremap j :DeniteCursorWord grep:. + +" Define mappings while in 'filter' mode +" - Switch to normal mode inside of search results +" - Exit denite window in any mode +" - Open currently selected file in any mode +" - Open currently selected file in a new tab +" - Open currently selected file a vertical split +" - Open currently selected file in a horizontal split +autocmd FileType denite-filter call s:denite_filter_my_settings() +function! s:denite_filter_my_settings() abort + imap + \ (denite_filter_quit) + inoremap + \ denite#do_map('quit') + nnoremap + \ denite#do_map('quit') + inoremap + \ denite#do_map('do_action') + inoremap + \ denite#do_map('do_action', 'tabopen') + inoremap + \ denite#do_map('do_action', 'vsplit') + inoremap + \ denite#do_map('do_action', 'split') +endfunction + +" Define mappings while in denite window +" - Opens currently selected file +" q or - Quit Denite window +" d - Delete currenly selected file +" p - Preview currently selected file +" or i - Switch to insert mode inside of filter prompt +" - Open currently selected file in a new tab +" - Open currently selected file a vertical split +" - Open currently selected file in a horizontal split +autocmd FileType denite call s:denite_my_settings() +function! s:denite_my_settings() abort + nnoremap + \ denite#do_map('do_action') + nnoremap q + \ denite#do_map('quit') + nnoremap + \ denite#do_map('quit') + nnoremap d + \ denite#do_map('do_action', 'delete') + nnoremap p + \ denite#do_map('do_action', 'preview') + nnoremap i + \ denite#do_map('open_filter_buffer') + nnoremap + \ denite#do_map('open_filter_buffer') + nnoremap + \ denite#do_map('do_action', 'tabopen') + nnoremap + \ denite#do_map('do_action', 'vsplit') + nnoremap + \ denite#do_map('do_action', 'split') +endfunction diff --git a/modules/general.vim b/modules/general.vim index ae2ed36e..c77460fa 100644 --- a/modules/general.vim +++ b/modules/general.vim @@ -96,3 +96,4 @@ vnoremap < >gv set conceallevel=0 +cmap w!! w !sudo tee % -- cgit v1.2.3