Open amitkot opened 2 years ago
I need multiple instances too.
The procedure to run multiple instances is as follows:
neovide
Arg, I hate that macOS lacks of such feature in Spotlight
Still looking for a way to do that with an alternative of Spotlight 😅
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
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.
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.
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 windowwin
. 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
:split
<CTRL-W>e
i
and type something, Neovim now thinks that the invisible external window is focused, the cursor is not visible for exampleOf course these external windows are not full fledged Neovim instances, I'm not sure but I don't think they:
But I think you can:
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.
I agree with this. Depending on energy I may take a stab at implementing this especially soonish
What would be the steps to implement this?
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
for multiple instance management we also have Neohub available for macOS.
Use this release meanwhile.
Here's my current workaround with Hammerspoon:
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
.
@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
@samgj18 oh cool, that's better than my hard linked path solution
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)
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.
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!
@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.
@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.
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.