From dd2c194b6eab1491291d6545c2f04050e18457f6 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 6 Mar 2024 18:07:47 +0300 Subject: [PATCH] Nvim : Add colorscheme toggles to + [ and ]. --- module/common/Nvim.nix | 1 + module/common/nvim/key/Colorscheme.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 module/common/nvim/key/Colorscheme.lua diff --git a/module/common/Nvim.nix b/module/common/Nvim.nix index 4a44ce1d..16d81d09 100644 --- a/module/common/Nvim.nix +++ b/module/common/Nvim.nix @@ -58,6 +58,7 @@ in { lua dofile("${nvimSrc}/plugin/Ollama.lua") lua dofile("${nvimSrc}/key/Autocomplete.lua") lua dofile("${nvimSrc}/key/Buffer.lua") + lua dofile("${nvimSrc}/key/Colorscheme.lua") lua dofile("${nvimSrc}/key/Comment.lua") lua dofile("${nvimSrc}/key/Common.lua") lua dofile("${nvimSrc}/key/Filetree.lua") diff --git a/module/common/nvim/key/Colorscheme.lua b/module/common/nvim/key/Colorscheme.lua new file mode 100644 index 00000000..0ad99fd4 --- /dev/null +++ b/module/common/nvim/key/Colorscheme.lua @@ -0,0 +1,21 @@ +function toggle_contrast() + if vim.g.gruvbox_material_background == "light" then + vim.g.gruvbox_material_background = "medium" + elseif vim.g.gruvbox_material_background == "medium" then + vim.g.gruvbox_material_background = "hard" + elseif vim.g.gruvbox_material_background == "hard" then + vim.g.gruvbox_material_background = "light" + end + vim.cmd("colorscheme gruvbox-material") +end + +function toggle_light() + if vim.o.background == "light" then + vim.o.background = "dark" + elseif vim.o.background == "dark" then + vim.o.background = "light" + end +end + +rekey_normal("[", "lua toggle_contrast()") +rekey_normal("]", "lua toggle_light()")