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

Possible to dynamically set Neovim background color based on color of enclosing text box? #1654

Open
cohml opened this issue Dec 17, 2024 · 2 comments

Comments

@cohml
Copy link

cohml commented Dec 17, 2024

Consider this scenario:

My computer is set to dark mode. In the browser, this causes web pages which respect my system's mode to show up with a dark theme. Web pages which don't respect the mode are fixed to white (usually) or some other color.

My Neovim background is dark, so it visually integrates quite nicely with websites that respect my mode. But on sites that don't (which is most of them), the mismatching colors between my embedded Neovim instance and the page surrounding it is very jarring.

So a very nice improvement to firenvim's UX would be to allow it to dynamically match or at least approximate the text box's existing background color. For instance, could firenvim access and steal the color from the underlying HTML or CSS, and run vim.api.nvim_set_hl or something in the background to set the bg or whatever to the same value?

@glacambre
Copy link
Owner

Mh, I guess firenvim should :set bg=light or :set bg=dark depending on whether the page is in light or dark mode. I remember reading about https://stackoverflow.com/questions/56393880/how-do-i-detect-dark-mode-using-javascript and https://fvsch.com/transparent-iframes not so long ago which might be useful to implement that.

@cohml
Copy link
Author

cohml commented Dec 20, 2024

firenvim should :set bg=light or :set bg=dark depending on whether the page is in light or dark mode.

If it's impossible or crazy difficult to exactly/closely match a site's specific background color, then a simple light mode/dark mode toggle would certainly be better than nothing!

I'd volunteer, but this is quite outside of my wheelhouse 😅

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

No branches or pull requests

2 participants