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

Background gets stuck after switching it once #1

Open
Slotos opened this issue Oct 9, 2023 · 0 comments
Open

Background gets stuck after switching it once #1

Slotos opened this issue Oct 9, 2023 · 0 comments

Comments

@Slotos
Copy link

Slotos commented Oct 9, 2023

When switching background, the option gets stuck, overriding even explicit light or dark theme selection afterwards. I've done some tweaking and the following diff results in the colorscheme initializing correctly, presenting explicit non-sticky dark and light variants, and following vim.o.background regardless of which explicit version was selected, unless configuration enforces one.

diff --git a/colors/litepal.vim b/colors/litepal.vim
deleted file mode 100644
index 519bbdb..0000000
--- a/colors/litepal.vim
+++ /dev/null
@@ -1 +0,0 @@
-lua require('nitepal').colorscheme('light') 
diff --git a/colors/nitepal-dark.lua b/colors/nitepal-dark.lua
new file mode 100644
index 0000000..5cec80c
--- /dev/null
+++ b/colors/nitepal-dark.lua
@@ -0,0 +1 @@
+require('nitepal').colorscheme('dark')
diff --git a/colors/nitepal-light.lua b/colors/nitepal-light.lua
new file mode 100644
index 0000000..2ff593b
--- /dev/null
+++ b/colors/nitepal-light.lua
@@ -0,0 +1 @@
+require('nitepal').colorscheme('light')
diff --git a/colors/nitepal.lua b/colors/nitepal.lua
new file mode 100644
index 0000000..9b9fcb4
--- /dev/null
+++ b/colors/nitepal.lua
@@ -0,0 +1 @@
+require('nitepal').colorscheme()
diff --git a/colors/nitepal.vim b/colors/nitepal.vim
deleted file mode 100644
index dba74c2..0000000
--- a/colors/nitepal.vim
+++ /dev/null
@@ -1 +0,0 @@
-lua require('nitepal').colorscheme()
diff --git a/lua/lualine/themes/litepal.lua b/lua/lualine/themes/litepal.lua
deleted file mode 100644
index 24f7681..0000000
--- a/lua/lualine/themes/litepal.lua
+++ /dev/null
@@ -1 +0,0 @@
-return require('nitepal.theme').generate_lualine('light')
diff --git a/lua/lualine/themes/nitepal.lua b/lua/lualine/themes/nitepal.lua
index 9dd1790..da8a002 100644
--- a/lua/lualine/themes/nitepal.lua
+++ b/lua/lualine/themes/nitepal.lua
@@ -1 +1 @@
-return require('nitepal.theme').generate_lualine('dark')
+return require('nitepal.theme').generate_lualine(vim.o.bg)
diff --git a/lua/nitepal/init.lua b/lua/nitepal/init.lua
index 1e5708e..f44a61d 100644
--- a/lua/nitepal/init.lua
+++ b/lua/nitepal/init.lua
@@ -1,32 +1,26 @@
 local nitepal = {}
 
 function nitepal.colorscheme(style)
-    if require('nitepal.config').options.style == false then
-        style = style or vim.o.background
+  style = style or require('nitepal.config').options.style or vim.o.bg
 
-        require('nitepal.config').options.style = style
-    else
-        style = require('nitepal.config').options.style
-    end
+  if style ~= 'dark' and style ~= 'light' then
+    error('Invalid style: ' .. style)
+  end
 
-    if style ~= 'dark' and style ~= 'light' then
-        error('Invalid style: ' .. style)
-    end
+  vim.cmd([[hi clear]])
 
-    vim.cmd([[hi clear]])
+  if vim.fn.exists([[syntax_on]]) then
+    vim.cmd([[syntax reset]])
+  end
 
-    if vim.fn.exists([[syntax_on]]) then
-        vim.cmd([[syntax reset]])
-    end
+  if vim.o.background ~= style then
+    vim.o.background = style
+  end
 
-    if vim.o.background ~= style then
-        vim.o.background = style
-    end
+  vim.o.termguicolors = true
+  vim.g.colors_name = 'nitepal'
 
-    vim.o.termguicolors = true
-    vim.g.colors_name = style == 'dark' and 'nitepal' or 'litepal'
-
-    require('nitepal.theme').init()
+  require('nitepal.theme').init()
 end
 
 return nitepal
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

1 participant