-
Notifications
You must be signed in to change notification settings - Fork 501
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
Change the defaults for fork/no-fork #2147
Comments
I actually think we should remove the There are already standard ways of running it in the background without forking like Forking can also interfere with things like git merge tools, and while we don't pipe the stdin properly to Neovim currently, it becomes possible to implement if we don't fork. On Windows the situation is more tricky, since there are no hybrid gui/console applications, but I think the current behaviour is good on that, it does not fork, but still allows the inputs and outputs to be redirected. That said, if we want to keep the forking behaviour for just the terminal it would be easy by using this https://doc.rust-lang.org/std/io/trait.IsTerminal.html Finally, I did have the impression that forking was actually necessary on macOS in all cases based on the PR that added it, #411
But actual issue, gives a different impression #402, so it's probably not necessary when launching from the dock. Also people there seem to agree that forking should be the default (including @Kethku), which is different from my opinion here, so more discussion is needed. |
FYI, yet another way to get the effect of forking when starting Neovide from the terminal is to use the I can't think of a good reason why it would be necessary for Neovide to ever do the forking itself. To my knowledge, no other Mac apps do this. It would be totally fine with me if the forking behavior were removed altogether. But that said, I don't have any objection to it being there for the benefit of those who want it, as long as it's not the default, or can be disabled in the config file. Your idea of basing the choice on whether we're attached to a terminal is kind of the inverse of my idea of detecting whether we're launched from the Dock. I could live with this too. |
Your advice is reasonable. I will be happier too if neovide plays better with Dock on macos. It's not a simple problem. Different platforms have different situations. Even on the same platform there are different situations. It would be the best if we can handle every situation "correctly". But it's a long way. Like, it is very tricky that we detect whether launchd or other programs starts neovide. At last, VSCode forks by default. And I vote for NO fork!😂 |
The absolute vast majority of linux gui applications do not fork by default. Most of them don't even have an option for it. I think having the option is nice, but I agree that it shouldn't be the default. |
Def subbing to this as 99% of the time i launch neovide from terminal from the current project im working in. When I click the icon in the dock though its really wild What I can say is that MacVim does it perfectly as far as mac experience
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
(OP here.) So #2189 claims to provide a "temporary solution" to this, but I don't see how. Forking is still the default, but now it can be controlled with an environment variable. There was a time when this would have been a good solution, but those days are gone. It's no longer possible to do I don't know of a way to set an environment variable for processes launched from the Dock. This needs to be a setting controlled from the config file, or else the default needs to change to not fork. If I'm missing something, please enlighten me! |
@valleydali i simply put this in I believe the proper way is to use launchctl to set it permanently, but i chose to do it this way so it fits in my .dotfiles repo
|
Ah! So, without I did not know that, thanks! |
MacVim (when run as One of the reasons that I end trying and never using emacs on macOS is it does not fork. I explicitly use a GUI version of vim because I want to be able to edit without blocking my terminal (I rarely use a vim terminal), especially since I typically open MacVim from the terminal and have it open in the previous window position on a different screen (rotated 90º, so tall). I may be in the minority on this, but I would immediately uninstall Neovide if I have to switch from |
Now that I take a closer look, I can also see a very brief stutter when launching Neovide from the Dock. I have also had duplicate icons appear, but only occasionally, rather than half the time. Disabling forking (i.e. with However the reason I found this issue is because I've discovered another bug caused by immediately forking. For the last couple months, my Neovide window has always been opening unfocused and behind all other windows. At first I thought it was just some weird saved window position or something, so I ignored it, but it kept happening, even after a reboot. I only now had the idea to see if disabling forking would make a difference, and it indeed fixes the issue. As for an actual fix, I think the best solution would be to keep forking when connected to a terminal, and stop forking everywhere else. Never forking would also be fine imo, as long as the @valleydali I use custom LaunchAgents to run commands (e.g. So as a temporary fix for this issue, I have the following saved as <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.NEOVIDE_FORK</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>setenv</string>
<string>NEOVIDE_FORK</string>
<string>0</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist> |
I don't agree with that, in most cases when I launch Neovide from the terminal, it's because I want to edit a single file and then resume with my terminal work. If I want to keep neovide open for longer, I don't want a terminal window, so I don't open it from the terminal. Also, standard things like All of those are things terminal users are expecting to work. |
That's fair, I hadn't really thought about wanting to edit single files with Neovide. I just use
I don't think it's necessarily an expectation that it should just work with no arguments, especially for GUI programs. As an example, upstream Vim itself forks by default when you run So yeah I don't really mind whether Neovide forks or not when in a terminal - I don't really ever launch it from a terminal. All I want is for it to stop forking when launched from the Dock on macOS, to fix the stuttering, duplicate icon and launching in the background issues. |
I generally start working with a specific file or a subset of files: $ gvim (fd server src) # or
$ gvim lib/application.ex I then use a fuzzy file picker to jump between files as I tend to work that. But I never launch MacVim from the dock or
Some terminal users, but I suspect not people who actually want neovide to be a good citizen on macOS. Blocking the console by default is the exact opposite of being a good citizen on macOS.
|
I've done some digging, and I think I now understand why GUI apps on macOS appear to "not block" the terminal when you use them. To use BBEdit as an example: if you run But this isn't what you'd be doing to edit files using BBEdit from the terminal, you'd use the So there isn't actually any difference between macOS and Linux when it comes to whether GUI apps fork or not - neither of them do. It's just on macOS, the expectation is that the app will ship with some kind of command line helper script that launches the actual app in the background, forwards arguments to it, and then either exits immediately or waits for the app to finish/quit. Problem is, for Neovide, the binary that is launched when you run the |
That sounds like it's something that should be handled by the homebrew cask and not by the application itself. |
…
However, forking is exactly what MacVim does. The # GUI mode, implies forking
case "$name" in m*|g*|rm*|rg*) gui=true ;; esac At line 61, that # Last step: fire up vim.
# The program should fork by default when started in GUI mode, but it does
# not; we work around this when this script is invoked as "gvim" or "rgview"
# etc., but not when it is invoked as "vim -g".
if [ "$gui" ]; then
# Note: this isn't perfect, because any error output goes to the
# terminal instead of the console log.
# But if you use open instead, you will need to fully qualify the
# path names for any filenames you specify, which is hard.
exec "$binary" -g $opts ${1:+"$@"}
else
exec "$binary" $opts ${1:+"$@"}
fi It may be that @fredizzimo: Homebrew can deliver packages that are built. Neovide builds a proper macOS I suspect that the flickering and duplicate dock issue reported initially has much more to do with Neovide having little proper macOS support‡ and nothing to do with the forking as originally reported. If I launch Neovide multiple times, I get multiple application icons in my application switcher (I have my dock hidden, but they are duplicated there, too). If I launch MacVim multiple times, it stays under one application icon and Some of these things, I could probably help with (generally the stuff that any idiot could do, like making sure that the system configuration loaded when Neovide launches includes macOS bindings), but other things…I cannot help with as I am not nor have never been a macOS application developer. ‡ Not slagging any of the developers. What works here is amazing, and it's more than I have knowledge to deal with. But as of right now, Neovide is the best neovim GUI…and worse than VS Code and the various Emacs GUIs when it comes to acting like a proper macOS citizen as a GUI editor. I personally find it nearly unusable:
|
It's been quite awhile since I looked at this, but I'm 99% certain the duplicate dock issue is related to forking or not. I had to do some hacks basically to get it to work, but in
I know it can go inside the bundle, and also it can get set directly on startup, but I put them here so it's in my dotfiles and I dont forget This 100% fixes the issue with launching the app from the dock. I forgot how I had it, but I believe I made an automator script wrapper. Currently I dont even use the dock version because the ONLY thing I use the dock icon for (rather than launching from terminal) is when I have to deal with dozens of CSV's, and I want to drag them into the icon as its just easier when working with tons of files. Unfortunately dragging into the icon was another issue i looked at but it involves workign with multiple runtime loops which I just dont know. So for now, i dont even have a neovide dock icon, i just use macvim for that case. Its really painful, and i really wished that worked. But, I do remember testing all this, and I remember it fixed the problem. I then had a separate launcher script so I can just type
But you can see i just override forking there This 100% removes the dock issues and bouncing, but it DOES open multiple instances of the app. I actually hated this at first, but have come to like it way way more, as its easier to maintain multiple "sessions". Im sure thats not the correct OSX behavior, which would try to put them as multiple windows, but still. Either way, I agree Neovide doesn't behave like a normal mac app, I think the problem is that not many developers working on Neovide use OSX. I use it and can test things, but I don't do OS dev/rust so it makes it hard to contribute except for simple things. |
I've never used MacVim, so I've just installed the MacVim cask to try it out. If you run If you run the
Well at least for me, disabling forking of the As for the multiple application icons issue, this is basically #1586, and is also related to what is to me the biggest usability issue on macOS - you can't open multiple Neovide windows without going through the terminal (with either
All three of these options are quite complicated though. 3 would apply to all platforms, so in that way it's sort of the "cleanest", but it would certainly be the most difficult to implement. 1 and 2 would be macOS-specific, and require less work, but would mean multiple binaries. For my issue, all I'd need is a vim.api.nvim_create_user_command("NeovideNewWindow", function()
vim.system({ "open", "-na", "Neovide" })
end, {}) which works for my setup, but it won't work if you don't have Neovide.app installed.
Neovide is currently a rather barebones GUI in terms of system integration, on all platforms - and that isn't necessarily a bad thing. It just simply forwards all keypresses to Neovim, which I think is perfectly reasonable. And I don't think it needs to inject its own keybindings, on any platform - the user can configure those themselves, which they should be comfortable with, since they're using Neovim. A recommended/helpful keybindings page in the wiki would be nice though.
I've had vim.keymap.set("v", "<D-c>", '"+y')
vim.keymap.set({ "n", "v" }, "<D-v>", '"+P')
vim.keymap.set({ "c", "i" }, "<D-v>", "<C-R>+")
vim.keymap.set("n", "<D-s>", "<Cmd>update<CR>") in my config file for ages, and I don't remember them ever not working. I also just added vim.g.neovide_scale_factor = 1.0
local change_scale_factor = function(delta)
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta
end
vim.keymap.set("n", "<D-+>", function()
change_scale_factor(1.25)
end)
vim.keymap.set("n", "<D-->", function()
change_scale_factor(1/1.25)
end) to test, and they also seems to work fine at least for me. I think there's probably something else going on that's causing your bindings to not work. I'm in a similar position to @9mm - I'd love to contribute fixes for this kind of issue, but I know basically nothing about OS development and I'm still (slowly) trying to learn Rust so I can only really help with testing.
I can entirely understand this. The way the Dock groups all windows of an app behind a right-click is for me one of the most annoying parts of using a mac. I really wish there was an option to either show all windows on hover (i.e. like Windows) or just show a separate icon for each. AltTab really is the single thing keeping me from going insane when I have to constantly switch between multiple windows. |
@AThePeanut4 I always used Hyperdock for the longest time: Sadly I think it stopped working some time ago but I don't remember. You might try installing it and see if it works. I have also heard of alternatives if it doesnt work: https://www.macenhance.com/dockmate.html Basically instead of alt tab, the thing that keeps me sane is 3 finger swipe UP on trackpad. I actually find this is much faster than hyperdock even which is why I dont use it much anymore. This trick wouldnt work though if you are not working on a laptop, but I find this is actually supreme as I can even have a dozen windows open and quickly find the one i want |
I'm not a Mac user, so I might be wrong but to add to the above, The dmg we provide is a Gui app, If you launch neovide.app the standard way As mentioned, the The macVim cask on the other hand provides several binaries https://github.com/Homebrew/homebrew-cask/blob/9b00cc305f9c06b69c61314984fba1dfb4248361/Casks/n/neovide.rb#L13. And they all target the same mvim script that was linked above. which selects the forking behaviour based on the binary used. In the case of macVim, that script is maintained by the team, but it does not need to and in our case I don't think it should, but I don't think we would refuse if someone made a PR and offers to maintain it. If not, it can be embedded in the cask using the preflight stanza What we definitely should not do is to embed complex logic like that in the binary itself. |
@9mm I searched around once and I remember finding Hyperdock, but yeah it hasn't been updated in 7 years. Also both Hyperdock and Dockmate are paid software, and yeah I know that's the Apple way, but I'd prefer something FOSS :) (like AltTab) I do use the 3 finger up swipe fairly often, if I need to find one specific window - but it's too tedious if I have to constantly do it. But yeah between that and AltTab I'm efficient enough, I just had to take the opportunity to rant a bit xD |
There's also this https://github.com/alex35mil/NeoHub, by @alex35mil specially made for Neovide, that you might want to look at. I'm not a mac user, so I don't know how well it works, but I have heard good things about it. |
@halostatue, can you create an issue for the key press issue with a log attached? There's a chance we can figure out the cause with that. But without any report's there's no hope of fixing it. |
It will take a bit of time (elapsed) to do so, because I need to try to isolate whether there are circumstances that cause it to happen so that I can reproduce it. It is really annoying when it happens, but when I relaunch neovide…it sometimes works. I’m swamped with paying work right now, so I’m not doing a lot of playing with Neovide right now. With respect to providing a launcher program / script for macOS, I believe that neovide should provide them like MacVim does. It should not have an "install helpers"; the homebrew cask takes care of symlinking those into I want to reiterate something, because I realize my tone may have come across as very negative. I tried Neovide last year and uninstalled it almost immediately. The improvements overall in the last year are impressive, and I applaud that. There's a long way to go, and it does require more work for better macOS integration that I am currently unable to provide (time, expertise, etc.) except as bug reports. I think there are things that could be learned from MacVim even though they are entirely different beasts. There is consideration of having a MacNeovim in the future, but I personally suspect that collaboration would be better between these two projects than competition (see macvim-dev/macvim#1472 and macvim-dev/macvim#47; the 2023 comments are more interesting). |
The defaults will be changed by #2512 |
And this was merged: |
I generally start Neovide by clicking on its Dock icon. The icon bounces and then there’s a visible stutter as the process forks, the parent exits, and the child replaces it.
But about half the time, the child appears as a second Dock icon. (I’m guessing there’s a race condition between the parent exiting and the child starting up.)
I can’t think why forking would be necessary when Neovide is launched from the Dock, and I believe it shouldn’t fork in this case.
So, either:
launchd
.or:
no-fork
to be specified in the config file (or, just make--no-fork
the default); and--fork
flag to be used in those cases where forking is really desired.Launching from the Dock is unique in that there is no way to supply any flags, so one way or another the default needs to be appropriate for that scenario.
The text was updated successfully, but these errors were encountered: