Nvim: add ability to switch between dark and light theme

This commit is contained in:
Marko Korhonen 2024-01-25 15:30:12 +02:00
parent f85a6425d1
commit 48f8b06521
3 changed files with 14 additions and 1 deletions

View file

@ -1,6 +1,7 @@
{ {
"LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" },
"alpha-nvim": { "branch": "main", "commit": "4b36c1ca9ea475bdc006896657cf1ccc486aeffa" }, "alpha-nvim": { "branch": "main", "commit": "4b36c1ca9ea475bdc006896657cf1ccc486aeffa" },
"auto-dark-mode.nvim": { "branch": "master", "commit": "76e8d40d1e1544bae430f739d827391cbcb42fcc" },
"bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" }, "bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" },
"cder.nvim": { "branch": "main", "commit": "07c9e3e8324ee7c3ffde493c1612aca0be5255d0" }, "cder.nvim": { "branch": "main", "commit": "07c9e3e8324ee7c3ffde493c1612aca0be5255d0" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },

View file

@ -2,6 +2,7 @@
--- @type LazyPluginSpec --- @type LazyPluginSpec
return { return {
"rebelot/kanagawa.nvim", "rebelot/kanagawa.nvim",
dependencies = { { "f-person/auto-dark-mode.nvim", config = true } },
--- @type KanagawaConfig --- @type KanagawaConfig
opts = { opts = {
compile = true, compile = true,

View file

@ -1,6 +1,16 @@
-- Display possible keybinds -- Display possible keybinds
-- Here I have also defined some generic keybinds -- Here I have also defined some generic keybinds
-- Plugin specific keybinds are set up in plugin configuration file -- Plugin specific keybinds are set up in plugin configuration file
local function toggle_theme()
local current_theme = vim.fn.eval("&background")
if current_theme == "dark" then
vim.cmd("set background=light")
else
vim.cmd("set background=dark")
end
end
--- @type LazyPluginSpec --- @type LazyPluginSpec
return { return {
"folke/which-key.nvim", "folke/which-key.nvim",
@ -10,6 +20,7 @@ return {
wk.register({ wk.register({
h = { "<cmd>nohlsearch<cr>", "Turn off search highlight" }, h = { "<cmd>nohlsearch<cr>", "Turn off search highlight" },
b = { toggle_theme, "Toggle background between dark and light" },
}, { prefix = "<leader>" }) }, { prefix = "<leader>" })
wk.register({ wk.register({