Skip to content

Commit

Permalink
Use : in hidden/mark actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 31, 2020
1 parent 92a2bbb commit 0a21cdb
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 22 deletions.
9 changes: 9 additions & 0 deletions autoload/fern/action.vim
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
let s:Action = vital#fern#import('App.Action')
call s:Action.set_ignores([
\ 'hidden-set',
\ 'hidden-unset',
\ 'hidden-toggle',
\ 'mark-clear',
\ 'mark-set',
\ 'mark-unset',
\ 'mark-toggle',
\])

function! fern#action#_init() abort
call s:Action.init()
Expand Down
19 changes: 15 additions & 4 deletions autoload/fern/mapping/filter.vim
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
function! fern#mapping#filter#init(disable_default_mappings) abort
nnoremap <buffer><silent> <Plug>(fern-action-hidden-set) :<C-u>call <SID>call('hidden_set')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-hidden-unset) :<C-u>call <SID>call('hidden_unset')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-hidden-toggle) :<C-u>call <SID>call('hidden_toggle')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-hidden:set) :<C-u>call <SID>call('hidden_set')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-hidden:unset) :<C-u>call <SID>call('hidden_unset')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-hidden:toggle) :<C-u>call <SID>call('hidden_toggle')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-include) :<C-u>call <SID>call('include')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-exclude) :<C-u>call <SID>call('exclude')<CR>
" Alias
nmap <buffer> <Plug>(fern-action-hidden) <Plug>(fern-action-hidden:toggle)
if !a:disable_default_mappings
nmap <buffer><nowait> ! <Plug>(fern-action-hidden-toggle)
nmap <buffer><nowait> ! <Plug>(fern-action-hidden)
nmap <buffer><nowait> fi <Plug>(fern-action-include)
nmap <buffer><nowait> fe <Plug>(fern-action-exclude)
endif

" DEPRECATED:
nmap <buffer><silent><expr> <Plug>(fern-action-hidden-set)
\ fern#mapping#deprecated('fern-action-hidden-set', 'fern-action-hidden:set')
nmap <buffer><silent><expr> <Plug>(fern-action-hidden-unset)
\ fern#mapping#deprecated('fern-action-hidden-unset', 'fern-action-hidden:unset')
nmap <buffer><silent><expr> <Plug>(fern-action-hidden-toggle)
\ fern#mapping#deprecated('fern-action-hidden-toggle', 'fern-action-hidden:toggle')
endfunction

function! s:call(name, ...) abort
Expand Down
44 changes: 33 additions & 11 deletions autoload/fern/mapping/mark.vim
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
let s:Promise = vital#fern#import('Async.Promise')

function! fern#mapping#mark#init(disable_default_mappings) abort
nnoremap <buffer><silent> <Plug>(fern-action-mark-clear) :<C-u>call <SID>call('mark_clear')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark-toggle) :<C-u>call <SID>call('mark_toggle')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark-set) :<C-u>call <SID>call('mark_set')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark-unset :<C-u>call <SID>call('mark_unset')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark-set) :call <SID>call('mark_set')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark-unset) :call <SID>call('mark_unset')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark-toggle) :call <SID>call('mark_toggle')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark:clear) :<C-u>call <SID>call('mark_clear')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark:set) :<C-u>call <SID>call('mark_set')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark:unset :<C-u>call <SID>call('mark_unset')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-mark:toggle) :<C-u>call <SID>call('mark_toggle')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark:set) :call <SID>call('mark_set')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark:unset) :call <SID>call('mark_unset')<CR>
vnoremap <buffer><silent> <Plug>(fern-action-mark:toggle) :call <SID>call('mark_toggle')<CR>
" Alias
nmap <buffer> <Plug>(fern-action-mark) <Plug>(fern-action-mark:toggle)
vmap <buffer> <Plug>(fern-action-mark) <Plug>(fern-action-mark:toggle)
if !a:disable_default_mappings
nmap <buffer><nowait> <C-j> <Plug>(fern-action-mark-toggle)j
nmap <buffer><nowait> <C-k> k<Plug>(fern-action-mark-toggle)
nmap <buffer><nowait> - <Plug>(fern-action-mark-toggle)
vmap <buffer><nowait> - <Plug>(fern-action-mark-toggle)
nmap <buffer><nowait> <C-j> <Plug>(fern-action-mark)j
nmap <buffer><nowait> <C-k> k<Plug>(fern-action-mark)
nmap <buffer><nowait> - <Plug>(fern-action-mark)
vmap <buffer><nowait> - <Plug>(fern-action-mark)
endif

" DEPRECATED:
nmap <buffer><silent><expr> <Plug>(fern-action-mark-clear)
\ <SID>deprecated('fern-action-mark-clear', 'fern-action-mark:clear')
nmap <buffer><silent><expr> <Plug>(fern-action-mark-set)
\ <SID>deprecated('fern-action-mark-set', 'fern-action-mark:set')
nmap <buffer><silent><expr> <Plug>(fern-action-mark-unset)
\ <SID>deprecated('fern-action-mark-unset', 'fern-action-mark:unset')
nmap <buffer><silent><expr> <Plug>(fern-action-mark-toggle)
\ <SID>deprecated('fern-action-mark-toggle', 'fern-action-mark:toggle')
vmap <buffer><silent><expr> <Plug>(fern-action-mark-clear)
\ <SID>deprecated('fern-action-mark-clear', 'fern-action-mark:clear')
vmap <buffer><silent><expr> <Plug>(fern-action-mark-set)
\ <SID>deprecated('fern-action-mark-set', 'fern-action-mark:set')
vmap <buffer><silent><expr> <Plug>(fern-action-mark-unset)
\ <SID>deprecated('fern-action-mark-unset', 'fern-action-mark:unset')
vmap <buffer><silent><expr> <Plug>(fern-action-mark-toggle)
\ <SID>deprecated('fern-action-mark-toggle', 'fern-action-mark:toggle')
endfunction

function! s:call(name, ...) abort
Expand Down
43 changes: 36 additions & 7 deletions doc/fern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,18 +665,31 @@ GLOBAL *fern-mapping-global*
The original window width will be restored once user leave the window.
It only works on a drawer style fern window.

*<Plug>(fern-action-hidden-set)*
*<Plug>(fern-action-hidden:set)*
Show hidden nodes. For example hidden nodes in file:// scheme is a
file or directory starts from '.' character.

*<Plug>(fern-action-hidden-unset)*
*<Plug>(fern-action-hidden:unset)*
Hide hidden nodes. For example hidden nodes in file:// scheme is a
file or directory starts from '.' character.

*<Plug>(fern-action-hidden-toggle)*
*<Plug>(fern-action-hidden:toggle)*
Toggle hidden nodes. For example hidden nodes in file:// scheme is a
file or directory starts from '.' character.

*<Plug>(fern-action-hidden)*
An alias to "hidden:toggle" action. Users can overwrite this mapping
to change the default behavior of "hidden" action.

*<Plug>(fern-action-hidden-set)*
DEPRECATED: Use |<Plug>(fern-action-hidden:set)| instead.

*<Plug>(fern-action-hidden-unset)*
DEPRECATED: Use |<Plug>(fern-action-hidden:unset)| instead.

*<Plug>(fern-action-hidden-toggle)*
DEPRECATED: Use |<Plug>(fern-action-hidden:toggle)| instead.

*<Plug>(fern-action-include)*
Open a prompt to enter include filter. Users can type a |pattern| to
filter nodes recursively.
Expand All @@ -685,17 +698,33 @@ GLOBAL *fern-mapping-global*
Open a prompt to enter exclude filter. Users can type a |pattern| to
filter nodes recursively.

*<Plug>(fern-action-mark-clear)*
*<Plug>(fern-action-mark:clear)*
Clear existing marks.

*<Plug>(fern-action-mark-toggle)*
*<Plug>(fern-action-mark:set)*
Set marks on cursor node(s).

*<Plug>(fern-action-mark:unset)*
Unset marks on cursor node(s).

*<Plug>(fern-action-mark:toggle)*
Toggle marks on cursor node(s).

*<Plug>(fern-action-mark)*
An alias to "mark:toggle" action. Users can overwrite this mapping to
change the default behavior of "mark" action.

*<Plug>(fern-action-mark-clear)*
DEPRECATED: Use |<Plug>(fern-action-mark:clear)| instead.

*<Plug>(fern-action-mark-set)*
Set marks on cursor node(s).
DEPRECATED: Use |<Plug>(fern-action-mark:set)| instead.

*<Plug>(fern-action-mark-unset)*
Unset marks on cursor node(s).
DEPRECATED: Use |<Plug>(fern-action-mark:unset)| instead.

*<Plug>(fern-action-mark-toggle)*
DEPRECATED: Use |<Plug>(fern-action-mark:toggle)| instead.

*<Plug>(fern-action-debug)*
Echo debug information of a cursor node.
Expand Down

0 comments on commit 0a21cdb

Please sign in to comment.