qvacua / vimr

VimR — Neovim GUI for macOS in Swift
https://twitter.com/VimRefined
MIT License
6.68k stars 219 forks source link

[FEAT] Provide a GUI or file to configure environment-variables for the spawned neovim process #865

Open ELLIOTTCABLE opened 3 years ago

ELLIOTTCABLE commented 3 years ago

In particular, I don't launch VimR from an existing terminal, so vimr --cur-env is useless to me — I'm a "terminal inside VimR", not "VimR from a terminal" kinda user!

I'd like to use nvr, from neovim-remote, as my $GIT_EDITOR and the like. I've configured my $NVIM_LISTEN_ADDRESS to /tmp/nvimsocket using shell configuration files; and that works fine, of course … if I launch VimR from a terminal:

  1. Open a macOS Terminal.app
  2. Use vimr --cur-env, so VimR's neovim inherits the shell $NVIM_LISTEN_ADDRESS
  3. Open another :terminal inside VimR itself
  4. Proceed normally with Git operations and suchlike, with nvr instructing VimR to open windows/buffers/etc as appropriate.
  5. nvr talks to VimR's embedded Neovim over /tmp/nvimsocket; all works fine!

However, in a more normal form of usage,

  1. Open VimR from the Finder
  2. Open :terminal inside VimR itself
  3. Proceed normally with Git operations and suchlike, with nvr instructing VimR to open windows/buffers/etc as appropriate.
  4. nvr tries to communicate to /tmp/nvimsocket; but VimR's neovim is listening on something random like:
    /var/folders/qx/mxf_tg093sn9xzthq9p9trfm0000gn/T/vimr_9F9C9D7A-71EA-4414-94DB-D8677C1C6E06.sock

    ... so nothing happens.

This is, however, just a specific case of the "we don't have control over the integrated neovim instance" issue. I really do think that the ideal solution to this is to simple make it configurable.

This isn't the first time this sort of issue has cropped up; and plenty of other GUI editors that invoke tools and similar offer options like this. I really hope you'll consider such a feature worth your time!

Andilutten commented 3 years ago

If you just need it inside the embedded neovim terminal, maybe you could try to set the correct servername in your configuration ?

let $NVIM_LISTEN_ADDRESS=v:servername
ELLIOTTCABLE commented 3 years ago

Unfortunately, that's the inverse — I need to configure the embedded neovim itself, not the terminal.

Edit: Oh, I mis-understood you — you mean configuring the embedded terminal, so launched-inside-VimR applications work as expected.

That's actually a really helpful tip, although it doesn't solve the underlying problem — with that solution, for instance, if I open a external Terminal.app window after launching VimR from the GUI, it won't be able to control my VimR instance.

For anybody else coming across this, the actual line @Andilutten suggested ended up being unnecessary — I'd hardcoded the envvar in my .profile, and thus it was getting overwritten on :terminal-start; all I had to do to at least get nvr instances inside VimR to start working was the following:

+|if [ -z "$NVIM_LISTEN_ADDRESS" ]; then
 |   export NVIM_LISTEN_ADDRESS="/tmp/nvimsocket"
+|fi
smackesey commented 2 years ago

I asked for something similar (to configure the socket) here: https://github.com/qvacua/vimr/issues/797

Sandybunting commented 2 years ago

This would be excellent, as currently with certain neovim configs, you need to set env variables for core functionality. E.g. I'm attempting to run Python code for the minted LaTeX package in SpaceVim, but SpaceVim requires an environment variable to be set to have Python functionality.