Archlinux, termite -> tmux -> neovim

I want to open ranger in new pane, and when it ended and pane was closed - open selected file/files. This flow is similar to Tim Pope`s dispatch behavior

" inspired by francoiscabrol plugin
function! OpenRanger(dir)
  let currentPath = expand(a:dir)
  let tmp_file_path = tempname()
  exec 'silent !tmux splitw ranger --choosefiles=' . shellescape(tmp_file_path) . ' ' .currentPath
  call system('notify-send "exec is ended"') " debug string, was fired
  if filereadable(tmp_file_path)
    call system('notify-send "tmpfile was readable"') " debug string, wasnt fired
    for f in readfile(tmp_file_path)
      exec 'edit '. f
    call delete(tmp_file_path)

nnoremap <leader>f :call OpenRanger('%:p:h')<CR>
nnoremap <leader>F :call OpenRanger('')<CR>

How can I force to execute if filereadable(tmp_file_path) after pane was closed (on neovim, which have issues with that )?

This don't work either

function! OpenRanger(dir)
  let currentPath = expand(a:dir)
  let tmp_file_path = tempname()
  let rangerCallback = { 'name': 'ranger' , 'tmp_file_path': tmp_file_path}
  function! rangerCallback.on_exit(id, code)
    call system('notify-send callback') " was fired before I close ranger
    " bdelete!
    if filereadable(self.tmp_file_path)
      for f in readfile(self.tmp_file_path)
        exec 'edit '. f
      call delete(self.tmp_file_path)
  call termopen('tmux splitw ranger --choosefiles=' . shellescape(tmp_file_path) . ' ' . currentPath, rangerCallback)


run ranger using tmux

call te#tmux#run_command('ranger',0x01)
| improve this answer | |
  • 1
    you should explain how your plugin achieves it – Christian Brabandt Sep 14 '17 at 6:46
  • This is just a vim function.You can copy it to your own vimrc, change its name.In this function, It just calls tmux with property argument using system function in vim. – tracyone Sep 14 '17 at 8:49
  • I know what a function is. I want to know, what exactly the function does. E.g. what are the exact tmux commands it will be executing? – Christian Brabandt Sep 14 '17 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.