diff --git a/Taskfile.yaml b/Taskfile.yaml index 80a4b31..158fc2e 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -16,6 +16,7 @@ tasks: - i run: cmds: + - task: build - nix run aliases: - r diff --git a/plugins/bombadil.lua b/plugins/bombadil.lua index aedcc3d..9c26cdd 100644 --- a/plugins/bombadil.lua +++ b/plugins/bombadil.lua @@ -1,3 +1,8 @@ return function() + vim.opt.background = (function() + local t = os.date "*t" + -- Use light theme between 8am and 8pm, light theme otherwise + return t.hour < 8 or t.hour > 20 and "dark" or "light" + end)() vim.cmd.colorscheme "flavours" end diff --git a/plugins/bombadil/lua/flavours.lua b/plugins/bombadil/lua/flavours.lua index c900585..bb46c61 100644 --- a/plugins/bombadil/lua/flavours.lua +++ b/plugins/bombadil/lua/flavours.lua @@ -1,20 +1,31 @@ local M = {} +local function hi(higroup, val) + vim.api.nvim_set_hl(0, higroup, val) +end + +local function link(higroup, link_to) + hi(higroup, { link = link_to }) +end + function M.setup() vim.opt.termguicolors = true - local palette = require "flavours.palette" + local palette = M.palette() + + for key, value in pairs(palette) do + hi(key .. "_fg", { fg = value, nocombine = true }) + hi(key .. "_bg", { bg = value, nocombine = true }) + end + for _, what in ipairs { "vim", "syntax", "diagnostics", "lsp" } do require("flavours." .. what).setup(palette) end end -local function hi(higroup, val) - vim.api.nvim_set_hl(0, higroup, val) -end - -local function link(higroup, link_to) - hi(higroup, { link = link_to }) +function M.palette() + local mode = vim.opt.background:get() or "dark" + return require("flavours.palette")[mode] end M.highlight = setmetatable({}, { diff --git a/plugins/bombadil/lua/flavours/palette.lua b/plugins/bombadil/lua/flavours/palette.lua index e965463..0da06f1 100644 --- a/plugins/bombadil/lua/flavours/palette.lua +++ b/plugins/bombadil/lua/flavours/palette.lua @@ -1,4 +1,4 @@ -local colors = { +local dark = { base00 = "#2d2d2d", base01 = "#393939", base02 = "#515151", @@ -17,4 +17,26 @@ local colors = { base0F = "#a3685a", } -return colors +local light = { + base00 = "#ffffff", + base01 = "#e0e0e0", + base02 = "#d6d6d6", + base03 = "#8e908c", + base04 = "#969896", + base05 = "#4d4d4c", + base06 = "#282a2e", + base07 = "#1d1f21", + base08 = "#c82829", + base09 = "#f5871f", + base0A = "#eab700", + base0B = "#718c00", + base0C = "#3e999f", + base0D = "#4271ae", + base0E = "#8959a8", + base0F = "#a3685a", +} + +return { + dark = dark, + light = light, +} diff --git a/plugins/bombadil/lua/flavours/syntax.lua b/plugins/bombadil/lua/flavours/syntax.lua index a37217e..b30e138 100644 --- a/plugins/bombadil/lua/flavours/syntax.lua +++ b/plugins/bombadil/lua/flavours/syntax.lua @@ -4,6 +4,7 @@ local M = {} function M.setup(palette) -- See: |group-name| + hi.Comment = { fg = palette.base04, italic = true } hi.Constant = { fg = palette.base09 } hi.String = { fg = palette.base0B } -- hi.Character = "Constant" diff --git a/plugins/indent-blankline.lua b/plugins/indent-blankline.lua index 36d94cb..858de42 100644 --- a/plugins/indent-blankline.lua +++ b/plugins/indent-blankline.lua @@ -19,8 +19,7 @@ return function() } local hi = require("flavours").highlight - local palette = require "flavours.palette" - hi.IndentBlanklineChar = { fg = palette.base02, nocombine = true } - hi.IndentBlanklineContextChar = { fg = palette.base04, nocombine = true } + hi.IndentBlanklineChar = "base02_fg" + hi.IndentBlanklineContextChar = "base04_fg" end diff --git a/plugins/lualine.lua b/plugins/lualine.lua index 827a33a..6e3abce 100644 --- a/plugins/lualine.lua +++ b/plugins/lualine.lua @@ -45,7 +45,7 @@ return function() }, } - local palette = require "flavours.palette" + local palette = require("flavours").palette() local theme = { normal = { a = { fg = palette.base01, bg = palette.base0D },