mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:30:05 +08:00
feat(defx): use p
to toggle preview windows
close https://github.com/SpaceVim/SpaceVim/issues/4205
This commit is contained in:
parent
f9755af4c5
commit
f1e57311ca
@ -146,8 +146,7 @@ function! s:defx_init()
|
||||
\ defx#do_action('drop', 'split')
|
||||
nnoremap <silent><buffer><expr> st
|
||||
\ defx#do_action('drop', 'tabedit')
|
||||
nnoremap <silent><buffer><expr> p
|
||||
\ defx#do_action('open', 'pedit')
|
||||
nnoremap <silent><buffer><expr> p defx#do_action('call', g:defx_config_sid . 'DefxPreview')
|
||||
nnoremap <silent><buffer><expr> K
|
||||
\ defx#do_action('new_directory')
|
||||
nnoremap <silent><buffer><expr> N
|
||||
@ -207,6 +206,27 @@ function! s:DefxSmartL(_)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:DefxPreview(_) abort
|
||||
if s:preview_windows_opened()
|
||||
pclose
|
||||
else
|
||||
if !defx#is_directory()
|
||||
let filepath = defx#get_candidate()['action__path']
|
||||
exe 'topleft pedit ' . filepath
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
fun! s:preview_windows_opened()
|
||||
for nr in range(1, winnr('$'))
|
||||
if getwinvar(nr, "&pvw") == 1
|
||||
" found a preview
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfun
|
||||
|
||||
function! s:DefxSmartH(_)
|
||||
" if cursor line is first line, or in empty dir
|
||||
if line('.') ==# 1 || line('$') ==# 1
|
||||
|
Loading…
Reference in New Issue
Block a user