Skip to content

Commit bf675a0

Browse files
committed
Add new focus:parent action
1 parent 31c76b3 commit bf675a0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

autoload/fern/mapping/node.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function! fern#mapping#node#init(disable_default_mappings) abort
99
nnoremap <buffer><silent> <Plug>(fern-action-expand:in) :<C-u>call <SID>call('expand_in')<CR>
1010
nnoremap <buffer><silent> <Plug>(fern-action-collapse) :<C-u>call <SID>call('collapse')<CR>
1111
nnoremap <buffer><silent> <Plug>(fern-action-reveal) :<C-u>call <SID>call('reveal')<CR>
12+
nnoremap <buffer><silent> <Plug>(fern-action-focus:parent) :<C-u>call <SID>call('focus_parent')<CR>
1213
1314
nnoremap <buffer><silent> <Plug>(fern-action-enter) :<C-u>call <SID>call('enter')<CR>
1415
nnoremap <buffer><silent> <Plug>(fern-action-leave) :<C-u>call <SID>call('leave')<CR>
@@ -115,6 +116,16 @@ function! s:map_reveal(helper) abort
115116
return fern#internal#viewer#reveal(a:helper, path)
116117
endfunction
117118

119+
function! s:map_focus_parent(helper) abort
120+
let owner = a:helper.sync.get_cursor_node().__owner
121+
122+
if empty(owner)
123+
return
124+
endif
125+
126+
call a:helper.sync.focus_node(owner.__key)
127+
endfunction
128+
118129
function! s:map_enter(helper) abort
119130
let node = a:helper.sync.get_cursor_node()
120131
if node is# v:null

doc/fern.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,9 @@ GLOBAL *fern-mapping-global*
892892
*<Plug>(fern-action-reveal)*
893893
Open a prompt to reveal a node in a tree.
894894

895+
*<Plug>(fern-action-focus:parent)*
896+
Focus the parent of the cursor node.
897+
895898
*<Plug>(fern-action-enter)*
896899
Open a new fern buffer which root node is a cursor node. In other
897900
word, get enter the directory.

0 commit comments

Comments
 (0)