mhinz / neovim-remote

:ok_hand: Support for --remote and friends.
MIT License
1.73k stars 83 forks source link

--remote-tab creates a new tab even if the file is already being edited #156

Open MrVizious opened 4 years ago

MrVizious commented 4 years ago

Hello!

When I try to open a new file remotely with --remote-tab, and the target nvim instance already has such file being edited in a tab (even if it is the one being edited), it creates a new tab editing the same buffer.

Is this intended behaviour? I ask that because, from what I could gather, that's not the case in regular vim.

Do you know any workarounds?

Thanks!

MrVizious commented 4 years ago

Has anyone found the same problem as I did?

rosshadden commented 4 years ago

Yes, I was trying to find a solution to the same problem.

MrVizious commented 3 years ago

Yes, I was trying to find a solution to the same problem.

And did you have any luck with that?

rosshadden commented 3 years ago

Oh I didn't mean to leave that ambiguous. No, I haven't had any luck with it.

salgadobreno commented 3 years ago

My guess is that the command/argument is just passed through to Vim so this would not be exactly a neovim-remote issue. Still there's probably a solution somewhere with custom command/expression to have this logic in and I'd like to know about it too :)

Edit: https://www.gilesorr.com/blog/vim-tab-drop.html Edit2: Managed to do it here with 'remote-expr', in this example I was trying to configure Godot external editor, file opening script command: /bin/bash -c "nvr --remote-expr $'execute(\'tab drop {file} +{line}\')'; wmctrl -a buzaga@buzaga-Dell-System-XPS"

Second command changes the focus to my terminal by the way

newptcai commented 2 years ago

My guess is that the command/argument is just passed through to Vim so this would not be exactly a neovim-remote issue. Still there's probably a solution somewhere with custom command/expression to have this logic in and I'd like to know about it too :)

Edit: https://www.gilesorr.com/blog/vim-tab-drop.html Edit2: Managed to do it here with 'remote-expr', in this example I was trying to configure Godot external editor, file opening script command: /bin/bash -c "nvr --remote-expr $'execute(\'tab drop {file} +{line}\')'; wmctrl -a buzaga@buzaga-Dell-System-XPS"

Second command changes the focus to my terminal by the way

This has only one problem. The +{line} does not seem to work in neovim. Probably a bug.

liujoey commented 1 year ago

neovim-remote should provide drop option, see :h drop

dstadelm commented 1 year ago

My 5 cents on this in zsh

    nvr -c "tab drop $argv"

or if you prefer

    nvr -c "tab drop $argv | set bufhidden=delete"

in my .zshrc

export NVIM_LISTEN_ADDRESS=/tmp/nvimsocket
function v(){
  if [[ -S $NVIM_LISTEN_ADDRESS ]]; then
    nvr -c "tab drop $argv | set bufhidden=delete"
  else
    nvr -s $argv
  fi
}

in bash (untested)

    nvr -c "tab drop $@"
    nvr -c "tab drop $@ | set bufhidden=delete"