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

Setting vim.o.background breaks auto-detection

Open realh opened this issue 1 year ago • 1 comments

I'm using a config based on kickstart, which uses lazy.vim. It apparently loads the plugins before vim sets vim.o.background by reading it from the terminal. This means when the vscode plugin gets loaded it reads background's default value of 'dark', and by writing this back to vim.o.background it seems to disable vim's subsequent autodetection, so it always gets forced to 'dark' even if the terminal has a light background.

If I disable the line vim.o.background = ... in the plugin's init.lua, auto-detection works correctly. Please could you consider changing it? The code below seems to work for me, and should also work for anyone who relied on the old behavior.

    local background = style or config.opts.style
    if background and background ~= vim.o.background then
        vim.o.background = background
    end

realh avatar Jan 18 '24 17:01 realh

@realh - Can you make PR if you fixed the issue?

Mofiqul avatar Jan 22 '24 14:01 Mofiqul