Skip to content

Commit 726f418

Browse files
committed
Support scheme mapping overwrite
1 parent 318a195 commit 726f418

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

autoload/fern/internal/scheme.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ function! fern#internal#scheme#provider_new(scheme) abort
1111
endfunction
1212

1313
function! fern#internal#scheme#mapping_init(scheme, disable_default_mappings) abort
14-
return call('s:call', [a:scheme, 'mapping#init', a:disable_default_mappings])
14+
let mappings = get(g:, printf('fern#scheme#%s#mapping#mappings', a:scheme), [])
15+
for name in mappings
16+
call s:call(a:scheme, printf('mapping#%s#init', name), a:disable_default_mappings)
17+
endfor
18+
return s:call(a:scheme, 'mapping#init', a:disable_default_mappings)
1519
endfunction
1620

1721
function! fern#internal#scheme#complete_url(scheme, arglead, cmdline, cursorpos) abort
18-
return call('s:call', [a:scheme, 'complete#url', a:arglead, a:cmdline, a:cursorpos])
22+
return s:call(a:scheme, 'complete#url', a:arglead, a:cmdline, a:cursorpos)
1923
endfunction
2024

2125
function! fern#internal#scheme#complete_reveal(scheme, arglead, cmdline, cursorpos) abort
22-
return call('s:call', [a:scheme, 'complete#reveal', a:arglead, a:cmdline, a:cursorpos])
26+
return s:call(a:scheme, 'complete#reveal', a:arglead, a:cmdline, a:cursorpos)
2327
endfunction

autoload/fern/scheme/dict/mapping.vim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ let s:Prompt = vital#fern#import('Prompt')
22
let s:Promise = vital#fern#import('Async.Promise')
33

44
function! fern#scheme#dict#mapping#init(disable_default_mappings) abort
5-
call fern#scheme#dict#mapping#clipboard#init(a:disable_default_mappings)
6-
call fern#scheme#dict#mapping#rename#init(a:disable_default_mappings)
7-
85
nnoremap <buffer><silent> <Plug>(fern-action-new-leaf) :<C-u>call <SID>call('new_leaf')<CR>
96
nnoremap <buffer><silent> <Plug>(fern-action-new-branch) :<C-u>call <SID>call('new_branch')<CR>
107
nnoremap <buffer><silent> <Plug>(fern-action-copy) :<C-u>call <SID>call('copy')<CR>
@@ -204,3 +201,8 @@ function! s:map_edit_leaf(helper) abort
204201
\.then({ -> a:helper.async.reload_node(root.__key) })
205202
\.then({ -> a:helper.async.redraw() })
206203
endfunction
204+
205+
let g:fern#scheme#dict#mapping#mappings = get(g:, 'fern#scheme#dict#mapping#mappings', [
206+
\ 'clipboard',
207+
\ 'rename',
208+
\])

autoload/fern/scheme/file/mapping.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ let s:Promise = vital#fern#import('Async.Promise')
22
let s:Prompt = vital#fern#import('Prompt')
33

44
function! fern#scheme#file#mapping#init(disable_default_mappings) abort
5-
call fern#scheme#file#mapping#cd#init(a:disable_default_mappings)
6-
call fern#scheme#file#mapping#system#init(a:disable_default_mappings)
7-
call fern#scheme#file#mapping#clipboard#init(a:disable_default_mappings)
8-
call fern#scheme#file#mapping#rename#init(a:disable_default_mappings)
9-
call fern#scheme#file#mapping#terminal#init(a:disable_default_mappings)
10-
call fern#scheme#file#mapping#grep#init(a:disable_default_mappings)
11-
125
nnoremap <buffer><silent> <Plug>(fern-action-new-file) :<C-u>call <SID>call('new_file')<CR>
136
nnoremap <buffer><silent> <Plug>(fern-action-new-dir) :<C-u>call <SID>call('new_dir')<CR>
147
nnoremap <buffer><silent> <Plug>(fern-action-copy) :<C-u>call <SID>call('copy')<CR>
@@ -198,3 +191,12 @@ function! s:map_remove(helper) abort
198191
\.then({ -> a:helper.async.redraw() })
199192
\.then({ -> a:helper.sync.echo(printf('%d items are removed', len(ps))) })
200193
endfunction
194+
195+
let g:fern#scheme#file#mapping#mappings = get(g:, 'fern#scheme#file#mapping#mappings', [
196+
\ 'cd',
197+
\ 'clipboard',
198+
\ 'grep',
199+
\ 'rename',
200+
\ 'system',
201+
\ 'terminal',
202+
\])

0 commit comments

Comments
 (0)