-
-
Notifications
You must be signed in to change notification settings - Fork 682
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
[fix #766] Add an event for OS appearance change #929
Conversation
This is a nice addition! |
I am not sure what is the best practice to initialise a vim variable when launching a Vim process. Communicating through message queue seems unreliable as it may happen anytime. Also, the user may relay on this variable during startup, i.e. Taking the value from command-line arguments or the environment variable should work well..maybe? |
@ychin It will be nice of you if you can give some suggestion on how to check the dark mode while launching the app. .. :-) |
Hi sorry I will get back to you this weekend. |
Hi @L-TChen I'm sorry for the late response. I checked out the code and it seems to work! I think there are a few minor things we should do:
|
Thanks for getting back to me! Okay, I will look into this this weekend. |
All done, @ychin! Here are some differences from what you suggested:
However, there is a glitch with Powerline which does not render its tabline properly. That is, No idea how to fix it. Not even know which part should be responsible for this. |
The change looks good! Can you squash your changes, and also remove the #936 patch since it's now merged?
Hmm, is that related to your change? You have to manually switch colorscheme for this bug to show up right? I would imagine just switching color schemes without invoking this autocommand would trigger this bug? If so that seems unrelated. |
You're right---it is not really related to my change. It seems that the bug is triggered while the window is inactive. |
Now they are all squashed and should be ready to merge. :-) |
Merged. Thanks for the work. |
Thanks @L-TChen for this feature! It works perfectly in graphical Question: could it be made to work in cli vim as well? For me, this seems to not work in cli vim. I tried using cli $ which vim
/usr/local/bin/vim
$ ls -l /usr/local/bin/vim
/usr/local/bin/vim -> ../Cellar/macvim/8.2-171/bin/vim but the event callback is not called (like it is in MacVim.app) |
@erikw I managed to control CLI Vim appearance on enter to align to OS appearance, but yet to create a listener for automatic switching. You could refer to my Vim config here to implement it: |
This is my attempt to fulfil the feature request issued by myself (#766).
Overview
An event
OSAppearanceChanged
is added. This event is emitted when MacVim changes its appearance. (It's calledOSAppearanceChanged
, since most of end users may only change view's appearance via Preference.)A vim variable
v:os_appearance
is added. This variable reflects the appearance setting.There are four possible values as explained in the comment in
MMVimView.m
Test
The following Vimscript snippet demonstrates how this change can be used to change
background
as well ascolorscheme
by hooking a callback function to the proposed event.Result
To-do
v:os_appearance
before running.vimrc
.MMBackground
does not respond the message when initialisingMMVimView
.Any advice to set
v:os_appearance
during startup would be appreciated.ChangingUsebackground
does not update until the window is focused, although the event is actually handled in the background. Is there a way to force the window to update? (30-07-2019 Update)redraw!
.Document it.