From 29e65ee8b1e5843b9e5004a84ac38016c4fc14a6 Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Fri, 5 May 2023 19:14:42 +0100 Subject: [PATCH] feat(color)!: Add theme.sh detection Add support for checking if `theme.sh` is installed and if so attempt to choose a matching theme colour. Marked as breaking as this is untested outside of my environment --- after/plugin/colour.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/after/plugin/colour.lua b/after/plugin/colour.lua index 0e86ad8..5d16827 100644 --- a/after/plugin/colour.lua +++ b/after/plugin/colour.lua @@ -3,5 +3,28 @@ if not ok then return end +-- default colourscheme settings vim.o.background = "dark" vim.cmd.colorscheme('gruvbox') + +local function invertTheme() + if vim.o.background == "dark" then + vim.o.background = "light" + else + vim.o.background = "dark" + end +end + +vim.keymap.set('n','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