Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions autoload/fern/internal/scheme.vim
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ function! fern#internal#scheme#provider_new(scheme) abort
endfunction

function! fern#internal#scheme#mapping_init(scheme, disable_default_mappings) abort
return call('s:call', [a:scheme, 'mapping#init', a:disable_default_mappings])
let mappings = get(g:, printf('fern#scheme#%s#mapping#mappings', a:scheme), [])
for name in mappings
call s:call(a:scheme, printf('mapping#%s#init', name), a:disable_default_mappings)
endfor
return s:call(a:scheme, 'mapping#init', a:disable_default_mappings)
endfunction

function! fern#internal#scheme#complete_url(scheme, arglead, cmdline, cursorpos) abort
return call('s:call', [a:scheme, 'complete#url', a:arglead, a:cmdline, a:cursorpos])
return s:call(a:scheme, 'complete#url', a:arglead, a:cmdline, a:cursorpos)
endfunction

function! fern#internal#scheme#complete_reveal(scheme, arglead, cmdline, cursorpos) abort
return call('s:call', [a:scheme, 'complete#reveal', a:arglead, a:cmdline, a:cursorpos])
return s:call(a:scheme, 'complete#reveal', a:arglead, a:cmdline, a:cursorpos)
endfunction
8 changes: 5 additions & 3 deletions autoload/fern/scheme/dict/mapping.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ let s:Prompt = vital#fern#import('Prompt')
let s:Promise = vital#fern#import('Async.Promise')

function! fern#scheme#dict#mapping#init(disable_default_mappings) abort
call fern#scheme#dict#mapping#clipboard#init(a:disable_default_mappings)
call fern#scheme#dict#mapping#rename#init(a:disable_default_mappings)

nnoremap <buffer><silent> <Plug>(fern-action-new-leaf) :<C-u>call <SID>call('new_leaf')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-new-branch) :<C-u>call <SID>call('new_branch')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-copy) :<C-u>call <SID>call('copy')<CR>
Expand Down Expand Up @@ -204,3 +201,8 @@ function! s:map_edit_leaf(helper) abort
\.then({ -> a:helper.async.reload_node(root.__key) })
\.then({ -> a:helper.async.redraw() })
endfunction

let g:fern#scheme#dict#mapping#mappings = get(g:, 'fern#scheme#dict#mapping#mappings', [
\ 'clipboard',
\ 'rename',
\])
16 changes: 9 additions & 7 deletions autoload/fern/scheme/file/mapping.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ let s:Promise = vital#fern#import('Async.Promise')
let s:Prompt = vital#fern#import('Prompt')

function! fern#scheme#file#mapping#init(disable_default_mappings) abort
call fern#scheme#file#mapping#cd#init(a:disable_default_mappings)
call fern#scheme#file#mapping#system#init(a:disable_default_mappings)
call fern#scheme#file#mapping#clipboard#init(a:disable_default_mappings)
call fern#scheme#file#mapping#rename#init(a:disable_default_mappings)
call fern#scheme#file#mapping#terminal#init(a:disable_default_mappings)
call fern#scheme#file#mapping#grep#init(a:disable_default_mappings)

nnoremap <buffer><silent> <Plug>(fern-action-new-file) :<C-u>call <SID>call('new_file')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-new-dir) :<C-u>call <SID>call('new_dir')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-copy) :<C-u>call <SID>call('copy')<CR>
Expand Down Expand Up @@ -198,3 +191,12 @@ function! s:map_remove(helper) abort
\.then({ -> a:helper.async.redraw() })
\.then({ -> a:helper.sync.echo(printf('%d items are removed', len(ps))) })
endfunction

let g:fern#scheme#file#mapping#mappings = get(g:, 'fern#scheme#file#mapping#mappings', [
\ 'cd',
\ 'clipboard',
\ 'grep',
\ 'rename',
\ 'system',
\ 'terminal',
\])
34 changes: 32 additions & 2 deletions doc/fern-develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ See https://github.com/lambdalisue/fern-comparator-lexical.vim as example.
=============================================================================
MAPPING *fern-develop-mapping*

TBW
Fern provides global mappings under "autoload/fern/mapping" directory.
Mapping MUST provide an init function as "fern#mapping#{name}#init()" with
a boolean argument to disable default mappings.

Mappings under that directory are registered automatically when a filename has
listed in |g:fern#mapping#mappings| variable.

So 3rd party plugin MUST register mappings by add followings to plugin.vim
like:
>
call add(g:fern#mapping#mappings, ['your_plugin'])
>
*g:fern#mapping#mappings*
A |List| of globally available mapping names.
A target mapping MUST exist under "fern#mapping#" namespace.


=============================================================================
Expand Down Expand Up @@ -292,7 +306,23 @@ the following methods.
-----------------------------------------------------------------------------
MAPPING *fern-develop-scheme-mapping*

TBW
Fern provides scheme mappings under "autoload/fern/scheme/{scheme}/mapping"
directory. Mapping MUST provide an init function as
"fern#scheme#{scheme}#mapping#{name}#init()" with a boolean argument to disable
default mappings.

Mappings under that directory are registered automatically when a filename has
listed in |g:fern#scheme#{scheme}#mapping#mappings| variable.

So 3rd party plugin MUST register mappings by add followings to plugin.vim
like:
>
call add(g:fern#scheme#file#mapping#mappings, ['your_plugin'])
>
*g:fern#scheme#{scheme}#mapping#mappings*
A |List| of scheme available mapping names for {scheme}.
A target mapping MUST exist under "fern#scheme#{scheme}#mapping#"
namespace.


=============================================================================
Expand Down