From 649d91301522acfbf9e89088116ba2117084d503 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 21 Mar 2017 22:19:43 +0800 Subject: [PATCH] Use rg for deinte grep by default --- config/plugins/denite.vim | 169 +++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 75 deletions(-) diff --git a/config/plugins/denite.vim b/config/plugins/denite.vim index ddb21b43d..c56eb26a7 100644 --- a/config/plugins/denite.vim +++ b/config/plugins/denite.vim @@ -5,108 +5,127 @@ let s:sys = SpaceVim#api#import('system') " denite option let s:denite_options = {'default' : { - \ 'winheight' : 15, - \ 'mode' : 'insert', - \ 'quit' : 'true', - \ 'highlight_matched_char' : 'MoreMsg', - \ 'highlight_matched_range' : 'MoreMsg', - \ 'direction': 'rightbelow', - \ 'statusline' : 'false', - \ 'prompt' : '➭', - \ }} + \ 'winheight' : 15, + \ 'mode' : 'insert', + \ 'quit' : 'true', + \ 'highlight_matched_char' : 'MoreMsg', + \ 'highlight_matched_range' : 'MoreMsg', + \ 'direction': 'rightbelow', + \ 'statusline' : 'false', + \ 'prompt' : '➭', + \ }} function! s:profile(opts) abort - for fname in keys(a:opts) - for dopt in keys(a:opts[fname]) - call denite#custom#option(fname, dopt, a:opts[fname][dopt]) - endfor - endfor + for fname in keys(a:opts) + for dopt in keys(a:opts[fname]) + call denite#custom#option(fname, dopt, a:opts[fname][dopt]) + endfor + endfor endfunction call s:profile(s:denite_options) " buffer source call denite#custom#var( - \ 'buffer', - \ 'date_format', '%m-%d-%Y %H:%M:%S') + \ 'buffer', + \ 'date_format', '%m-%d-%Y %H:%M:%S') " denite command if !s:sys.isWindows - if executable('rg') - " For ripgrep - " Note: It is slower than ag - call denite#custom#var('file_rec', 'command', - \ ['rg', '--files', '--glob', '!.git', ''] - \ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'rg') - \ ) - elseif executable('ag') - " Change file_rec command. - call denite#custom#var('file_rec', 'command', - \ ['ag' , '--nocolor', '--nogroup', '-g', ''] - \ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'ag') - \ ) - endif + if executable('rg') + " For ripgrep + " Note: It is slower than ag + call denite#custom#var('file_rec', 'command', + \ ['rg', '--hidden', '--files', '--glob', '!.git', ''] + \ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'rg') + \ ) + elseif executable('ag') + " Change file_rec command. + call denite#custom#var('file_rec', 'command', + \ ['ag' , '--nocolor', '--nogroup', '-g', ''] + \ + zvim#util#Generate_ignore(g:spacevim_wildignore, 'ag') + \ ) + endif else - if executable('pt') - " For Pt(the platinum searcher) - " NOTE: It also supports windows. - call denite#custom#var('file_rec', 'command', - \ ['pt', '--follow', '--nocolor', '--nogroup', '-g:', '']) - endif + if executable('pt') + " For Pt(the platinum searcher) + " NOTE: It also supports windows. + call denite#custom#var('file_rec', 'command', + \ ['pt', '--follow', '--nocolor', '--nogroup', '-g:', '']) + endif endif " FIND and GREP COMMANDS -if executable('ag') - call denite#custom#var('grep', 'command', ['ag']) - call denite#custom#var('grep', 'recursive_opts', []) - call denite#custom#var('grep', 'pattern_opt', []) - call denite#custom#var('grep', 'separator', ['--']) - call denite#custom#var('grep', 'final_opts', []) - call denite#custom#var('grep', 'default_opts', - \ [ '--vimgrep', '--smart-case' ]) +if executable('rg') + " Ripgrep command on grep source + call denite#custom#var('grep', 'command', ['rg']) + call denite#custom#var('grep', 'default_opts', + \ ['--vimgrep', '--no-heading']) + 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', []) + +elseif executable('pt') + " Pt command on grep source + call denite#custom#var('grep', 'command', ['pt']) + call denite#custom#var('grep', 'default_opts', + \ ['--nogroup', '--nocolor', '--smart-case']) + call denite#custom#var('grep', 'recursive_opts', []) + call denite#custom#var('grep', 'pattern_opt', []) + call denite#custom#var('grep', 'separator', ['--']) + call denite#custom#var('grep', 'final_opts', []) +elseif executable('ag') + call denite#custom#var('grep', 'command', ['ag']) + call denite#custom#var('grep', 'recursive_opts', []) + call denite#custom#var('grep', 'pattern_opt', []) + call denite#custom#var('grep', 'separator', ['--']) + call denite#custom#var('grep', 'final_opts', []) + call denite#custom#var('grep', 'default_opts', + \ [ '--vimgrep', '--smart-case' ]) elseif executable('ack') - " Ack command - call denite#custom#var('grep', 'command', ['ack']) - call denite#custom#var('grep', 'recursive_opts', []) - call denite#custom#var('grep', 'pattern_opt', ['--match']) - call denite#custom#var('grep', 'separator', ['--']) - call denite#custom#var('grep', 'final_opts', []) - call denite#custom#var('grep', 'default_opts', - \ ['--ackrc', $HOME.'/.config/ackrc', '-H', - \ '--nopager', '--nocolor', '--nogroup', '--column']) + " Ack command + call denite#custom#var('grep', 'command', ['ack']) + call denite#custom#var('grep', 'recursive_opts', []) + call denite#custom#var('grep', 'pattern_opt', ['--match']) + call denite#custom#var('grep', 'separator', ['--']) + call denite#custom#var('grep', 'final_opts', []) + call denite#custom#var('grep', 'default_opts', + \ ['--ackrc', $HOME.'/.config/ackrc', '-H', + \ '--nopager', '--nocolor', '--nogroup', '--column']) endif " KEY MAPPINGS let s:insert_mode_mappings = [ - \ ['jk', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ] + \ ['jk', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ] let s:normal_mode_mappings = [ - \ ["'", '', 'noremap'], - \ ['', '', 'noremap'], - \ ['', '', 'noremap'], - \ ['gg', '', 'noremap'], - \ ['st', '', 'noremap'], - \ ['sg', '', 'noremap'], - \ ['sv', '', 'noremap'], - \ ['q', '', 'noremap'], - \ ['r', '', 'noremap'], - \ ] + \ ["'", '', 'noremap'], + \ ['', '', 'noremap'], + \ ['', '', 'noremap'], + \ ['gg', '', 'noremap'], + \ ['st', '', 'noremap'], + \ ['sg', '', 'noremap'], + \ ['sv', '', 'noremap'], + \ ['q', '', 'noremap'], + \ ['r', '', 'noremap'], + \ ] for s:m in s:insert_mode_mappings - call denite#custom#map('insert', s:m[0], s:m[1], s:m[2]) + call denite#custom#map('insert', s:m[0], s:m[1], s:m[2]) endfor for s:m in s:normal_mode_mappings - call denite#custom#map('normal', s:m[0], s:m[1], s:m[2]) + call denite#custom#map('normal', s:m[0], s:m[1], s:m[2]) endfor unlet s:m s:insert_mode_mappings s:normal_mode_mappings