-
Hi there, Basically I have a command that I want to use to automatically change colorscheme (being triggered by a shell script) on system's appearance change (in macOS). This is the command that I have so far and I'm using the vim.api.nvim_create_user_command("ChangeBackground", function()
local dark = vim.fn.system("defaults read -g AppleInterfaceStyle")
local isDark = dark:match("^Dark") ~= nil
local lualine = require("lazy.core.config").plugins["lualine.nvim"]
local tokyo = require("lazy.core.config").plugins["tokyonight.nvim"]
local github = require("lazy.core.config").plugins["github-nvim-theme"]
local gitsigns = require("lazy.core.config").plugins["gitsigns.nvim"]
local tree = require("lazy.core.config").plugins["nvim-treesitter"]
if isDark then
vim.cmd.colorscheme("tokyonight-moon")
require("lazy.core.loader").reload(lualine)
require("lazy.core.loader").reload(tokyo)
require("lazy.core.loader").reload(gitsigns)
require("lazy.core.loader").reload(tree)
else
vim.cmd.colorscheme("github_light")
require("lazy.core.loader").reload(lualine)
require("lazy.core.loader").reload(github)
require("lazy.core.loader").reload(gitsigns)
require("lazy.core.loader").reload(tree)
end
end, {}) The issue is that there are some colors that don't change when changing the colorscheme, such as some syntax highlighting which I guess depends on treesitter, but then reloading treesitter is giving me an error: Telescope's background color is also not updated and reloading it in the same way as above didn't work. I would appreciate to be pointed in the right direction on how to accomplish that everything gets reloaded correctly (colors, I mean) when changing the colorscheme. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As I pointed out on the issue: Other plugins typically have an autocmd that triggers on colorscheme changes. If not that should be fixed in those plugins. Also, for proper reloading, complex plugins would eventually have to implement a And why do you even reload tokyonight? Your code makes no sense at all. reload is NOT the way to go here |
Beta Was this translation helpful? Give feedback.
As I pointed out on the issue:
@idr4n you should not use
reload
for this purpose, that makes no sense.For lualine, you can just change the theme I believe.
Other plugins typically have an autocmd that triggers on colorscheme changes. If not that should be fixed in those plugins.
Also, for proper reloading, complex plugins would eventually have to implement a
deactivate
function. Reloading treesitter sounds like a really bad idea for now.And why do you even reload tokyonight?
Your code makes no sense at all.
reload is NOT the way to go here