Lyude / neovim-gtk

gtk ui for neovim
GNU General Public License v3.0
161 stars 10 forks source link

Pass nvim-bin-path to the shell #16

Open bk2204 opened 2 years ago

bk2204 commented 2 years ago

Right now, the --nvim-bin-path argument takes only the name of a binary. This is fine for local environments, but if one wants to run a Neovim instance on a remote system over SSH, this becomes difficult.

Git and other tools handle this by passing their arguments to the shell. This is specifically required for environment variables like EDITOR and VISUAL, so there's plenty of precedent for this.

Passing the argument to the shell would allow someone to do nvim-gtk --nvim-bin-path 'ssh SERVER nvim' and edit files on the remote system. This is generally useful both for general SSH uses and GitHub's Codespaces feature.

jacobmischka commented 2 years ago

Unfortunately I think we need more than just passing along the command, unless I'm missing something obvious. I admit I don't fully understand what you mean above by "pass to the shell", I took it to mean just essentially splitting the argument by whitespace and passing along the arguments, am I misunderstanding something?

When I hack that in just to see if it works, I can't seem to get nvim-gtk to accept the remote nvim (I also commented out the rtp assignment, though I don't think that's relevant here, it looks like that file just adds GUI helper commands).

It always fails with:

$ cargo run --release -- --nvim-bin-path 'ssh $SERVER -tt nvim' --no-fork
    Finished release [optimized] target(s) in 0.03s
     Running `target/release/nvim-gtk --nvim-bin-path 'ssh $SERVER -tt nvim' --no-fork`
[2022-02-21T16:32:35Z ERROR nvim_gtk::shell] Error reading message
[2022-02-21T16:32:35Z ERROR nvim_gtk::error] Can't initialize nvim: DecodeError(InvalidMessage(UnknownMessageType(94)), "nvim_set_client_info")

(NeovimGtk:1209716): Gtk-WARNING **: 10:32:35.079: Child name 'Error' not found in GtkStack

It usually swallows the stack trace for some reason, but I was able to finally get one once by hitting buttons, apparently causing the nvim_input event to happen before the usual nvim_set_client_info:

$ RUST_BACKTRACE=1 cargo run -- --nvim-bin-path 'ssh $SERVER -tt nvim' --no-fork
   Compiling nvim-gtk v0.4.1 (/home/mischka/projects/neovim-gtk)
    Finished dev [unoptimized + debuginfo] target(s) in 5.62s
     Running `target/debug/nvim-gtk --nvim-bin-path 'ssh $SERVER -tt nvim' --no-fork`
[2022-02-21T16:45:20Z ERROR nvim_gtk::shell] Error reading message
[2022-02-21T16:45:20Z ERROR nvim_gtk::nvim::ext] Error in last Neovim request: Error decoding response to request 'nvim_input'
[2022-02-21T16:45:20Z ERROR nvim_gtk::nvim::ext] Caused by: Some(InvalidMessage(UnknownMessageType(94)))
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CallError(DecodeError(InvalidMessage(UnknownMessageType(94)), "nvim_input"))', src/nvim/ext.rs:51:19
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1299:23
   4: <core::result::Result<T,nvim_gtk::nvim::SessionError> as nvim_gtk::nvim::ext::ErrorReport<T>>::ok_and_report
             at ./src/nvim/ext.rs:51:14
   5: nvim_gtk::input::im_input
             at ./src/input.rs:91:5
   6: nvim_gtk::shell::State::im_commit
             at ./src/shell.rs:537:13
   7: nvim_gtk::shell::Shell::init::{{closure}}
             at ./src/shell.rs:1044:42
   8: <O as gtk::auto::im_context::IMContextExt>::connect_commit::commit_trampoline
             at /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.15.3/src/auto/im_context.rs:244:13
   9: g_cclosure_marshal_VOID__STRINGv
  10: g_signal_emit_valist
  11: g_signal_emit_by_name
  12: g_cclosure_marshal_VOID__STRINGv
  13: g_signal_emit_valist
  14: g_signal_emit
  15: <unknown>
  16: <O as gtk::auto::im_context::IMContextExt>::filter_keypress
             at /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.15.3/src/auto/im_context.rs:123:23
  17: nvim_gtk::shell::Shell::init::{{closure}}
             at ./src/shell.rs:989:16
  18: <O as gtk::auto::widget::WidgetExt>::connect_key_press_event::key_press_event_trampoline
             at /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.15.3/src/auto/widget.rs:4101:13
  19: <unknown>
  20: g_closure_invoke
  21: <unknown>
  22: g_signal_emit_valist
  23: g_signal_emit
  24: <unknown>
  25: gtk_window_propagate_key_event
  26: <unknown>
  27: <unknown>
  28: g_signal_emit_valist
  29: g_signal_emit
  30: <unknown>
  31: <unknown>
  32: gtk_main_do_event
  33: <unknown>
  34: <unknown>
  35: g_main_context_dispatch
  36: <unknown>
  37: g_main_context_iteration
  38: g_application_run
  39: <O as gio::application::ApplicationExtManual>::run_with_args
             at /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.15.4/src/application.rs:30:13
  40: <O as gio::application::ApplicationExtManual>::run
             at /home/mischka/.cargo/registry/src/github.com-1ecc6299db9ec823/gio-0.15.4/src/application.rs:23:9
  41: nvim_gtk::main
             at ./src/main.rs:181:5
  42: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.