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
16 changes: 10 additions & 6 deletions autoload/fern/scheme/dict/mapping/clipboard.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ let s:clipboard = {
\}

function! fern#scheme#dict#mapping#clipboard#init(disable_default_mappings) abort
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-copy) :<C-u>call <SID>call('clipboard_copy')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-move) :<C-u>call <SID>call('clipboard_move')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste) :<C-u>call <SID>call('clipboard_paste')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-clear) :<C-u>call <SID>call('clipboard_clear')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-copy) :<C-u>call <SID>call('clipboard_copy')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-move) :<C-u>call <SID>call('clipboard_move')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste-confirm) :<C-u>call <SID>call('clipboard_paste', 1)<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste-immediate) :<C-u>call <SID>call('clipboard_paste', 0)<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-clear) :<C-u>call <SID>call('clipboard_clear')<CR>

" Alias map
nmap <buffer><silent> <Plug>(fern-action-clipboard-paste) <Plug>(fern-action-clipboard-paste-confirm)

if !a:disable_default_mappings
nmap <buffer><nowait> C <Plug>(fern-action-clipboard-copy)
Expand Down Expand Up @@ -49,12 +53,12 @@ function! s:map_clipboard_copy(helper) abort
\.then({ -> a:helper.sync.echo(printf('%d items are saved in clipboard to copy', len(nodes))) })
endfunction

function! s:map_clipboard_paste(helper) abort
function! s:map_clipboard_paste(helper, confirm_move) abort
if empty(s:clipboard)
return s:Promise.reject('Nothing to paste')
endif

if s:clipboard.mode ==# 'move'
if s:clipboard.mode ==# 'move' && a:confirm_move
let paths = map(copy(s:clipboard.candidates), { -> v:val._path })
let prompt = printf('The following %d nodes will be moved', len(paths))
for path in paths[:5]
Expand Down
16 changes: 10 additions & 6 deletions autoload/fern/scheme/file/mapping/clipboard.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ let s:clipboard = {
\}

function! fern#scheme#file#mapping#clipboard#init(disable_default_mappings) abort
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-copy) :<C-u>call <SID>call('clipboard_copy')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-move) :<C-u>call <SID>call('clipboard_move')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste) :<C-u>call <SID>call('clipboard_paste')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-clear) :<C-u>call <SID>call('clipboard_clear')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-copy) :<C-u>call <SID>call('clipboard_copy')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-move) :<C-u>call <SID>call('clipboard_move')<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste-confirm) :<C-u>call <SID>call('clipboard_paste', 1)<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-paste-immediate) :<C-u>call <SID>call('clipboard_paste', 0)<CR>
nnoremap <buffer><silent> <Plug>(fern-action-clipboard-clear) :<C-u>call <SID>call('clipboard_clear')<CR>

" Alias map
nmap <buffer><silent> <Plug>(fern-action-clipboard-paste) <Plug>(fern-action-clipboard-paste-confirm)

if !a:disable_default_mappings
nmap <buffer><nowait> C <Plug>(fern-action-clipboard-copy)
Expand Down Expand Up @@ -49,12 +53,12 @@ function! s:map_clipboard_copy(helper) abort
\.then({ -> a:helper.sync.echo(printf('%d items are saved in clipboard to copy', len(nodes))) })
endfunction

function! s:map_clipboard_paste(helper) abort
function! s:map_clipboard_paste(helper, confirm_move) abort
if empty(s:clipboard)
return s:Promise.reject('Nothing to paste')
endif

if s:clipboard.mode ==# 'move'
if s:clipboard.mode ==# 'move' && a:confirm_move
let paths = map(copy(s:clipboard.candidates), { -> v:val._path })
let prompt = printf('The following %d nodes will be moved', len(paths))
for path in paths[:5]
Expand Down
4 changes: 4 additions & 0 deletions doc/fern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1300,9 +1300,13 @@ The following mappings/actions are only available on file:// scheme.
action.
Note that this action has NO-relation with the system clipboard.

*<Plug>(fern-action-clipboard-paste-confirm)*
*<Plug>(fern-action-clipboard-paste-immediate)*
*<Plug>(fern-action-clipboard-paste)*
Paste copied/moved nodes on a cursor node. It does not clear the
internal clipboard so users can copy -> paste -> paste -> ...
The confirm variant prompts the user for confirmation when moving
files (this is default), and the immediate variant skips this prompt.
Note that this action has NO-relation with the system clipboard.

*<Plug>(fern-action-clipboard-clear)*
Expand Down
Loading