2017-03-20 21:02:50 +08:00
|
|
|
scriptencoding utf-8
|
|
|
|
" load api
|
2017-03-19 22:58:36 +08:00
|
|
|
let s:sys = SpaceVim#api#import('system')
|
2017-03-20 21:02:50 +08:00
|
|
|
|
2017-03-21 20:36:42 +08:00
|
|
|
|
2017-03-20 21:02:50 +08:00
|
|
|
" denite option
|
2017-03-29 22:29:42 +08:00
|
|
|
let s:denite_options = {
|
2017-03-29 21:36:46 +08:00
|
|
|
\ 'default' : {
|
2017-03-21 22:19:43 +08:00
|
|
|
\ 'winheight' : 15,
|
|
|
|
\ 'mode' : 'insert',
|
2019-09-18 20:57:09 +08:00
|
|
|
\ 'start_filter' : 1,
|
2018-04-22 22:46:29 +08:00
|
|
|
\ 'quit' : 1,
|
2017-03-21 22:19:43 +08:00
|
|
|
\ 'highlight_matched_char' : 'MoreMsg',
|
|
|
|
\ 'highlight_matched_range' : 'MoreMsg',
|
|
|
|
\ 'direction': 'rightbelow',
|
2017-10-08 19:58:51 +08:00
|
|
|
\ 'statusline' : has('patch-7.4.1154') ? v:false : 0,
|
2018-12-22 22:18:19 +08:00
|
|
|
\ 'prompt' : g:spacevim_commandline_prompt,
|
2017-03-29 22:29:42 +08:00
|
|
|
\ }}
|
2017-03-20 21:02:50 +08:00
|
|
|
|
|
|
|
function! s:profile(opts) abort
|
2017-03-21 22:19:43 +08:00
|
|
|
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
|
2017-03-20 21:02:50 +08:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
call s:profile(s:denite_options)
|
|
|
|
|
2017-03-20 22:06:26 +08:00
|
|
|
" buffer source
|
|
|
|
call denite#custom#var(
|
2017-03-21 22:19:43 +08:00
|
|
|
\ 'buffer',
|
|
|
|
\ 'date_format', '%m-%d-%Y %H:%M:%S')
|
2017-03-20 22:06:26 +08:00
|
|
|
|
2017-03-20 21:02:50 +08:00
|
|
|
" denite command
|
2017-03-19 22:58:36 +08:00
|
|
|
if !s:sys.isWindows
|
2017-03-21 22:19:43 +08:00
|
|
|
if executable('rg')
|
|
|
|
" For ripgrep
|
|
|
|
" Note: It is slower than ag
|
2019-03-26 22:35:14 +08:00
|
|
|
call denite#custom#var('file/rec', 'command',
|
2017-05-23 20:17:41 +08:00
|
|
|
\ ['rg', '--hidden', '--files', '--glob', '!.git', '--glob', '']
|
2019-06-08 15:09:53 +08:00
|
|
|
\ + SpaceVim#util#Generate_ignore(g:spacevim_wildignore, 'rg')
|
2017-03-21 22:19:43 +08:00
|
|
|
\ )
|
|
|
|
elseif executable('ag')
|
2019-03-26 22:35:14 +08:00
|
|
|
" Change file/rec command.
|
|
|
|
call denite#custom#var('file/rec', 'command',
|
2017-03-21 22:19:43 +08:00
|
|
|
\ ['ag' , '--nocolor', '--nogroup', '-g', '']
|
2019-06-08 15:09:53 +08:00
|
|
|
\ + SpaceVim#util#Generate_ignore(g:spacevim_wildignore, 'ag')
|
2017-03-21 22:19:43 +08:00
|
|
|
\ )
|
|
|
|
endif
|
2017-03-19 22:58:36 +08:00
|
|
|
else
|
2017-03-21 22:19:43 +08:00
|
|
|
if executable('pt')
|
|
|
|
" For Pt(the platinum searcher)
|
|
|
|
" NOTE: It also supports windows.
|
2019-03-26 22:35:14 +08:00
|
|
|
call denite#custom#var('file/rec', 'command',
|
2018-12-29 01:03:15 +08:00
|
|
|
\ ['pt', '--nocolor', '--ignore', '.git', '--hidden', '-g=', ''])
|
2017-03-21 22:19:43 +08:00
|
|
|
endif
|
2017-03-19 22:58:36 +08:00
|
|
|
endif
|
2017-03-20 21:02:50 +08:00
|
|
|
|
2019-03-26 22:35:14 +08:00
|
|
|
call denite#custom#alias('source', 'file/rec/git', 'file/rec')
|
|
|
|
call denite#custom#var('file/rec/git', 'command',
|
2018-03-30 21:36:00 +08:00
|
|
|
\ ['git', 'ls-files', '-co', '--exclude-standard'])
|
2017-03-20 21:02:50 +08:00
|
|
|
|
|
|
|
" FIND and GREP COMMANDS
|
2017-03-21 22:19:43 +08:00
|
|
|
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' ])
|
2017-03-20 21:02:50 +08:00
|
|
|
elseif executable('ack')
|
2017-03-21 22:19:43 +08:00
|
|
|
" 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'])
|
2017-03-20 21:02:50 +08:00
|
|
|
endif
|
|
|
|
|
2017-03-22 22:15:13 +08:00
|
|
|
" enable unite menu compatibility
|
|
|
|
call denite#custom#var('menu', 'unite_source_menu_compatibility', 1)
|
|
|
|
|
2017-03-20 21:02:50 +08:00
|
|
|
" KEY MAPPINGS
|
|
|
|
let s:insert_mode_mappings = [
|
2018-03-30 21:36:00 +08:00
|
|
|
\ ['jk', '<denite:enter_mode:normal>', 'noremap'],
|
2017-03-21 22:19:43 +08:00
|
|
|
\ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
|
2018-03-03 21:52:08 +08:00
|
|
|
\ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
|
2017-03-21 22:19:43 +08:00
|
|
|
\ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
|
2018-03-03 21:52:08 +08:00
|
|
|
\ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
|
2018-03-30 21:36:00 +08:00
|
|
|
\ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
|
|
|
|
\ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
|
|
|
|
\ ['<C-s>', '<denite:do_action:split>', 'noremap'],
|
|
|
|
\ ['<Esc>', '<denite:enter_mode:normal>', 'noremap'],
|
|
|
|
\ ['<C-N>', '<denite:assign_next_matched_text>', 'noremap'],
|
|
|
|
\ ['<C-P>', '<denite:assign_previous_matched_text>', 'noremap'],
|
|
|
|
\ ['<Up>', '<denite:assign_previous_text>', 'noremap'],
|
|
|
|
\ ['<Down>', '<denite:assign_next_text>', 'noremap'],
|
|
|
|
\ ['<C-Y>', '<denite:redraw>', 'noremap'],
|
2017-03-21 22:19:43 +08:00
|
|
|
\ ]
|
2017-03-20 21:02:50 +08:00
|
|
|
|
|
|
|
let s:normal_mode_mappings = [
|
2018-03-30 21:36:00 +08:00
|
|
|
\ ["'", '<denite:toggle_select_down>', 'noremap'],
|
|
|
|
\ ['<C-n>', '<denite:jump_to_next_source>', 'noremap'],
|
|
|
|
\ ['<C-p>', '<denite:jump_to_previous_source>', 'noremap'],
|
|
|
|
\ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
|
|
|
|
\ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
|
|
|
|
\ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
|
|
|
|
\ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
|
|
|
|
\ ['gg', '<denite:move_to_first_line>', 'noremap'],
|
|
|
|
\ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
|
|
|
|
\ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
|
|
|
|
\ ['<C-s>', '<denite:do_action:split>', 'noremap'],
|
|
|
|
\ ['q', '<denite:quit>', 'noremap'],
|
|
|
|
\ ['r', '<denite:redraw>', 'noremap'],
|
2017-03-21 22:19:43 +08:00
|
|
|
\ ]
|
2017-03-20 21:02:50 +08:00
|
|
|
|
2019-09-15 21:16:14 +08:00
|
|
|
" this is for old version of denite
|
2017-03-20 21:02:50 +08:00
|
|
|
for s:m in s:insert_mode_mappings
|
2017-03-21 22:19:43 +08:00
|
|
|
call denite#custom#map('insert', s:m[0], s:m[1], s:m[2])
|
2017-03-20 21:02:50 +08:00
|
|
|
endfor
|
|
|
|
for s:m in s:normal_mode_mappings
|
2017-03-21 22:19:43 +08:00
|
|
|
call denite#custom#map('normal', s:m[0], s:m[1], s:m[2])
|
2017-03-20 21:02:50 +08:00
|
|
|
endfor
|
|
|
|
|
|
|
|
unlet s:m s:insert_mode_mappings s:normal_mode_mappings
|
|
|
|
|
|
|
|
|
2019-09-15 21:16:14 +08:00
|
|
|
" Define mappings
|
2019-10-05 22:31:49 +08:00
|
|
|
augroup spacevim_layer_denite
|
|
|
|
autocmd!
|
|
|
|
autocmd FileType denite call s:denite_my_settings()
|
|
|
|
autocmd FileType denite-filter call s:denite_filter_my_settings()
|
|
|
|
augroup END
|
|
|
|
|
2019-09-15 21:16:14 +08:00
|
|
|
function! s:denite_my_settings() abort
|
|
|
|
nnoremap <silent><buffer><expr> i
|
|
|
|
\ denite#do_map('open_filter_buffer')
|
|
|
|
nnoremap <silent><buffer><expr> '
|
|
|
|
\ denite#do_map('toggle_select').'j'
|
|
|
|
nnoremap <silent><buffer><expr> q
|
|
|
|
\ denite#do_map('quit')
|
|
|
|
nnoremap <silent><buffer><expr> <C-t>
|
|
|
|
\ denite#do_map('do_action', 'tabopen')
|
|
|
|
nnoremap <silent><buffer><expr> <C-v>
|
|
|
|
\ denite#do_map('do_action', 'vsplit')
|
|
|
|
nnoremap <silent><buffer><expr> <C-s>
|
|
|
|
\ denite#do_map('do_action', 'split')
|
|
|
|
nnoremap <silent><buffer><expr> <CR>
|
|
|
|
\ denite#do_map('do_action')
|
|
|
|
nnoremap <silent><buffer><expr> p
|
|
|
|
\ denite#do_map('do_action', 'preview')
|
|
|
|
nnoremap <silent><buffer><Tab> j
|
|
|
|
nnoremap <silent><buffer><S-Tab> k
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! s:denite_filter_my_settings() abort
|
2019-11-02 13:26:05 +08:00
|
|
|
call s:clear_imap('<C-g>g')
|
|
|
|
call s:clear_imap('<C-g>S')
|
|
|
|
call s:clear_imap('<C-g>s')
|
|
|
|
call s:clear_imap('<C-g>%')
|
2019-09-15 21:16:14 +08:00
|
|
|
imap <silent><buffer> <Esc> <Plug>(denite_filter_quit)
|
2019-11-02 13:26:05 +08:00
|
|
|
imap <silent><buffer> <C-g> <Plug>(denite_filter_quit):q<Cr>
|
2019-09-18 20:57:09 +08:00
|
|
|
inoremap <silent><buffer> <Tab>
|
|
|
|
\ <Esc><C-w>p:call cursor(line('.')+1,0)<CR><C-w>pA
|
|
|
|
inoremap <silent><buffer> <S-Tab>
|
|
|
|
\ <Esc><C-w>p:call cursor(line('.')-1,0)<CR><C-w>pA
|
|
|
|
inoremap <silent><buffer><expr> <CR> denite#do_map('do_action')
|
2020-01-01 21:50:39 +08:00
|
|
|
" @fixme use this key binding only for sources which has delete action
|
|
|
|
inoremap <silent><buffer><expr> <C-d>
|
|
|
|
\ <SID>delete_action()
|
2020-01-29 23:16:54 +08:00
|
|
|
if exists('*deoplete#custom#buffer_option')
|
|
|
|
call deoplete#custom#buffer_option('auto_complete', v:false)
|
|
|
|
endif
|
2020-01-01 21:50:39 +08:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function! s:delete_action() abort
|
|
|
|
if SpaceVim#layers#core#statusline#denite_status("sources") =~# '^buffer'
|
|
|
|
return denite#do_map('do_action', 'delete')
|
|
|
|
else
|
|
|
|
return ''
|
|
|
|
endif
|
2019-09-15 21:16:14 +08:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2019-11-02 13:26:05 +08:00
|
|
|
function! s:clear_imap(map) abort
|
|
|
|
if maparg(a:map, 'i')
|
|
|
|
exe 'iunmap <buffer> ' . a:map
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2017-03-21 21:06:49 +08:00
|
|
|
" vim:set et sw=2 cc=80:
|