tamago324 / LeaderF-filer

📂 LeaderF file explorer
Apache License 2.0
39 stars 5 forks source link

[Feature] simplify file operation #30

Open roachsinai opened 4 years ago

roachsinai commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago
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 commented 4 years ago

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

How do you reproduce it?

tamago324 commented 4 years ago

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

The implementation is going to have to change.

roachsinai commented 4 years ago

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 commented 4 years ago

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!