From 9660a18350dbeb24b0b23bd5f2e4a2bbb549f648 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Fri, 6 Oct 2023 07:37:07 -0700 Subject: [PATCH] Add toggle_background function and keymap --- .config/nvim/lua/config/keymaps.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 2c134f7..a42222f 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,3 +1,16 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here + +local Util = require("lazy.core.util") + +function toggle_background() + Util.info(vim.opt.background:get()) + if vim.opt.background:get() == "dark" then + vim.opt.background = "light" + else + vim.opt.background = "dark" + end +end + +vim.keymap.set("n", "", "lua toggle_background()", { desc = "Switch between dark and light themes", noremap = true })