lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

[Bug] `nvim-remote` not working on Windows 11

Open pidgeon777 opened this issue 10 months ago • 5 comments

Describe the bug When opening Lazygit inside Neovim and trying to edit a file with e, Lazygit hangs.

To Reproduce Steps to reproduce the behavior:

  1. Start Lazygit in Neovim.
  2. Select a file in the Lazygit files list.
  3. Press e.

As a result, the Lazygit terminal will hang.

Expected behavior

After running the e command, I would expect Lazygit to close and Neovim to open a new tab with the corresponding file to be edited.

Version info: lazygit --version:

commit=3675570a391b1a49ddd198b4c7e71e17701d4404, build date=2024-03-23T09:09:11Z, build source=binaryRelease, version=0.41.0, os=windows, arch=amd64, git version=2.44.0.windows.1

git --version:

git version 2.44.0.windows.1

Additional context The problem could be related to this code:

https://github.com/jesseduffield/lazygit/blob/master/pkg/config/editor_presets.go#L54-L61

It seems a command to be run in a Linux environment.

So, I suppose there would have to be a Windows equivalent command. Also, how and where should the NVIM variable be set?

pidgeon777 avatar Apr 01 '24 12:04 pidgeon777

Also, how and where should the NVIM variable be set?

NVIM env var is set when Lazygit is run inside a terminal created within neovim: https://github.com/neovim/neovim/blob/4459e0cee8b6d043ab2b06cbd89545c45a76a612/runtime/doc/nvim_terminal_emulator.txt#L43 As the above line in the documentation describes, the terminal emulator used by neovim uses the same environment setup as neovim jobs (where NVIM is set): https://github.com/neovim/neovim/blob/4459e0cee8b6d043ab2b06cbd89545c45a76a612/runtime/doc/builtin.txt#L3866

rpkwv8 avatar Apr 11 '24 19:04 rpkwv8

I've encountered a similar issue with an error message direcly printed as I attempt to use "e". (Windows 11):

'[' is not recognized as an internal or external command, operable program or batch file.

Only with nvim-remote as an editPreset

avario-cpu avatar Aug 28 '24 14:08 avario-cpu

For work I am forced to use windows and I noticed this as well. Lazygit uses CMD on windows and the preset uses bash syntax so that won't work. I tried to set the editTemplate manually in the config using CMD syntax but this won't work either because you have to use CMD syntax to check if the NVIM variable exists (with if not defined %NVIM% ....) but this won't work either because the percent signs are getting quoted by lazygit. I am not super familiar with the lazygit codebase but if none of the maintainers know a quick solution for this I am willing to try to work around this if this is something you want.

RZMNR avatar Sep 25 '24 17:09 RZMNR

In the lazygit configuration, you can override the commands that the preset sets. That should give you the ability to set commands that work on your system.

I don't know much about environment variables and how they work on Windows these days. If you're stuck and willing to try an alternative, I currently work on osx and use

  • these lazygit settings
  • I load a plugin called https://github.com/willothy/flatten.nvim which allows neovim to pretty much do the same thing as nvim-remote
    • https://github.com/mikavilpas/dotfiles/blob/ccd520277eb60212da0936eec7bab81317b83362/.config/nvim/lua/plugins/terminal-integration.lua?plain=1#L3

https://github.com/user-attachments/assets/8ee9c1af-4a0f-4aab-9782-f95f4ffc72c0

mikavilpas avatar Sep 25 '24 17:09 mikavilpas

Thanks, I didn't know that plugin. I will try that out!

RZMNR avatar Sep 25 '24 18:09 RZMNR