neovide / neovide

No Nonsense Neovim Client in Rust
https://neovide.dev
MIT License
13.11k stars 534 forks source link

Open multiple instances / Windows #1332

Open amitkot opened 2 years ago

amitkot commented 2 years ago

Is your feature request related to a problem? Please describe. I cannot have more than one Neovide window running at the same time.

Describe the solution you'd like Allow running multiple instances of Neovide.

Additional context I use macOS.

yuhuihu commented 2 years ago

I need multiple instances too.

AndreyGladkov commented 2 years ago

The procedure to run multiple instances is as follows:

  1. Open the Terminal application
  2. Enter neovide
  3. Press Enter
JulienLecoq commented 1 year ago

Arg, I hate that macOS lacks of such feature in Spotlight

JulienLecoq commented 1 year ago

Still looking for a way to do that with an alternative of Spotlight 😅

tonogdlp commented 1 year ago

I use the Alfred App instead of Spotlight, a game changer in many ways... But for you, you can do the following prompt:

>neovide

It will run the command after the > .. in this case the neovide command

kipelovets commented 1 year ago

It's cool there's a workaround, but the experience is certainly lacking compared to MacVim for instance. MacVim's multiple windows can be cycled through with ⌘+` and closed with ⌘+w, while the whole application is closed with ⌘+q. On the other hand the new instances of Neovide are separate applications that pollute the ⌘+Tab list and have to be closed individually.

treeman commented 1 year ago

One use-case this would enable is with multiple monitors you could have a window with a compilation buffer or diagnostics on the secondary monitor while having the main monitor full of code. This would enable you to compile from within neovim, instead of having to jump to a separate terminal, and would keep the diagnostics list.

This is in my view the big differentiator between neovim in a gui vs neovim in a terminal.

fredizzimo commented 1 year ago

Neovim actually do support multiple windows that would be completely compatible with Neovide

https://neovim.io/doc/user/api.html#nvim_open_win()

external: GUI should display the window as an external top-level window. Currently accepts no other positioning configuration together with this.

There's also a built-in keymapping for it https://neovim.io/doc/user/windows.html#CTRL-W_ge

We then receive the following UI event

["win_external_pos", grid, win]
Display or reconfigure external window win. The window should be displayed as a separate top-level window in the desktop environment, or something similar.

I think it's actually a bug to not implement it, it's part of the standard protocol without any extensions. And if you do

  1. :split
  2. <CTRL-W>e
  3. i and type something, Neovim now thinks that the invisible external window is focused, the cursor is not visible for example

Of course these external windows are not full fledged Neovim instances, I'm not sure but I don't think they:

  1. Have a cmd line
  2. Can be split futher
  3. You can open floating windows anchored to them (but this one I'm not sure about at all)

But I think you can:

  1. Have a winbar
  2. Switch buffers
  3. Resize them completely independently from the main window

So at least for people with multiple monitors, it could be useful. And as mentioned we are actually required to implement it according to the specs, so re-opening this.

That said, it's not a small task to implement it, but I don't see any huge obstacles either.

Kethku commented 1 year ago

I agree with this. Depending on energy I may take a stab at implementing this especially soonish

bqv commented 12 months ago

What would be the steps to implement this?

kentslaney commented 8 months ago

In case the executable didn't end up in your $PATH (which was the case for me), it's located at /Applications/neovide.app/Contents/MacOS/neovide

It looks like the init.lua workaround from here didn't make it onto this thread, but the stand-alone translation looks like

if vim.g.neovide and vim.fn.has('macunix') then
    vim.keymap.set("n", "<D-n>", ":silent exec '!/Applications/neovide.app/Contents/MacOS/neovide'<cr>")
end
falcucci commented 8 months ago

for multiple instance management we also have Neohub available for macOS.

Use this release meanwhile.

https://github.com/falcucci/NeoHub/releases/tag/v0.0.2

iwinux commented 7 months ago

Here's my current workaround with Hammerspoon:

image
function cycleNeovideWindows()
  local current = hs.window.focusedWindow()

  local items = hs.fnutils.imap({hs.application.find('com.neovide.neovide')}, function(app)
    local title = app:title()
    local status
    local win = app:mainWindow()

    if win ~= nil then
      title = win:title()
    end

    if win == current then
      status = '[CURRENT]'
    end

    return {
      text = title,
      subText = status,
      pid = app:pid(),
    }
  end)

  local callback = function(result)
    hs.application.applicationForPID(result.pid):activate()
  end

  hs.chooser.new(callback):choices(items):show()
end

hs.hotkey.bind({'cmd', 'ctrl'}, '`', cycleNeovideWindows)

Press Command + Ctrl + ~ to choose Neovide instances. NOTE: Neovide instances need to be launched with open --new -b com.neovide.neovide, otherwise they can't be looked up with bundle ID com.neovide.neovide.

sagoez commented 7 months ago

@iwinux I did use your script. However, I found particularly useful to modify the command as follows:

'open --new -b com.neovide.neovide --args ${PWD}'

This is similar to do ".", which I use pretty often. Notice it must be single quoted to enable variable expansion, see reference

kentslaney commented 7 months ago

@samgj18 oh cool, that's better than my hard linked path solution

preland commented 6 months ago

Ok, so weird question: Is this already implemented somehow?

Context: A couple of days ago I was messing around with keybinds, and accidentally moved one of my tabs into a new window. I don't know how I did it, and I can't remember how I did it.

(Platform: Hyprland (Arch Linux), NvChad config)

davibe commented 5 months ago

Vimr does this right. It opens multiple windows and each windows title matches the titlestring also on macos. Unfortunately it's not as stable as neovide is in my case, it often crashes.

bassamsdata commented 3 weeks ago

I’ve been running intothe issue with the Aerospace tiling window manager where Neovide doesn’t get recognized if it’s opened from the terminal, appearing without a bundle ID in the aerospace list-apps output:

8668 | NULL-APP-BUNDLE-ID | neovide

Launching Neovide with the command below works:

open --new -b com.neovide.neovide --args ${PWD}

However, this defaults to the home directory as the working directory, which is why I prefer opening it from the terminal in the first place.

If anyone has suggestions for a workaround, I’d be grateful!

ChristinWhite commented 3 weeks ago

@bassamsdata I ran into that too, what worked for me was to use if.window-title-regex-substring rather than if.app-id, just make sure there's something like Neovide in your vim.opt.titlestring if there isn't by default and that it doesn't get truncated.

bassamsdata commented 3 weeks ago

@ChristinWhite Thank you for the info and solution.

I did that earlier, and it worked with this configuration:

[[on-window-detected]]
if.window-title-regex-substring = 'neovide'
run = ['layout tiling', "move-node-to-workspace 3_neovide"]  

However, I encountered an issue where Neovide wouldn't focus after moving to the workspace. Even with focus commands like focus left or focus right, the mouse would center on Neovide, but the app itself wouldn’t get focused. I'm not sure if you've had a similar experience.

alt-n = 'workspace 3_neovide'
alt-h = 'focus left'
alt-k = 'focus up'

To resolve this, I followed a suggestion from this comment and created a wrapper file named neovide-wrapper. I placed this file inside /Applications/Neovide.app/Contents/MacOS and updated the CFBundleExecutable in /Applications/Neovide.app/Contents/info.plist to point to the wrapper instead. Here's the wrapper:

#!/bin/bash
# Get the current working directory
CWD="$PWD"

# Get the path to the actual neovide binary in the same directory as this wrapper
NEOVIDE_PATH="$(dirname "$0")/neovide"

# Change to the directory where the command was invoked
cd "$CWD"

# Execute neovide with any passed arguments
"$NEOVIDE_PATH" "$@" &
disown

It’s a bit of a workaround, but it solved all my issues. Now, Neovide is fully recognized by Aerospace and actually recognized the working directory where the command was invoked.