1

How can I set the default colorscheme according the current shell light/dark theme?

I thought about using an if..else statement reading the background variable, but on my light theme terminals, background is "dark" during loading and "light" afterwards.

None of my config files set a value on background, but according :verbose set background? last value was set on Lua (no file path given)

5
  • According to theme of what? The "background" is yet another user-changeable option in vim.
    – Matt
    Commented Nov 19, 2023 at 8:55
  • according the shell theme. At least in Mac and Linux whenever I set a light/dark theme I can see the background value inheriting the value from the shell theme. If I have two shells, one with dark and another one with light theme, I can see vim using a different light/dark theme too automatically. Commented Nov 19, 2023 at 9:00
  • AFAIR, neovim always sets "dark" by default. So you need to read any external os/app settings yourself. Needless to say, linux/macos/1001 various shells all can have very different apis.
    – Matt
    Commented Nov 19, 2023 at 9:09
  • In my case, neovim is inheriting from the shell the right color theme. In my boot scripts it is always "dark" but once the editor is loaded, the same background value is set to "light" only if it was started from a shell with light theme Commented Nov 19, 2023 at 12:38
  • If the whole problem is about the execution order then postpone your code until some event, such as VimEnter, UIEnter or such.
    – Matt
    Commented Nov 19, 2023 at 17:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.