feat: support themes other than defaults
Try to activate a theme if not presented in defaults. Accordingly, add the option `ui.colors` to provide the missing `hl_theme*` in the custom theme.
This commit is contained in:
parent
958a62bc67
commit
ec5017126c
|
@ -13,22 +13,34 @@ M.init = function(theme)
|
||||||
|
|
||||||
if present then
|
if present then
|
||||||
-- first load the base16 theme
|
-- first load the base16 theme
|
||||||
base16(base16.themes(theme), true)
|
local ok, array = pcall(base16.themes, theme)
|
||||||
|
|
||||||
-- unload to force reload
|
if ok then
|
||||||
package.loaded["colors.highlights" or false] = nil
|
base16(array, true)
|
||||||
-- then load the highlights
|
-- unload to force reload
|
||||||
require "colors.highlights"
|
package.loaded["colors.highlights" or false] = nil
|
||||||
|
-- then load the highlights
|
||||||
|
require "colors.highlights"
|
||||||
|
else
|
||||||
|
pcall(vim.cmd, "colo " .. theme)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
pcall(vim.cmd, "colo " .. theme)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns a table of colors for given or current theme
|
-- returns a table of colors for given or current theme
|
||||||
M.get = function(theme)
|
M.get = function(theme)
|
||||||
if not theme then
|
local colors = require("core.utils").load_config().ui.colors
|
||||||
theme = vim.g.nvchad_theme
|
|
||||||
end
|
|
||||||
|
|
||||||
return require("hl_themes." .. theme)
|
if #colors ~= 0 then
|
||||||
|
return require(colors)
|
||||||
|
else
|
||||||
|
if not theme then
|
||||||
|
theme = vim.g.nvchad_theme
|
||||||
|
end
|
||||||
|
return require("hl_themes." .. theme)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
@ -46,6 +46,7 @@ M.options = {
|
||||||
|
|
||||||
M.ui = {
|
M.ui = {
|
||||||
hl_override = "", -- path of your file that contains highlights
|
hl_override = "", -- path of your file that contains highlights
|
||||||
|
colors = "", -- path of your file that contains colors
|
||||||
italic_comments = false,
|
italic_comments = false,
|
||||||
theme = "onedark", -- default theme
|
theme = "onedark", -- default theme
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue