1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

enhance defx keymap l

This commit is contained in:
alanding 2019-04-03 11:07:27 +08:00
parent 9e5134001d
commit dc3c23fe3e

View File

@ -95,12 +95,8 @@ function! s:defx_init()
\ defx#do_action('paste')
nnoremap <silent><buffer><expr> h defx#do_action('call', 'DefxSmartH')
nnoremap <silent><buffer><expr> <Left> defx#do_action('call', 'DefxSmartH')
nnoremap <silent><buffer><expr> l
\ defx#is_directory() ?
\ defx#do_action('open_tree') . 'j' : defx#do_action('drop')
nnoremap <silent><buffer><expr> <Right>
\ defx#is_directory() ?
\ defx#do_action('open_tree') . 'j' : defx#do_action('open')
nnoremap <silent><buffer><expr> l defx#do_action('call', 'DefxSmartL')
nnoremap <silent><buffer><expr> <Right> defx#do_action('call', 'DefxSmartL')
nnoremap <silent><buffer><expr> <Cr>
\ defx#is_directory() ?
\ defx#do_action('open_directory') : defx#do_action('drop')
@ -138,6 +134,32 @@ function! s:defx_init()
\ defx#do_action('change_vim_cwd')
endf
function! DefxSmartL(_)
if defx#is_directory()
call defx#call_action('open_tree')
normal! j
else
let filepath = defx#get_candidate()['action__path']
if tabpagewinnr(tabpagenr(), '$') >= 3
if has('nvim')
let input = input({
\ 'prompt' : 'ChooseWin No.: ',
\ 'cancelreturn': 0,
\ })
if input == 0 | return | endif
else
let input = input('ChooseWin No.: ')
endif
if input == winnr() | return | endif
exec ': ' . input . 'wincmd w'
exec ':e' . filepath
else
exec 'wincmd w'
exec ':e' . filepath
endif
endif
endfunction
function! DefxSmartH(_)
" candidate is opend tree?
if defx#is_opened_tree()