-
May I ask how to define a keymap in tokyonight config to toggle btw dark and light modes? Similarly, how to define a keymap to toggle the transparent mode? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @hopezh, I might be far from the point but there is option require("tokyonight").setup({
style = 'moon',
light_style = 'day',
})
-- default value
vim.opt.background = "dark" and then define user command to toggle between the two: vim.api.nvim_create_user_command('ToggleTheme', function (input)
if vim.opt.background == "dark" then
vim.opt.background = "light"
else
vim.opt.background = "dark"
end
end, {})
-- also define the keymap
vim.keymap.set("n", "<leader>t", vim.cmd.ToggleTheme, {}) I haven't tested this, writing from top of my head, but it might me worth trying out. I'm personally handling it Edit: If changing value of vim.api.nvim_create_user_command('ToggleTheme', function (input)
if vim.opt.background == "dark" then
vim.opt.background = "light"
vim.cmd("colorscheme tokyonight-day")
else
vim.opt.background = "dark"
vim.cmd("colorscheme tokyonight-moon")
end
end, {})
-- also define the keymap
vim.keymap.set("n", "<leader>t", vim.cmd.ToggleTheme, {}) |
Beta Was this translation helpful? Give feedback.
Hey @hopezh, I've managed to get the toggler working with following code:
The difference from previous snip…