diff --git a/lua/lualine/themes/duckbones.lua b/lua/lualine/themes/duckbones.lua index 0cc8f01..6238970 100644 --- a/lua/lualine/themes/duckbones.lua +++ b/lua/lualine/themes/duckbones.lua @@ -1,34 +1 @@ --- This file is auto-generated by shipwright.nvim -local common_fg = "#9A9FBC" -local inactive_bg = "#222536" -local inactive_fg = "#F0F5C4" - -return { - normal = { - a = { bg = "#5C6489", fg = common_fg, gui = "bold" }, - b = { bg = "#3C415B", fg = common_fg }, - c = { bg = "#2B2F44", fg = "#EBEFC0" }, - }, - - insert = { - a = { bg = "#2A3E48", fg = common_fg, gui = "bold" }, - }, - - command = { - a = { bg = "#4D3191", fg = common_fg, gui = "bold" }, - }, - - visual = { - a = { bg = "#37382D", fg = common_fg, gui = "bold" }, - }, - - replace = { - a = { bg = "#311C1A", fg = common_fg, gui = "bold" }, - }, - - inactive = { - a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" }, - b = { bg = inactive_bg, fg = inactive_fg }, - c = { bg = inactive_bg, fg = inactive_fg }, - }, -} +return require("zenbones.util").get_lualine_theme("duckbones") diff --git a/lua/lualine/themes/forestbones.lua b/lua/lualine/themes/forestbones.lua index de9a323..c947bcd 100644 --- a/lua/lualine/themes/forestbones.lua +++ b/lua/lualine/themes/forestbones.lua @@ -1 +1 @@ -return require("lualine.themes.forestbones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("forestbones") diff --git a/lua/lualine/themes/neobones.lua b/lua/lualine/themes/neobones.lua index 2494baa..64a463c 100644 --- a/lua/lualine/themes/neobones.lua +++ b/lua/lualine/themes/neobones.lua @@ -1 +1 @@ -return require("lualine.themes.neobones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("neobones") diff --git a/lua/lualine/themes/nordbones.lua b/lua/lualine/themes/nordbones.lua index 4ed2a50..643c7de 100644 --- a/lua/lualine/themes/nordbones.lua +++ b/lua/lualine/themes/nordbones.lua @@ -1,34 +1 @@ --- This file is auto-generated by shipwright.nvim -local common_fg = "#A8B1C5" -local inactive_bg = "#414959" -local inactive_fg = "#F2F4F7" - -return { - normal = { - a = { bg = "#727F98", fg = common_fg, gui = "bold" }, - b = { bg = "#576175", fg = common_fg }, - c = { bg = "#485061", fg = "#EBEEF3" }, - }, - - insert = { - a = { bg = "#476968", fg = common_fg, gui = "bold" }, - }, - - command = { - a = { bg = "#84637E", fg = common_fg, gui = "bold" }, - }, - - visual = { - a = { bg = "#545F70", fg = common_fg, gui = "bold" }, - }, - - replace = { - a = { bg = "#663A3E", fg = common_fg, gui = "bold" }, - }, - - inactive = { - a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" }, - b = { bg = inactive_bg, fg = inactive_fg }, - c = { bg = inactive_bg, fg = inactive_fg }, - }, -} +return require("zenbones.util").get_lualine_theme("nordbones") diff --git a/lua/lualine/themes/randombones.lua b/lua/lualine/themes/randombones.lua index a887119..7b624c7 100644 --- a/lua/lualine/themes/randombones.lua +++ b/lua/lualine/themes/randombones.lua @@ -1 +1 @@ -return require("lualine.themes." .. vim.g.randombones_colors_name) +return require("zenbones.util").get_lualine_theme(vim.g.randombones_colors_name) diff --git a/lua/lualine/themes/rosebones.lua b/lua/lualine/themes/rosebones.lua index 6d4dd90..b1d2dcc 100644 --- a/lua/lualine/themes/rosebones.lua +++ b/lua/lualine/themes/rosebones.lua @@ -1 +1 @@ -return require("lualine.themes.rosebones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("rosebones") diff --git a/lua/lualine/themes/seoulbones.lua b/lua/lualine/themes/seoulbones.lua index e21a330..67686a2 100644 --- a/lua/lualine/themes/seoulbones.lua +++ b/lua/lualine/themes/seoulbones.lua @@ -1 +1 @@ -return require("lualine.themes.seoulbones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("seoulbones") diff --git a/lua/lualine/themes/tokyobones.lua b/lua/lualine/themes/tokyobones.lua index 5e99e04..100f0e9 100644 --- a/lua/lualine/themes/tokyobones.lua +++ b/lua/lualine/themes/tokyobones.lua @@ -1 +1 @@ -return require("lualine.themes.tokyobones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("tokyobones") diff --git a/lua/lualine/themes/vimbones.lua b/lua/lualine/themes/vimbones.lua index b2fc558..630df66 100644 --- a/lua/lualine/themes/vimbones.lua +++ b/lua/lualine/themes/vimbones.lua @@ -1,34 +1 @@ --- This file is auto-generated by shipwright.nvim -local common_fg = "#515143" -local inactive_bg = "#D6D6B5" -local inactive_fg = "#686868" - -return { - normal = { - a = { bg = "#A7A78D", fg = common_fg, gui = "bold" }, - b = { bg = "#BABB9D", fg = common_fg }, - c = { bg = "#CBCBAB", fg = "#353535" }, - }, - - insert = { - a = { bg = "#A9BED1", fg = common_fg, gui = "bold" }, - }, - - command = { - a = { bg = "#DEB9D6", fg = common_fg, gui = "bold" }, - }, - - visual = { - a = { bg = "#D7D7D7", fg = common_fg, gui = "bold" }, - }, - - replace = { - a = { bg = "#EBD8DA", fg = common_fg, gui = "bold" }, - }, - - inactive = { - a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" }, - b = { bg = inactive_bg, fg = inactive_fg }, - c = { bg = inactive_bg, fg = inactive_fg }, - }, -} +return require("zenbones.util").get_lualine_theme("vimbones") diff --git a/lua/lualine/themes/zenbones.lua b/lua/lualine/themes/zenbones.lua index 7f82ebe..05bf822 100644 --- a/lua/lualine/themes/zenbones.lua +++ b/lua/lualine/themes/zenbones.lua @@ -1 +1 @@ -return require("lualine.themes.zenbones_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("zenbones") diff --git a/lua/lualine/themes/zenburned.lua b/lua/lualine/themes/zenburned.lua index a758de6..226c58d 100644 --- a/lua/lualine/themes/zenburned.lua +++ b/lua/lualine/themes/zenburned.lua @@ -1,34 +1 @@ --- This file is auto-generated by shipwright.nvim -local common_fg = "#B6B6B6" -local inactive_bg = "#525252" -local inactive_fg = "#F5EDE0" - -return { - normal = { - a = { bg = "#868686", fg = common_fg, gui = "bold" }, - b = { bg = "#6A6A6A", fg = common_fg }, - c = { bg = "#5C5C5C", fg = "#F0E4CF" }, - }, - - insert = { - a = { bg = "#53738B", fg = common_fg, gui = "bold" }, - }, - - command = { - a = { bg = "#9C6992", fg = common_fg, gui = "bold" }, - }, - - visual = { - a = { bg = "#746956", fg = common_fg, gui = "bold" }, - }, - - replace = { - a = { bg = "#764544", fg = common_fg, gui = "bold" }, - }, - - inactive = { - a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" }, - b = { bg = inactive_bg, fg = inactive_fg }, - c = { bg = inactive_bg, fg = inactive_fg }, - }, -} +return require("zenbones.util").get_lualine_theme("zenburned") diff --git a/lua/lualine/themes/zenflesh.lua b/lua/lualine/themes/zenflesh.lua deleted file mode 100644 index 7ee10cd..0000000 --- a/lua/lualine/themes/zenflesh.lua +++ /dev/null @@ -1,34 +0,0 @@ --- This file is auto-generated from lua/zenbones/template/lualine.lua -local common_fg = "#AFA099" -local inactive_bg = "#322D2B" -local inactive_fg = "#CAD0D4" - -return { - normal = { - a = { bg = "#736863", fg = common_fg, gui = "bold" }, - b = { bg = "#4F4844", fg = common_fg }, - c = { bg = "#3E3835", fg = "#B4BDC3" }, - }, - - insert = { - a = { bg = "#324757", fg = common_fg, gui = "bold" }, - }, - - command = { - a = { bg = "#65435E", fg = common_fg, gui = "bold" }, - }, - - visual = { - a = { bg = "#3D4042", fg = common_fg, gui = "bold" }, - }, - - replace = { - a = { bg = "#3E2225", fg = common_fg, gui = "bold" }, - }, - - inactive = { - a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" }, - b = { bg = inactive_bg, fg = inactive_fg }, - c = { bg = inactive_bg, fg = inactive_fg }, - }, -} diff --git a/lua/lualine/themes/zenwritten.lua b/lua/lualine/themes/zenwritten.lua index 132c2af..c46a938 100644 --- a/lua/lualine/themes/zenwritten.lua +++ b/lua/lualine/themes/zenwritten.lua @@ -1 +1 @@ -return require("lualine.themes.zenwritten_" .. vim.opt.background:get()) +return require("zenbones.util").get_lualine_theme("zenwritten") diff --git a/lua/zenbones/util.lua b/lua/zenbones/util.lua index a900695..0563628 100644 --- a/lua/zenbones/util.lua +++ b/lua/zenbones/util.lua @@ -3,13 +3,48 @@ local M = {} --- Apply a zenbones colorscheme based on g:colors_name and &background. ---@return nil function M.apply_colorscheme() - local colors_name = vim.api.nvim_get_var "colors_name" + local colors_name = vim.g.colors_name package.loaded[colors_name] = nil require "lush"(require(colors_name), { force_clean = false }) local p = require(colors_name .. ".palette")[vim.opt.background:get()] require("zenbones.term").apply_colors(p) end +function M.get_colorscheme_list() + local json_decode = vim.fn.has "nvim-0.6.0" == 1 and vim.json.decode or vim.fn.json_decode + local file = io.open(vim.api.nvim_get_runtime_file("colorschemes.json", false)[1], "r") + local content = file:read "*a" + file:close() + return json_decode(content) +end + +function M.get_colorscheme(name) + local colorschemes = M.get_colorscheme_list() + local colorscheme = nil + for _, c in ipairs(colorschemes) do + if c.name == name then + colorscheme = c + end + end + if colorscheme == nil then + error(string.format("Invalid name %s", name)) + end + return colorscheme +end + +function M.get_lualine_theme(name) + local colorscheme = M.get_colorscheme(name) + local ness_config = vim.g[name] and vim.g[name][string.format("%sness", colorscheme.background)] + or vim.g[string.format("%s_%sness", name, colorscheme.background)] + local ness = ness_config or "default" + + if colorscheme.background then + return require(string.format("lualine.themes.%s_%s", name, ness)) + else + return require(string.format("lualine.themes.%s_%s_%s", name, vim.opt.background:get(), ness)) + end +end + --- Auto-fill a palette with the default palette. ---@param p table palette ---@param base_bg string light or dark