onedark.nvim icon indicating copy to clipboard operation
onedark.nvim copied to clipboard

Cannot set light theme via `setup(opts)`

Open juangiordana opened this issue 1 year ago • 2 comments

I've been playing around with the Lazy plugin manager and onedark, basically setting some custom options for loading the color scheme.

For this I've been trying to use the light theme to have a strong visual notice if the modifications I was doing where loading.

It turns out that if I use any other of the provided themes the changes were reflected, but when using the light theme the color scheme was not applied, instead it loaded the dark theme:

https://github.com/navarasu/onedark.nvim/blob/462b45758ea94ff30ad48979268094590a6b7b7e/lua/onedark/init.lua#L23

I only have a couple of weeks using Neovim so far so sending a PR would take me a while atm, but I think the referenced line could be the source of my problem and I thought about mentioning this here so you can take a look.

Cheers!

juangiordana avatar Jun 23 '23 00:06 juangiordana

Had the same issue, here's what I did. I can see all of the themes. In setup examples, the readme shows you can define a toggle, your default style, and the set of themes it switches between if one of the available. From my lua,

        style = 'deep',
        -- toggle theme style --- nil to disable
        toggle_style_key = '<leader>ts', -- nil to disable or set it to a string, for example "<leader>ts"
        toggle_style_list = { 'darker', 'deep', 'warmer', 'light' },
        -- toggle_style_list = { 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light' }, -- List of styles to toggle between

rudimusmaximus avatar Jul 26 '23 16:07 rudimusmaximus

It looks like onedark actually checks vim.opt.background in order to decide whether to set the light theme. This workaround seems fine until it's fixed (lazy.vim style):

return {{
  "navarasu/onedark.nvim",
  opts = {
    style = "light",
  },
  config = function(_, opts)
    vim.opt.background = "light"
    require("onedark").setup(opts)
  end
}}

mesmere avatar Feb 08 '24 19:02 mesmere