Nvim : Add colorscheme toggles to <Leader> + [ and ].

This commit is contained in:
Dmitry Voronin 2024-03-06 18:07:47 +03:00
parent 18c2754546
commit dd2c194b6e
2 changed files with 22 additions and 0 deletions

View file

@ -58,6 +58,7 @@ in {
lua dofile("${nvimSrc}/plugin/Ollama.lua") lua dofile("${nvimSrc}/plugin/Ollama.lua")
lua dofile("${nvimSrc}/key/Autocomplete.lua") lua dofile("${nvimSrc}/key/Autocomplete.lua")
lua dofile("${nvimSrc}/key/Buffer.lua") lua dofile("${nvimSrc}/key/Buffer.lua")
lua dofile("${nvimSrc}/key/Colorscheme.lua")
lua dofile("${nvimSrc}/key/Comment.lua") lua dofile("${nvimSrc}/key/Comment.lua")
lua dofile("${nvimSrc}/key/Common.lua") lua dofile("${nvimSrc}/key/Common.lua")
lua dofile("${nvimSrc}/key/Filetree.lua") lua dofile("${nvimSrc}/key/Filetree.lua")

View file

@ -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("<Leader>[", "<cmd>lua toggle_contrast()<cr>")
rekey_normal("<Leader>]", "<cmd>lua toggle_light()<cr>")