From dd724ba8727c3c29137aaa231e17d01e150c8110 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 20 Mar 2017 21:02:50 +0800 Subject: [PATCH] Update denite config --- config/plugins/denite.vim | 117 ++++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 16 deletions(-) diff --git a/config/plugins/denite.vim b/config/plugins/denite.vim index e45c2f2d2..4e7574547 100644 --- a/config/plugins/denite.vim +++ b/config/plugins/denite.vim @@ -1,20 +1,105 @@ +scriptencoding utf-8 +" load api let s:sys = SpaceVim#api#import('system') + +" denite option +let s:denite_options = {'default' : { + \ 'winheight' : 15, + \ 'mode' : 'insert', + \ 'quit' : 'true', + \ 'highlight-matched-char' : 'Function', + \ 'highlight-matched-range' : 'Function', + \ '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 +endfunction + +call s:profile(s:denite_options) + +" denite command if !s:sys.isWindows - if executable('ag') - " Change file_rec command. - call denite#custom#var('file_rec', 'command', - \ ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']) - elseif executable('rg') - " For ripgrep - " Note: It is slower than ag - call denite#custom#var('file_rec', 'command', - \ ['rg', '--files', '--glob', '!.git', '']) - endif + if executable('ag') + " Change file_rec command. + call denite#custom#var('file_rec', 'command', + \ ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']) + elseif executable('rg') + " For ripgrep + " Note: It is slower than ag + call denite#custom#var('file_rec', 'command', + \ ['rg', '--files', '--glob', '!.git', '']) + 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' ]) +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']) +endif + +" KEY MAPPINGS +let s:insert_mode_mappings = [ + \ ['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'], + \ ] + +for s:m in s:insert_mode_mappings + 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]) +endfor + +unlet s:m s:insert_mode_mappings s:normal_mode_mappings + +" vim: set ts=2 sw=2 tw=80 noet : +