mhinz / neovim-remote

:ok_hand: Support for --remote and friends.
MIT License
1.73k stars 83 forks source link

doc: --listen on Windows #160

Open Acelya-9028 opened 3 years ago

Acelya-9028 commented 3 years ago

Hello, thank you for this very useful package.

I think it can be useful to add some help for Windows so I share this.

--listen want a named pipe and on Windows named pipe is on a special directory \\.\pipe\ so if you try --listen with $env:TEMP\<...>, it will not work, only \\.\pipe\<...>.

Exemple (type $profile on pwsh to get the path of your profile file):

$env:NVIM_LISTEN_ADDRESS = "\\.\pipe\nvim-nvr"
function nvr { &(Get-Command nvr -CommandType Application) -s --nostart $args; if ($LastExitCode -ne 0) { nvd; if ($args) { &(Get-Command nvr -CommandType Application) -s --nostart $args } } }
function nvd { neovide -S "$env:LocalAppData\nvim-data\current.session" --listen "$env:NVIM_LISTEN_ADDRESS" }

Next, just use nvr and everything is good.

PS: Replace neovide with nvim and remove the -S option if you don't need it ^^.

EDIT: Update the nvr function to fix the crash after a git commit if Neovim is not started.

Acelya-9028 commented 3 years ago

For use Git with nvr as editor on Powershell terminal, you have two solutions:

  1. git config --global core.editor "pwsh -Command nvr -cc split --remote-wait"

Works but a little slowly because pwsh must be loaded with its profile.

  1. git config --global core.editor "nvr.py -cc split --remote-wait"

Better because faster! But need a python3 executable in the path. If Python is installed with Chocolatey (choco install python), you haven't a python3 shims, so generate it with sudo $env:ProgramData\chocolatey\tools\shimgen.exe --output="$env:ChocolateyInstall\bin\python3.exe" --path="$($(Get-Command python).Source)"

PS: sudo on Windows: scoop install sudo scoop: https://github.com/lukesampson/scoop

PS2: If you are using neovide and airblade/vim-rooter, add let g:rooter_silent_chdir = 1 in your config file if you don't want the opening of the .git/COMMIT_EDITMSG file to be blocked by the directory change notification ^^.

LucasCorssac commented 2 years ago

Is it possible to change the python script itself to get the address from \\.\pipe\ instead of /tmp/nvimsocket ? As it stands, without any changes to the original script it works half the time, since it uses a fixed address that might not be available. Your changes do work, but they are sort of a workaround.

Acelya-9028 commented 2 years ago

Yes it is a workaround. I think you have to test it because I can't help you anymore, I gave up Windows to switch to Linux full time, even for video games ^^