equalsraf / neovim-qt

Neovim client library and GUI, in Qt5.
https://github.com/equalsraf/neovim-qt/wiki
ISC License
1.85k stars 171 forks source link

Eliminate "--" for separating nvim-qt arguments from file names #449

Open justinmk opened 6 years ago

justinmk commented 6 years ago

Currently nvim-qt requires -- to know which arguments to send to nvim.exe.

It would be better to whitelist things like --geometry, and send everything else to nvim.exe. (Ideally the number of arguments accepted by nvim-qt should be minimal, anyways...)

One problem with the -- scheme is that it makes it difficult to associate nvim-qt.exe with filetypes. Because the OS sends the file list to the program, it doesn't know that -- must be prepended.

ref https://github.com/neovim/neovim/issues/7222#issuecomment-416017347

equalsraf commented 6 years ago

Some open points in my mind on this:

ref neovim/neovim#7222 (comment)

I'll need to have a closer look on this one, but I suspect the double -- is the same bug discussed in other issues. To be clear - it should not be necessary to use -- when passing file arguments. The use of cmd in there also seems strange to me, but maybe that is normal.

justinmk commented 6 years ago

what happens with --help or --version (currently this option does not exist but it was requested before) - I assume we don't forward these

I think we should forward them (see below), and skip nvim-qt.exe entirely. But --version and --help are special cases, nvim-qt might want to print its help/version info to stdout before passing control to nvim.exe.

more generally what happens when the user calls a command that does not start nvim ... [for example] nvim-qt -- --help

Any case where the Nvim UI is not started should also not start the Nvim-Qt GUI (exec() to nvim). For example, Ex-mode probably won't work well with a GUI (and doesn't seem useful for a GUI).

echo "foo" | nvim-qt.exe -Es
equalsraf commented 6 years ago

echo "foo" | nvim-qt.exe -Es

All commands that expect to forward stdin/stdout (https://github.com/equalsraf/neovim-qt/issues/275) --version and --help are just the more significant cases.

I think we should forward them (see below), and skip nvim-qt.exe entirely. But --version and --help are special cases, nvim-qt might want to print its help/version info to stdout before passing control to nvim.exe.

This gets us very close to turning the startup sequence upside down (https://github.com/equalsraf/neovim-qt/issues/50) and have nvim control nvim-qt startup via some vimscript (https://github.com/equalsraf/neovim-gui-shim/pull/4).

iamkarlson commented 5 years ago

Hi guys, Seems it's not a really popular issue. I suppose that it just takes some time to realize that if you want to open a file in neovim you have to pass two double dashes.

❯ nvim-qt.exe settings.json # doesn't work
❯ nvim-qt.exe -- settings.json # doesn't work
❯ nvim-qt.exe -- -- settings.json # works oO

If that issue is discussed somewhere else could you point me there? Cuz it's really annoying.

equalsraf commented 5 years ago

Hi @iamkarlson

Let me be clear, all the examples that you listed above should work without issues. If they don't there is something wrong going on.

What system are you on and what version are you using? There was a regression in the past about this, if this is broken we can open new issues to fix it.

iamkarlson commented 5 years ago

@equalsraf thanks for such a swift reply! Here's versions:

❯ systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.17763 N/A Build 17763
❯ nvim --version
NVIM v0.3.1
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: C:/msys64/mingw64/bin/gcc.exe -Wconversion -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -D__USE_MINGW_ANSI_STDIO -D_WIN32_WINNT=0x0600 -Wvla -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -IC:/projects/neovim/build/config -IC:/projects/neovim/src -IC:/projects/neovim/.deps/usr/include -IC:/msys64/mingw64/include -IC:/projects/neovim/build/src/nvim/auto -IC:/projects/neovim/build/include
Compiled by appveyor@APPVYR-WIN

Features: -acl +iconv -jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Run :checkhealth for more info
❯ cup neovim -whatif
Chocolatey v0.10.11
_ Chocolatey:ChocolateyUpgradeCommand - Noop Mode _

You have neovim v0.3.1 installed. Version 0.3.4 is available based on your source(s).

Chocolatey can upgrade 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
justinmk commented 5 years ago

Please update to 0.3.4

iamkarlson commented 5 years ago

@justinmk hm, thanks, I didn't notice that. Looks like it fixed the issue. Thanks!

willt commented 4 years ago

Should running nvim-qt foo.txt work correctly now? I'm running neovim 0.5.0 on Ubuntu (Windows WSL) The only thing that works is nvim-qt -- -- foo.txt

nvim-qt foo.txt
ps -axfww | grep nvim
27131 tty1     S      0:00      \_ grep --color=auto nvim
27109 ?        Sl     0:00 /usr/bin/nvim-qt --nofork foo.txt
27111 ?        S      0:00  \_ nvim --cmd let &rtp.=',/usr/share/nvim-qt/runtime' --cmd set termguicolors foo.txt --embed --headless

nvim-qt -- -- foo.txt
ps -axfww | grep nvim
27156 tty1     S      0:00      \_ grep --color=auto nvim
27134 ?        Sl     0:00 /usr/bin/nvim-qt --nofork -- -- foo.txt
27136 ?        S      0:00  \_ nvim --cmd let &rtp.=',/usr/share/nvim-qt/runtime' --cmd set termguicolors --embed --headless -- foo.txt

nvim-qt -- foo.txt
ps -axfww | grep nvim
27181 tty1     S      0:00      \_ grep --color=auto nvim
27159 ?        Sl     0:00 /usr/bin/nvim-qt --nofork -- foo.txt
27161 ?        S      0:00  \_ nvim --cmd let &rtp.=',/usr/share/nvim-qt/runtime' --cmd set termguicolors foo.txt --embed --headless
jgehrig commented 4 years ago

Should running nvim-qt foo.txt work correctly now?

Yes.

Can you open a new issue to track your problem? It would also be helpful to provide additional information about your environment.

xileF1337 commented 2 years ago

Hi, I just stumbled across this issue as I was trying to use Neovim Qt to open files in multiple splits using the -o option of (Neo)vim. It took me a websearch to figure out that I have to use nvim-qt -- -o file1 file2 to do so. Are there any plans to change the current behaviour? Even if not, I really think the requirement to use -- should be made clear in the program help. Currently, the usage line looks like this:

Usage: nvim-qt [options] [file...] [-- ...]

Maybe it this could be clarified by changing it to something like:

Usage: nvim-qt [options] [file...] [-- neovim_options]

Below, the help currently states:

Arguments:
  file         Edit specified file(s)
  ...          Additional arguments are forwarded to Neovim

Here the second line could be changed to:

  -- ...       Additional arguments following a -- are forwarded 
               to Neovim

Any thoughts? I'm using nvim-qt v0.2.16.1 on Fedora 33, by the way.

equalsraf commented 2 years ago

A similar changed has been merged to master back in 65b5b117b36081544f9f01f06516a5ea977ae406 but it is not released.

My current help shows:

 nvim-qt --help
Usage: nvim-qt [options] [file...] [-- nvim_args]

Options:
  --nvim <nvim_path>           nvim executable path
  --timeout <ms>               Error if nvim does not responde after count
                               milliseconds
  --geometry <width>x<height>  Set initial window geometry
  --stylesheet <stylesheet>    Apply qss stylesheet from file
  --maximized                  Maximize the window on startup
  --fullscreen                 Open the window in fullscreen on startup
  --embed                      Communicate with Neovim over stdin/out
  --server <addr>              Connect to existing Neovim instance
  --spawn                      Treat positional arguments as the nvim argv
  -v, --version                Displays version information.
  -h, --help                   Displays help on commandline options.
  --help-all                   Displays help including Qt specific options.
  --nofork                     Run in foreground

Arguments:
  file                         Edit specified file(s)
  -- [nvim_args]               Additional arguments are forwarded to Neovim:
                               "nvim-qt -- -u NONE"
1ofseven commented 1 year ago

Is nvim-qt a separate program that starts and instance of nvim?

nvim-qt -o file1 file2 should open two buffers to edit two files. It seems that implementing convolutions like nvim-qt.exe file1 file2 -- -o will mess up command line invocations and existing piping and redirection. It also doesn't appear to conform with convention. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html Guideline 10: The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options. Any following arguments should be treated as operands, even if they begin with the '-' character.