diff --git a/config/plugins/defx.vim b/config/plugins/defx.vim index c5a271500..123afa022 100644 --- a/config/plugins/defx.vim +++ b/config/plugins/defx.vim @@ -121,8 +121,7 @@ function! s:defx_init() \ defx#do_action('remove') nnoremap r \ defx#do_action('rename') - nnoremap yy - \ defx#do_action('yank_path') + nnoremap yy defx#do_action('call', 'DefxYarkPath') nnoremap . \ defx#do_action('toggle_ignored_files') nnoremap ~ @@ -144,7 +143,7 @@ function! DefxSmartH(_) if defx#is_opened_tree() return defx#call_action('close_tree') endif - + " parent is root? let s:candidate = defx#get_candidate() let s:parent = fnamemodify(s:candidate['action__path'], s:candidate['is_directory'] ? ':p:h:h' : ':p:h') @@ -152,14 +151,20 @@ function! DefxSmartH(_) if s:trim_right(s:parent, sep) == s:trim_right(b:defx.paths[0], sep) return defx#call_action('cd', ['..']) endif - + " move to parent. call defx#call_action('search', s:parent) - + " if you want close_tree immediately, enable below line. call defx#call_action('close_tree') endfunction +function! DefxYarkPath(_) abort + let candidate = defx#get_candidate() + let @+ = candidate['action__path'] + echo 'yarked: ' . @+ +endfunction + function! s:trim_right(str, trim) return substitute(a:str, printf('%s$', a:trim), '', 'g') endfunction