Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: CLI option to open new files in the existing instance of Neovide instead of creating a new one #1586

Open
chrisgrieser opened this issue Oct 4, 2022 · 14 comments
Labels
enhancement New feature or request

Comments

@chrisgrieser
Copy link

chrisgrieser commented Oct 4, 2022

Is your feature request related to a problem? Please describe.
When Neovide is already open, and I use neovide (the CLI) to open another file, another instance of Neovide is opened instead of opening neovide in a new buffer in the already existing instance.

This is very impractical, since I often accidentally end up with several neovide instances, which cannot be dealt with properly via the OS (all have the same icon and same app name for app switchers), and also I cannot switch between them with things like :buffer.

Describe the solution you'd like
a CLI option to open new files in the existing instance of Neovide instead of creating a new one

Describe alternatives you've considered
Only opening the first file via neovide and all other files from inside neovide? That is quite cumbersome to do though.

As @bboles outlined in a different issue, if the Neovide.app would use the "open with" feature on mac properly, one could open files with the app and it would open in the same instance. If that is going to be implemented, open -a "Neovide" {filename} could be a workaround for this.

@chrisgrieser chrisgrieser added the enhancement New feature or request label Oct 4, 2022
@avalonv
Copy link

avalonv commented Oct 5, 2022

Breaking the current standard and messing up people's workflows is the easiest way to saturate this issues page with an angry mob. Instead of changing the default it would be better to expose an argument which does that, but otherwise I agree this would be a cool feature.

@tstm
Copy link

tstm commented Oct 13, 2022

As it is, Neovide does not seem to be able to run multiple windows in one instance, so doing this would definitely break expected behaviour?

@chrisgrieser
Copy link
Author

chrisgrieser commented Oct 14, 2022

Breaking the current standard and messing up people's workflows is the easiest way to saturate this issues page with an angry mob. Instead of changing the default it would be better to expose an argument which does that, but otherwise I agree this would be a cool feature.

Yes, an option was what I meant. Edited for clarity.

@chrisgrieser chrisgrieser changed the title FR: the CLI should open new files in the existing instance of Neovide instead of creating a new one FR: CLI option to open new files in the existing instance of Neovide instead of creating a new one Oct 14, 2022
@kemiller
Copy link

+1 To this. I'd be OK with a special CLI command for this, a la VSCode or VimR, or a flag. I'd expect it to open a new buffer, not a new macOS window.

@shemerey
Copy link

shemerey commented Feb 8, 2023

yep, would be grate feature to have.

Solution in this case can be pretty trivial, since neovide relay on a nvim server any way we just need to define static listener and then send --remote command to it. In my case implementation was next. I've created script in /usr/local/bin/v and use my own socket.

#!/bin/sh

NVIM_SOCKET=/tmp/neovide.socket
if [ ! -S $NVIM_SOCKET ]; then
    neovide --noidle  -- --listen $NVIM_SOCKET $@
else
    nvim --server $NVIM_SOCKET --remote $@
fi

@9mm
Copy link
Contributor

9mm commented Aug 13, 2023

+1 To this. I'd be OK with a special CLI command for this, a la VSCode or VimR, or a flag. I'd expect it to open a new buffer, not a new macOS window.

I strongly disagree with this. If you want a new buffer you should just open a new buffer in the current window.

I actually need an entirely different window so it can go on other monitors, or so I can move projects around independently, but they should spawn out of the same icon so you dont get this:

image

I think the flag should enable functionality exactly like all the other Vim GUI's like MacVim, VimR, etc, where it opens in a new window spawned under the same icon.

@9mm
Copy link
Contributor

9mm commented Aug 13, 2023

As a sidenote, I just HAD to do this;

➜  ~ n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n; n; n; n; n;n;n;

When they open, they create a literal wave 🌊

image

@mambusskruj
Copy link

mambusskruj commented Sep 5, 2023

I think it would be nice to have an option that makes it possible to reuse (open) the existing neovide window if you call neovide to open in the CWD that already was opened inside other neovide window.

This feature makes it possible to comfortably use Neovide as part of Tmux workflow with sessions and its windows. So you open Neovide window in CWD that you want and continue to use terminal session. Then switch to the existing Neovide window easily calling Neovide again.

For example, for me missing this kind of feature is a dealbreaker to use Neovide regularly.

@idelice
Copy link

idelice commented Feb 18, 2024

I think it would be nice to have an option that makes it possible to reuse (open) the existing neovide window if you call neovide to open in the CWD that already was opened inside other neovide window.

This feature makes it possible to comfortably use Neovide as part of Tmux workflow with sessions and its windows. So you open Neovide window in CWD that you want and continue to use terminal session. Then switch to the existing Neovide window easily calling Neovide again.

For example, for me missing this kind of feature is a dealbreaker to use Neovide regularly.

Agree

@chrisgrieser
Copy link
Author

Due to the PR #2395, the Neovide.app now can open files correctly, so open -a "Neovide" {filename} will avoid opening multiple windows. This solves the issue at least on macOS.

@chrisgrieser
Copy link
Author

chrisgrieser commented May 17, 2024

@fredizzimo sorry to bother you, but I do not think this issue is fully resolved. Just one case (opening via open on macOS) is solved, opening via neovide (the CLI) still spawns new windows.

Other than not working on systems other than macOS, opening via neovide is still relevant for various use cases (tmux described here, to open at a specific line via rg, …)

@fredizzimo
Copy link
Member

fredizzimo commented May 18, 2024

Yes, re-opening this, I thought we had another cross-platform issue for it, since it's the same on all other platforms, we don't have a built-in way of re-using the same Neovide instance. We had this #1293, but it was closed in favour of this one.

With a few shell commands it's easy to support though:

  1. Start the server
    nvim --listen localhost:9034&
  2. Start Neovide and connect
    neovide --server localhost:9034
  3. Edit a file
    nvim --server localhost:9034 --remote-tab $PWD/file.txt
    or
    nvim --server localhost:9034 --remote-edit $PWD/file.txt

You can replace the port 9034, by any free TCP port on your system, I just selected a number randomly. If you want multiple instances you can use multiple ports

Note, you need to full path to the file, if you started the instance in another folder, that's why I added $PWD

If you use it much, then a shell alias could be created
alias neovide-open='nvim --server localhost:9034 --remote-tab' and used like this neovide-open $PWD/file.txt`. But in practice you probably want something a bit smarter than that, that automatically converts relative paths to absolute, and supports multiple arguments. I leave that as an exercise for the reader.

@fredizzimo fredizzimo reopened this May 18, 2024
@chrisgrieser
Copy link
Author

Yeah, I am using sth similar to that as a workaround currently, though it is quite cumbersome.

It's also not very beginner friendly for people starting out with nvim.

@lparry
Copy link

lparry commented Jul 2, 2024

I've tried both

alias nvim='open -a "Neovide"'

and I've tried

function nvim() {
  local nvim_socket
  nvim_socket=/tmp/neovide.socket

  if [ ! -S $nvim_socket ]; then
    nvim --server $nvim_socket --remote-edit $PWD/file.txt
  else
    nvim --headless --listen $nvim_socket &
    neovide --server $nvim_socket
  fi
}

but both those options seem to have significantly worse performance for me than just running

neovide $filename

Scrolling is buttery smooth via neovide but regularly chokes and stutters using either of the other options when navigating a huge ruby file (full of lines longer than lines have any right to be).

Would anyone have any suggestions why that might be, or what else I might try to get the normal neovide performance, while being able to add new buffers to the same instance from the cli?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants