Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't behave like vim for --remote-silent #13

Closed
gbin opened this issue May 11, 2016 · 14 comments
Closed

Doesn't behave like vim for --remote-silent #13

gbin opened this issue May 11, 2016 · 14 comments

Comments

@gbin
Copy link
Contributor

gbin commented May 11, 2016

I have this function defined so I can reuse the same vim per tmux window.

vim () {
        export DISPLAY=:0 
        $HOME/prefix/bin/vim --servername VIM$TMUX_WINDOW $(if [ ! -z "$@" ]; then echo "--remote-silent";fi;) "$@"
}

It works perfectly: first vim foo.txt creates a vim server editing the file.
then from another pane vim bar.txt will connect to the first vim and open bar.txt there.

now if I use nvr:

nvr () {
        export DISPLAY=:0 
        $HOME/prefix/bin/nvr --servername VIM$TMUX_WINDOW $(if [ ! -z "$@" ]; then echo "--remote-silent";fi;) "$@"
}

The first foo.txt doesn't create the first neovim instance, just returns silently.

I gonna try to figure out what is going wrong but maybe you have idea about it ?

@MiSawa
Copy link

MiSawa commented May 25, 2016

--remote-wait-silent, --remote-tab-silent, --remote-tab-wait-silent doesn't behave like vim too.

@mhinz
Copy link
Owner

mhinz commented Jun 6, 2016

So, I rewrote the script quite a bit. Please test the latest changes.

Any --remote-* flag should now start a local instance, if it can't connect to a remote instance. If the flag isn't from the *-silent family, a nice message with possible solutions will be shown, too.

Moreover, nvr file1 file2 is the same as nvr --remote file1 file2.

@MiSawa
Copy link

MiSawa commented Jun 7, 2016

Looks good! thank you 😄

@mhinz
Copy link
Owner

mhinz commented Jun 7, 2016

@MiSawa Nice. :)

@gbin Works for you, too?

(By the way, in the meanwhile I released v1.2, so pip3 install -U neovim-remote should fix this problem.)

@mhinz
Copy link
Owner

mhinz commented Jun 9, 2016

Well, by now I'm pretty sure that it's working, but please reopen if it's not the case for you.

Thanks for bringing this up!

@tpict
Copy link

tpict commented Jul 18, 2016

Is it possible to make --remote-wait work from a terminal within Neovim and stop waiting once the new buffer is closed? At the moment it seems to hang indefinitely, since presumably it's waiting for the Neovim instance in which it's contained to exit

@mhinz
Copy link
Owner

mhinz commented Jul 18, 2016

As you already noticed, an autocmd is used for --remote-wait. On VimLeave, the nvim process sends a msgpack notification to nvr saying "exiting".

Of course there are buffer-local autocmds, so it could do the same on BufDelete instead. But what about --remote-wait file1 file2? It would quickly become somewhat complicated to decide when to send the notification to nvr.

What exactly is your use case? Maybe we can work around it.

@tpict
Copy link

tpict commented Jul 18, 2016

I tend to just keep a Neovim instance open and use it for editing and terminal multiplexing. I'd like to use nvr --remote-wait as my $EDITOR variable so I can, for example, do git commit without spawning a new Neovim instance (obviously fugitive does this already but it would be nice to have the git command do the same thing).

@mhinz
Copy link
Owner

mhinz commented Jul 19, 2016

So, the actual wait isn't really important within :terminal, right?

You could do something like this:

export EDITOR=nvr

nvr() {
    [[ -n "$VIM" ]] && command nvr || command nvr --remote-wait
}

($VIM is set by Vim itself, so usually it shouldn't be defined outside of :term.)

@tpict
Copy link

tpict commented Jul 19, 2016

screenshot from 2016-07-19 11 29 22

Maybe this better illustrates the issue. Since the nvr script finishes before you can write to and close COMMIT_EDITMSG, git aborts the commit and ignores changes to the file.

@mhinz
Copy link
Owner

mhinz commented Jul 19, 2016

Oh, I see.

Actually, the only thing I can't think of right now is a reliable way to detect if we're inside or outside of :term.

I try to come up with a PoC that relies on the user having the following in his vimrc:

if has('nvim')
  let $NVIM_TERMINAL = 1
endif

mhinz added a commit that referenced this issue Jul 19, 2016
This requires $NVIM_TERMINAL to be set. Put this in your vimrc:

    if has('nvim')
      let $NVIM_TERMINAL = 1
    endif

References #13
@mhinz
Copy link
Owner

mhinz commented Jul 19, 2016

Please pull from master and put what I wrote above in your vimrc. Hopefully it should work now.

@tpict
Copy link

tpict commented Jul 19, 2016

That works just great! Thank you so much!

@peterwillcn
Copy link

peterwillcn commented May 10, 2019

export EDITOR='nvim --remote-tab-wait-silent' iTrm2 + Fish cool...

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

No branches or pull requests

5 participants