NIVM/lua/sherlock5512/colourSwitch.lua
Robert Morrison fb537df11b chore(init): Initial working version
Create and push an initial working version of this repo before I change
things on this machine

Signed-off-by: Robert Morrison <robert@closedless.xyz>
2023-09-10 22:22:30 +01:00

24 lines
705 B
Lua

-- A very dumb but functional way to switch between light and dark colourschemes.
-- Also with build in theme.sh integration.
local function invertTheme()
if vim.o.background == 'dark' then
vim.o.background = 'light'
else
vim.o.background = 'dark'
end
end
vim.keymap.set('n', '<leader>i', invertTheme, { desc = 'Invert colourscheme' })
if vim.fn.executable('theme.sh') and vim.fn.exists('~/.config/.theme_history') then
local currentTheme = vim.fn.system('theme.sh -l | tail -n1', 'silent'):gsub('\n', '')
local lightThemes = vim.fn.systemlist('theme.sh --light -l')
if vim.tbl_contains(lightThemes, currentTheme) then
vim.o.background = 'light'
else
vim.o.background = 'dark'
end
end