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

Extra buffer opening with neovim 0.3.0 #417

Closed
kierun opened this issue Jun 12, 2018 · 18 comments
Closed

Extra buffer opening with neovim 0.3.0 #417

kierun opened this issue Jun 12, 2018 · 18 comments

Comments

@kierun
Copy link

kierun commented Jun 12, 2018

I launch neovim-qt via this zsh function:

function gvim {                                                                 
    nvim-qt --geometry 970x512 --no-ext-tabline -- "$@" &                       
}   

I updated to neovim 0.3.0 and when calling the above, I get a window to open just fine but there are two buffers: an empty one and another buffer the one with the file.

screenshot

@kierun
Copy link
Author

kierun commented Jun 12, 2018

Just for completeness sake. When I select the second buffer, the one where my file is, this is what I get:

screenshot

@kierun
Copy link
Author

kierun commented Jun 13, 2018

@equalsraf Are you still looking at these? A while back you were very quick at replying and now I have two bugs reported and have heard nothing? You okay? You still maintaining this? …

@equalsraf
Copy link
Owner

hi @kierun I'm good, just crazy busy :) thanks for asking.

As for the issue. I was able to reproduce this in sh too. And I confirmed it does not happen with neovim alone. To replicate is enough to call nvim-qt with a single file name argument (the file does not need to exist) i.e.

bin/nvim-qt --nvim ../../neovim/build/bin/nvim -- -u NONE /tmp/test

However this does not cause the same issue

../../neovim/build/bin/nvim  -u NONE /tmp/test

The additional buffer is unnamed which suggests this is not a bug regarding command line arguments.

On a side note you can probably remove the & since nvim-qt now forks into the backgroud.

@kierun
Copy link
Author

kierun commented Jun 13, 2018

hi @kierun I'm good, just crazy busy :) thanks for asking.

You're welcome.

As for the issue. I was able to reproduce this in sh too.

Right, so not the shell… Good.

On a side note you can probably remove the & since nvim-qt now forks into the background.

Yup. Done that, all working. Thanks.

@JAffleck
Copy link

JAffleck commented Jun 17, 2018

FWIW, until this bug is fixed you can kill the extra empty buffer by putting this init.vim

if @% == ""
  bd
endif

justinmk added a commit to justinmk/neovim that referenced this issue Jun 17, 2018
If stdin is not a TTY we read it into buffer 1, as text. But if the
stdin pipe is empty, Nvim was most likely invoked for some other reason.
DWIM: select buffer 2 (if it exists). Example:

    echo file1 | xargs nvim

closes neovim#8560
closes neovim#8561
ref equalsraf/neovim-qt#417
@justinmk
Copy link
Contributor

I wouldn't expect nvim-qt to be affected by this, but neovim/neovim#8576 may help with this. If not I don't know what the issue could be. Can someone try that PR?

@kierun
Copy link
Author

kierun commented Jun 18, 2018

@JAffleck

Even better, just add it to ~/.config/nvim/ginit.vim

@kierun kierun closed this as completed Jun 18, 2018
@kierun kierun reopened this Jun 18, 2018
@kierun
Copy link
Author

kierun commented Jun 18, 2018

Sorry, pressed the wrong key…

@roflcopter4
Copy link
Contributor

roflcopter4 commented Jun 19, 2018

I managed to fix this (for me) with this extremely simple patch. It seems that for whatever reason the current version neovim doesn't like getting option paramaters passed after files. Neovim-qt was passing arguments that look like --cmd let &rtp.=',/usr/local/share/nvim-qt/runtime' --cmd set termguicolors *FILES* --embed --headless. There are two simple solutions. The first is to define an alias like alias gvi='nvim-qt --no-ext-tabline -- --' which forces nvim-qt to put its arguments before the file list. The second and better solution is to force nvim-qt to always put its arguments before the file list. This patch does that.

diff --git a/src/neovimconnector.cpp b/src/neovimconnector.cpp
index 1f15768..1ba4f4c 100644
--- a/src/neovimconnector.cpp
+++ b/src/neovimconnector.cpp
@@ -196,8 +196,8 @@ NeovimConnector* NeovimConnector::spawn(const QStringList& params, const QString
        QProcess *p = new QProcess();
        QStringList args;
        if (params.indexOf("--") == -1) {
-               args.append(params);
                args << "--embed" << "--headless";
+               args.append(params);
        } else {
                // Neovim accepts a -- argument after which only
                // filenames are passed

I'm not sure if it's worth opening a pull request for something this small but this does fix the problem.

@kierun
Copy link
Author

kierun commented Jun 19, 2018

@roflcopter4 I just tried your patch and can confirm that this solves the issue. Thank you.

@equalsraf
Copy link
Owner

Thanks @roflcopter4 that fixes it.

Totally missed that one, but it does make sense, although I would only expect this to happen when -- was in use.

I tried to reproduce this in standalone nvim with other cli options but failed. Maybe this only happens when --embed is in effect.

I'm not sure if it's worth opening a pull request for something this small but this does fix the problem.

Please do, I'll be happy to just press the merge button.

justinmk added a commit to justinmk/neovim that referenced this issue Jun 19, 2018
If stdin is not a TTY we read it into buffer 1, as text. But if the
stdin pipe is empty, Nvim was most likely invoked for some other reason.
DWIM: select buffer 2 (if it exists). Example:

    echo file1 | xargs nvim

closes neovim#8560
closes neovim#8561
ref equalsraf/neovim-qt#417
justinmk added a commit to justinmk/neovim that referenced this issue Jun 19, 2018
If stdin is not a TTY we read it into buffer 1, as text. But if the
stdin pipe is empty, Nvim was most likely invoked for some other reason.
DWIM: select buffer 2 (if it exists). Example:

    echo file1 | xargs nvim

closes neovim#8560
closes neovim#8561
ref equalsraf/neovim-qt#417
@DrakeXiang
Copy link

This issue still remains on windows, neovim 0.3.1

@equalsraf equalsraf reopened this Jul 24, 2018
@equalsraf
Copy link
Owner

@DrakeXiang this should be fixed in master.

@dumblob
Copy link

dumblob commented Jul 27, 2018

@equalsraf I've tested right now the latest nightly build (neovim/neovim@5f15788 ) under Windows 10 and it still doesn't work (one has to close the buffer with :bd to get the expected result).

@justinmk
Copy link
Contributor

@dumblob can you try the artifact from neovim/neovim#8901 . It works when I tested it.

@dumblob
Copy link

dumblob commented Aug 27, 2018

@justinmk great, it works now for me with the artifact. Thanks.

@w1mb0r
Copy link

w1mb0r commented Sep 6, 2018

I tested with the latest nightly and this issue doesn't occur anymore.
thanks!

@equalsraf
Copy link
Owner

Ok closing this, thanks for checking.

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

8 participants