Yagua / nebulous.nvim

Minimalist Collection of Colorschemes for Neovim Written in Lua
MIT License
184 stars 11 forks source link

Cannot change theme variant #13

Closed lostl1ght closed 2 years ago

lostl1ght commented 2 years ago

Bug description

Since ade7d7d I can no longer change theme variant using setup function.

Steps to reproduce

require('nebulous').setup({
    variant = 'midnight',
})

Additional information

I have discovered that this may happen due to setup_scheme function being called twice. The first time it is called with user parameters by setup function. The second time it is called from nebulous.vim file with default parameters.

Yagua commented 2 years ago

Hi buddy, how are you, thanks for bringing this problem to our attention. I wanted to ask you where you are calling the setup function, as I have tested it on two computers and it works correctly both in a module loaded automatically by the editor (in the after directory) and in the 'config' callback that the 'Packer' package manager has.

I show you briefly my configuration. it is located in the after/plugin directory in a file named like the theme.

image

lostl1ght commented 2 years ago

I have a loader function. It is a wrapper around packer: image

It is called from init.lua file: image

Parameter for the loader is a table and looks like this: image

Config looks like this: image

llvim.style is just a global, and if I replace it with a string 'midnight' I still get a night variant.

Yagua commented 2 years ago

I have cloned your configuration and I am changing the value of the global variable llvim.style and apparently on my pc it works.

image

image

do you think it is possible to verify if really the value you give to this variable is arriving correctly to the theme setup, generally when a value is not specified in the "variant" attribute it will be set by default night

however it is weird because in my machine it works

lostl1ght commented 2 years ago

I have added a print inside set_scheme: image

And this is what I see when I start nvim: image

You can see set_scheme is called twice.

I've also used inspect library to print tables: image

And that's what I see: image image

setup_scheme function is called twice. The first 2 tables in the output are opts and conf from my config. The third table is nil because setup_scheme is called without arguments so opts is nil and conf is the default fourth table.

So yes, the value arrives correctly but then the config gets changed to default by the second setup_scheme call.

Yagua commented 2 years ago

I understand, and upon review you are right, and I think I know where the problem is. Try commenting out the line "require(" nebulous.utils").setup_scheme()" inside colors/nebulous.vim in the theme, that's where you overwrite the user configuration (just as you mentioned). It is something that I see is causing problems and I will remove it from there, just as the readme mentions the theme is set by means of its setup function.

lostl1ght commented 2 years ago

Thank you, it helped.

As far as I'm concerned, plugins are loaded asynchronously. So maybe on your machine nebulous.vim is loaded before nebulous.lua and on mine vice versa. Maybe that's why you couldn't reproduce this issue.

Yagua commented 2 years ago

Solved in 9cb59ab