Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

[Feature] simplify file operation #30

Open
roachsinai opened this issue Apr 18, 2020 · 6 comments
Open

[Feature] simplify file operation #30

roachsinai opened this issue Apr 18, 2020 · 6 comments

Comments

@roachsinai
Copy link

When using defx I can use setting below to create file/directory, remove file, and no need to remember all that maps, just one map m.

nnoremap <silent><buffer>m :call <sid>defx_context_menu()<CR>
function! s:defx_context_menu() abort
  let l:actions = ['new_multiple_files', 'rename', 'copy', 'move', 'paste', 'remove']
  let l:selection = confirm('Action?', "&New file/directory\n&Rename\n&Copy\n&Move\n&Paste\n&Delete")
  silent exe 'redraw'
  return feedkeys(defx#do_action(l:actions[l:selection - 1]))
endfunc

Could this possible when using LeaderF-filer?

@tamago324
Copy link
Owner

Thank you for the suggestion.
That's a great idea!

This can be done by doing the following

let g:Lf_NormalMap = {
\   "Filer": [
\      ['m', ':call Lf_filer_context_menu()<CR>']
\   ],
\}

function! Lf_filer_context_menu() abort
    exec g:Lf_py "from filerExpl import *"
    let l:commands = ['create_file', 'mkdir', 'rename', 'copy', 'paste']
    let l:selection = confirm('Action?', "New &file\n&New Directory\n&Rename\n&Copy\n&Paste")
    silent exe 'redraw'
    exec printf('exec g:Lf_py "filerExplManager.do_command(''%s'')"', l:commands[l:selection - 1])
endfunction

I'm going to add it to the README.
Thank you so much!

@roachsinai
Copy link
Author

roachsinai commented Apr 18, 2020

let g:Lf_NormalMap = {
	\ "File":   [["<ESC>", ':exec g:Lf_py "fileExplManager.quit()"<CR>']],
	\ "Filer":  [['m', ':call Lf_filer_context_menu()<CR>']],
	\ "Buffer": [["<ESC>", ':exec g:Lf_py "bufExplManager.quit()"<CR>']],
	\ "Mru":    [["<ESC>", ':exec g:Lf_py "mruExplManager.quit()"<CR>']],
	\ "Tag":    [["<ESC>", ':exec g:Lf_py "tagExplManager.quit()"<CR>']],
	\ "BufTag":    [["<ESC>", ':exec g:Lf_py "bufTagExplManager.quit()"<CR>']],
	\ "Function":    [["<ESC>", ':exec g:Lf_py "functionExplManager.quit()"<CR>']],
	\ "Colorscheme":    [["<ESC>", ':exec g:Lf_py "colorschemeExplManager.quit()"<CR>']],
	\ }

I have my setting about this issue above, and use Lf_filer_context_menu you posted above. Could you tell me how to trigger the function?

I can't trigger when on Filer normal mode press m.

@tamago324
Copy link
Owner

Try running it with a minimal vimrc.
Also, take a look at the minimal vimrc.

How do you reproduce it?

@tamago324
Copy link
Owner

I'm sorry. I couldn't set the popup mapping in g:Lf_NormalMap.

The implementation is going to have to change.

@roachsinai
Copy link
Author

OK, thanks for your work! Just wairing for the success! Btw does the reason there is no delete operation is the delete is dangerous?

If so I think it will be better to let people to decided whether add it to normal map.

@tamago324
Copy link
Owner

Using g:Lf_NormalMap, customizing popup mappings is technically difficult, but I'll put it in the TODO.

Btw does the reason there is no delete operation is the delete is dangerous?

Yes. I'm struggling with how to implement it because it's dangerous.

Sure, it's just a matter of not mapping it out. I'll try to implement it in the future.

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants