From bd4e3d58e2c217abaaef0bfc0745e3fa25259544 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 12:16:26 +0200 Subject: [PATCH 01/13] refactor: use a better way to generate day style --- lua/lightline/colorscheme/tokyonight.lua | 12 ---- lua/lualine/themes/tokyonight.lua | 13 ---- lua/tokyonight/colors.lua | 4 +- lua/tokyonight/extra/init.lua | 1 - lua/tokyonight/util.lua | 92 +++--------------------- 5 files changed, 12 insertions(+), 110 deletions(-) diff --git a/lua/lightline/colorscheme/tokyonight.lua b/lua/lightline/colorscheme/tokyonight.lua index e37694b..5220f12 100644 --- a/lua/lightline/colorscheme/tokyonight.lua +++ b/lua/lightline/colorscheme/tokyonight.lua @@ -1,6 +1,5 @@ local config = require("tokyonight.config") local colors = require("tokyonight.colors").setup(config) -local util = require("tokyonight.util") local tokyonight = {} @@ -37,15 +36,4 @@ tokyonight.tabline = { tabsel = { { colors.blue, colors.fg_gutter }, { colors.dark3, colors.bg } }, } -if vim.o.background == "light" then - for _, mode in pairs(tokyonight) do - for _, section in pairs(mode) do - for _, subsection in pairs(section) do - subsection[1] = util.getColor(subsection[1]) - subsection[2] = util.getColor(subsection[2]) - end - end - end -end - return tokyonight diff --git a/lua/lualine/themes/tokyonight.lua b/lua/lualine/themes/tokyonight.lua index 5312214..88c41ba 100644 --- a/lua/lualine/themes/tokyonight.lua +++ b/lua/lualine/themes/tokyonight.lua @@ -36,19 +36,6 @@ tokyonight.inactive = { c = { bg = colors.bg_statusline, fg = colors.fg_gutter }, } -if vim.o.background == "light" then - for _, mode in pairs(tokyonight) do - for _, section in pairs(mode) do - if section.bg then - section.bg = util.getColor(section.bg) - end - if section.fg then - section.fg = util.getColor(section.fg) - end - end - end -end - if vim.g.tokyonight_lualine_bold then for _, mode in pairs(tokyonight) do mode.a.gui = "bold" diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index 1ed48ab..ecf0669 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -87,8 +87,8 @@ function M.setup(config) util.color_overrides(colors, config) - if config.transform_colors and (config.style == "day" or vim.o.background == "light") then - return util.light_colors(colors) + if config.style == "day" or vim.o.background == "light" then + return util.invert_colors(colors) end return colors diff --git a/lua/tokyonight/extra/init.lua b/lua/tokyonight/extra/init.lua index 1011df2..7e33b3a 100644 --- a/lua/tokyonight/extra/init.lua +++ b/lua/tokyonight/extra/init.lua @@ -33,7 +33,6 @@ for extra, ext in pairs(extras) do for style, style_name in pairs(styles) do config.style = style config = config or require("tokyonight.config") - config.transform_colors = true local colors = require("tokyonight.colors").setup(config) local fname = extra .. "_tokyonight_" .. style .. "." .. ext colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index 87278ed..7f8fe60 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -3,7 +3,6 @@ local hsluv = require("tokyonight.hsluv") local util = {} util.colorsUsed = {} -util.colorCache = {} util.bg = "#000000" util.fg = "#ffffff" @@ -52,7 +51,7 @@ function util.brighten(color, percentage) return hsluv.hsluv_to_hex(hsl) end -function util.invertColor(color) +function util.invert_color(color) if color ~= "NONE" then local hsl = hsluv.hex_to_hsluv(color) hsl[3] = 100 - hsl[3] @@ -64,25 +63,6 @@ function util.invertColor(color) return color end -function util.randomColor(color) - if color ~= "NONE" then - local hsl = hsluv.hex_to_hsluv(color) - hsl[1] = math.random(1, 360) - return hsluv.hsluv_to_hex(hsl) - end - return color -end - -function util.getColor(color) - if vim.o.background == "dark" then - return color - end - if not util.colorCache[color] then - util.colorCache[color] = util.invertColor(color) - end - return util.colorCache[color] -end - -- local ns = vim.api.nvim_create_namespace("tokyonight") function util.highlight(group, color) if color.fg then @@ -96,9 +76,9 @@ function util.highlight(group, color) end local style = color.style and "gui=" .. color.style or "gui=NONE" - local fg = color.fg and "guifg=" .. util.getColor(color.fg) or "guifg=NONE" - local bg = color.bg and "guibg=" .. util.getColor(color.bg) or "guibg=NONE" - local sp = color.sp and "guisp=" .. util.getColor(color.sp) or "" + local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE" + local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE" + local sp = color.sp and "guisp=" .. color.sp or "" local hl = "highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp @@ -201,21 +181,18 @@ function util.terminal(colors) vim.g.terminal_color_6 = colors.cyan vim.g.terminal_color_14 = colors.cyan - - if vim.o.background == "light" then - for i = 0, 15, 1 do - vim.g["terminal_color_" .. i] = util.getColor(vim.g["terminal_color_" .. i]) - end - end end -function util.light_colors(colors) +---@param colors ColorScheme +---@return ColorScheme +function util.invert_colors(colors) if type(colors) == "string" then - return util.getColor(colors) + ---@diagnostic disable-next-line: return-type-mismatch + return util.invert_color(colors) end local ret = {} for key, value in pairs(colors) do - ret[key] = util.light_colors(value) + ret[key] = util.invert_colors(value) end return ret end @@ -278,53 +255,4 @@ function util.color_overrides(colors, config) end end -function util.light(brightness) - for hl_name, hl in pairs(vim.api.nvim__get_hl_defs(0)) do - local def = {} - for key, def_key in pairs({ foreground = "fg", background = "bg", special = "sp" }) do - if type(hl[key]) == "number" then - local hex = string.format("#%06x", hl[key]) - local color = util.invertColor(hex) - if brightness then - color = util.brighten(hex, brightness) - end - table.insert(def, "gui" .. def_key .. "=" .. color) - end - end - if hl_name ~= "" and #def > 0 then - for _, style in pairs({ "bold", "italic", "underline", "undercurl", "reverse" }) do - if hl[style] then - table.insert(def, "gui=" .. style) - end - end - - vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " ")) - end - end -end - -function util.random() - local colors = {} - for hl_name, hl in pairs(vim.api.nvim__get_hl_defs(0)) do - local def = {} - for key, def_key in pairs({ foreground = "fg", background = "bg", special = "sp" }) do - if type(hl[key]) == "number" then - local hex = string.format("#%06x", hl[key]) - local color = colors[hex] and colors[hex] or util.randomColor(hex) - colors[hex] = color - table.insert(def, "gui" .. def_key .. "=" .. color) - end - end - if hl_name ~= "" and #def > 0 then - for _, style in pairs({ "bold", "italic", "underline", "undercurl", "reverse" }) do - if hl[style] then - table.insert(def, "gui=" .. style) - end - end - - vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " ")) - end - end -end - return util From 3c05c5ad8e2611da1514d1c633b677e956fbb0ce Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 12:33:12 +0200 Subject: [PATCH 02/13] refactor: gitSigns --- lua/tokyonight/colors.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index ecf0669..58fe6ae 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -41,7 +41,6 @@ function M.setup(config) red = "#f7768e", red1 = "#db4b4b", git = { change = "#6183bb", add = "#449dab", delete = "#914c54", conflict = "#bb7a61" }, - gitSigns = { add = "#164846", change = "#394b70", delete = "#823c41" }, } if config.style == "night" or config.style == "day" or vim.o.background == "light" then colors.bg = "#1a1b26" @@ -58,9 +57,9 @@ function M.setup(config) } colors.gitSigns = { - add = util.brighten(colors.gitSigns.add, 0.2), - change = util.brighten(colors.gitSigns.change, 0.2), - delete = util.brighten(colors.gitSigns.delete, 0.2), + add = util.brighten("#164846", 0.2), + change = util.brighten("#394b70", 0.2), + delete = util.brighten("#823c41", 0.2), } colors.git.ignore = colors.dark3 From dba4e35903b6c22fda33e5f1f4139b34ced57e7b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 14:06:03 +0200 Subject: [PATCH 03/13] refactor: refactored code to better deal with the day theme --- lua/lightline/colorscheme/tokyonight.lua | 3 +- lua/lualine/themes/tokyonight.lua | 4 +- lua/tokyonight/colors.lua | 12 ++--- lua/tokyonight/config.lua | 59 +++++++++++------------- lua/tokyonight/extra/init.lua | 5 +- lua/tokyonight/theme.lua | 45 ++++++++++++------ lua/tokyonight/util.lua | 23 ++++++--- 7 files changed, 84 insertions(+), 67 deletions(-) diff --git a/lua/lightline/colorscheme/tokyonight.lua b/lua/lightline/colorscheme/tokyonight.lua index 5220f12..dba1c42 100644 --- a/lua/lightline/colorscheme/tokyonight.lua +++ b/lua/lightline/colorscheme/tokyonight.lua @@ -1,5 +1,4 @@ -local config = require("tokyonight.config") -local colors = require("tokyonight.colors").setup(config) +local colors = require("tokyonight.colors").setup({ transform = true }) local tokyonight = {} diff --git a/lua/lualine/themes/tokyonight.lua b/lua/lualine/themes/tokyonight.lua index 88c41ba..29cdffd 100644 --- a/lua/lualine/themes/tokyonight.lua +++ b/lua/lualine/themes/tokyonight.lua @@ -1,6 +1,4 @@ -local config = require("tokyonight.config") -local colors = require("tokyonight.colors").setup(config) -local util = require("tokyonight.util") +local colors = require("tokyonight.colors").setup({ transform = true }) local tokyonight = {} diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index 58fe6ae..d7c9a5f 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -1,11 +1,11 @@ local util = require("tokyonight.util") +local config = require("tokyonight.config").options local M = {} ----@param config Config ---@return ColorScheme -function M.setup(config) - config = config or require("tokyonight.config") +function M.setup(opts) + opts = opts or {} -- Color Palette ---@class ColorScheme @@ -40,7 +40,7 @@ function M.setup(config) teal = "#1abc9c", red = "#f7768e", red1 = "#db4b4b", - git = { change = "#6183bb", add = "#449dab", delete = "#914c54", conflict = "#bb7a61" }, + git = { change = "#6183bb", add = "#449dab", delete = "#914c54" }, } if config.style == "night" or config.style == "day" or vim.o.background == "light" then colors.bg = "#1a1b26" @@ -86,8 +86,8 @@ function M.setup(config) util.color_overrides(colors, config) - if config.style == "day" or vim.o.background == "light" then - return util.invert_colors(colors) + if opts.transform and (config.style == "day" or vim.o.background == "light") then + util.invert_colors(colors) end return colors diff --git a/lua/tokyonight/config.lua b/lua/tokyonight/config.lua index cb262d7..83821e0 100644 --- a/lua/tokyonight/config.lua +++ b/lua/tokyonight/config.lua @@ -1,40 +1,37 @@ -- shim vim for kitty and other generators vim = vim or { g = {}, o = {} } -local function opt(key, default) - key = "tokyonight_" .. key - if vim.g[key] == nil then - return default - end - if vim.g[key] == 0 then - return false - end - return vim.g[key] -end +local M = {} ---@class Config -local config = { - style = opt("style", "storm"), - dayBrightness = opt("day_brightness", 0.3), - transparent = opt("transparent", false), - commentStyle = opt("italic_comments", true) and "italic" or "NONE", - keywordStyle = opt("italic_keywords", true) and "italic" or "NONE", - functionStyle = opt("italic_functions", false) and "italic" or "NONE", - variableStyle = opt("italic_variables", false) and "italic" or "NONE", - hideInactiveStatusline = opt("hide_inactive_statusline", false), - terminalColors = opt("terminal_colors", true), - sidebars = opt("sidebars", {}), - colors = opt("colors", {}), - dev = opt("dev", false), - darkFloat = opt("dark_float", true), - darkSidebar = opt("dark_sidebar", true), - transparentSidebar = opt("transparent_sidebar", false), - transform_colors = false, - lualineBold = opt("lualine_bold", false), +local defaults = { + style = "storm", + styles = { + comments = "italic", + functions = "NONE", + keywords = "italic", + variables = "NONE", + }, + colors = {}, + darkFloat = true, + darkSidebar = true, + dayBrightness = 0.3, + dev = false, + hideInactiveStatusline = false, + lualineBold = false, + sidebars = {}, + terminalColors = true, + transparent = false, + transparentSidebar = false, } -if config.style == "day" then - vim.o.background = "light" +---@type Config +M.options = {} + +function M.setup(options) + M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) end -return config +M.setup() + +return M diff --git a/lua/tokyonight/extra/init.lua b/lua/tokyonight/extra/init.lua index 7e33b3a..329b07a 100644 --- a/lua/tokyonight/extra/init.lua +++ b/lua/tokyonight/extra/init.lua @@ -1,6 +1,6 @@ package.path = "./lua/?/init.lua;./lua/?.lua" -local config = require("tokyonight.config") +local config = require("tokyonight.config").options local function write(str, fileName) print("[write] extra/" .. fileName) @@ -32,8 +32,7 @@ for extra, ext in pairs(extras) do local plugin = require("tokyonight.extra." .. extra) for style, style_name in pairs(styles) do config.style = style - config = config or require("tokyonight.config") - local colors = require("tokyonight.colors").setup(config) + local colors = require("tokyonight.colors").setup({ transform = true }) local fname = extra .. "_tokyonight_" .. style .. "." .. ext colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname colors["_style_name"] = "Tokyo Night" .. style_name diff --git a/lua/tokyonight/theme.lua b/lua/tokyonight/theme.lua index 29a7cd5..6c98fa7 100644 --- a/lua/tokyonight/theme.lua +++ b/lua/tokyonight/theme.lua @@ -1,22 +1,31 @@ local util = require("tokyonight.util") local colors = require("tokyonight.colors") +local config = require("tokyonight.config").options local M = {} +-- +---@class Highlight +---@field fg string|nil +---@field bg string|nil +---@field sp string|nil +---@field style string|nil + +---@alias Highlights table ----@param config Config ---@return Theme -function M.setup(config) - config = config or require("tokyonight.config") - +function M.setup() ---@class Theme - local theme = {} - theme.config = config - theme.colors = colors.setup(config) + ---@field base Highlights + ---@field plugins Highlights + local theme = { + config = config, + colors = colors.setup(), + } local c = theme.colors theme.base = { - Comment = { fg = c.comment, style = config.commentStyle }, -- any comment + Comment = { fg = c.comment, style = config.styles.comments }, -- any comment ColorColumn = { bg = c.black }, -- used for the columns set with 'colorcolumn' Conceal = { fg = c.dark5 }, -- placeholder characters substituted for concealed text (see 'conceallevel') Cursor = { fg = c.bg, bg = c.fg }, -- character under the cursor @@ -90,15 +99,15 @@ function M.setup(config) -- Boolean = { }, -- a boolean constant: TRUE, false -- Float = { }, -- a floating point constant: 2.3e10 - Identifier = { fg = c.magenta, style = config.variableStyle }, -- (preferred) any variable name - Function = { fg = c.blue, style = config.functionStyle }, -- function name (also: methods for classes) + Identifier = { fg = c.magenta, style = config.styles.variables }, -- (preferred) any variable name + Function = { fg = c.blue, style = config.styles.functions }, -- function name (also: methods for classes) Statement = { fg = c.magenta }, -- (preferred) any statement -- Conditional = { }, -- if, then, else, endif, switch, etc. -- Repeat = { }, -- for, do, while, etc. -- Label = { }, -- case, default, etc. Operator = { fg = c.blue5 }, -- "sizeof", "+", "*", etc. - Keyword = { fg = c.cyan, style = config.keywordStyle }, -- any other keyword + Keyword = { fg = c.cyan, style = config.styles.keywords }, -- any other keyword -- Exception = { }, -- try, catch, throw PreProc = { fg = c.cyan }, -- (preferred) generic Preprocessor @@ -227,8 +236,8 @@ function M.setup(config) -- TSFuncBuiltin = { }; -- For builtin functions: `table.insert` in Lua. -- TSFuncMacro = { }; -- For macro defined fuctions (calls and definitions): each `macro_rules` in Rust. -- TSInclude = { }; -- For includes: `#include` in C, `use` or `extern crate` in Rust, or `require` in Lua. - TSKeyword = { fg = c.purple, style = config.keywordStyle }, -- For keywords that don't fall in previous categories. - TSKeywordFunction = { fg = c.magenta, style = config.functionStyle }, -- For keywords used to define a fuction. + TSKeyword = { fg = c.purple, style = config.styles.keywords }, -- For keywords that don't fall in previous categories. + TSKeywordFunction = { fg = c.magenta, style = config.styles.functions }, -- For keywords used to define a fuction. TSLabel = { fg = c.blue }, -- For labels: `label:` in C and `:label:` in Lua. -- TSMethod = { }; -- For method calls and definitions. -- TSNamespace = { }; -- For identifiers referring to modules and namespaces. @@ -248,7 +257,7 @@ function M.setup(config) -- TSSymbol = { }; -- For identifiers referring to symbols or atoms. -- TSType = { }; -- For types. -- TSTypeBuiltin = { }; -- For builtin types. - TSVariable = { style = config.variableStyle }, -- Any variable name that does not have another highlight. + TSVariable = { style = config.styles.variables }, -- Any variable name that does not have another highlight. TSVariableBuiltin = { fg = c.red }, -- Variable names that are defined by the languages, like `this` or `self`. -- TSTag = { }; -- Tags like html tag names. @@ -510,7 +519,7 @@ function M.setup(config) MiniStarterCurrent = { style = "nocombine" }, MiniStarterFooter = { fg = c.yellow, style = "italic" }, MiniStarterHeader = { fg = c.blue }, - MiniStarterInactive = { fg = c.comment, style = config.commentStyle }, + MiniStarterInactive = { fg = c.comment, style = config.styles.comments }, MiniStarterItem = { fg = c.fg, bg = config.transparent and c.none or c.bg }, MiniStarterItemBullet = { fg = c.border_highlight }, MiniStarterItemPrefix = { fg = c.warning }, @@ -563,6 +572,12 @@ function M.setup(config) theme.plugins.MiniStatuslineInactive = inactive end + if config.style == "day" or vim.o.background == "light" then + util.invert_colors(theme.colors) + util.invert_highlights(theme.base) + util.invert_highlights(theme.plugins) + end + return theme end diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index 7f8fe60..929ce2c 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -184,17 +184,29 @@ function util.terminal(colors) end ---@param colors ColorScheme ----@return ColorScheme function util.invert_colors(colors) if type(colors) == "string" then ---@diagnostic disable-next-line: return-type-mismatch return util.invert_color(colors) end - local ret = {} for key, value in pairs(colors) do - ret[key] = util.invert_colors(value) + colors[key] = util.invert_colors(value) + end +end + +---@param hls Highlights +function util.invert_highlights(hls) + for _, hl in pairs(hls) do + if hl.fg then + hl.fg = util.invert_color(hl.fg) + end + if hl.bg then + hl.bg = util.invert_color(hl.bg) + end + if hl.sp then + hl.sp = util.invert_color(hl.sp) + end end - return ret end ---@param theme Theme @@ -203,9 +215,6 @@ function util.load(theme) if vim.g.colors_name then vim.cmd("hi clear") end - -- if vim.fn.exists("syntax_on") then - -- vim.cmd("syntax reset") - -- end vim.o.termguicolors = true vim.g.colors_name = "tokyonight" From a3b558b552a7cc932f92328a5fe053711155e242 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:09:28 +0200 Subject: [PATCH 04/13] feat: added colorscheme names for styles --- colors/tokyonight-day.lua | 1 + colors/tokyonight-night.lua | 1 + colors/tokyonight-storm.lua | 1 + colors/tokyonight.lua | 1 + colors/tokyonight.vim | 9 --------- lua/tokyonight/colors.lua | 2 +- lua/tokyonight/config.lua | 7 ++++--- lua/tokyonight/init.lua | 7 ++++++- 8 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 colors/tokyonight-day.lua create mode 100644 colors/tokyonight-night.lua create mode 100644 colors/tokyonight-storm.lua create mode 100644 colors/tokyonight.lua delete mode 100644 colors/tokyonight.vim diff --git a/colors/tokyonight-day.lua b/colors/tokyonight-day.lua new file mode 100644 index 0000000..61bf56b --- /dev/null +++ b/colors/tokyonight-day.lua @@ -0,0 +1 @@ +require("tokyonight").load({ style = "day" }) diff --git a/colors/tokyonight-night.lua b/colors/tokyonight-night.lua new file mode 100644 index 0000000..92f8f26 --- /dev/null +++ b/colors/tokyonight-night.lua @@ -0,0 +1 @@ +require("tokyonight").load({ style = "night" }) diff --git a/colors/tokyonight-storm.lua b/colors/tokyonight-storm.lua new file mode 100644 index 0000000..40710d9 --- /dev/null +++ b/colors/tokyonight-storm.lua @@ -0,0 +1 @@ +require("tokyonight").load({ style = "storm" }) diff --git a/colors/tokyonight.lua b/colors/tokyonight.lua new file mode 100644 index 0000000..f559581 --- /dev/null +++ b/colors/tokyonight.lua @@ -0,0 +1 @@ +require("tokyonight").load() diff --git a/colors/tokyonight.vim b/colors/tokyonight.vim deleted file mode 100644 index 4764076..0000000 --- a/colors/tokyonight.vim +++ /dev/null @@ -1,9 +0,0 @@ -" clear cache so this reloads changes. -" useful for development -" lua package.loaded['tokyonight'] = nil -" lua package.loaded['tokyonight.theme'] = nil -" lua package.loaded['tokyonight.colors'] = nil -" lua package.loaded['tokyonight.util'] = nil -lua package.loaded['tokyonight.config'] = nil - -lua require('tokyonight').colorscheme() diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index d7c9a5f..552d439 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -1,11 +1,11 @@ local util = require("tokyonight.util") -local config = require("tokyonight.config").options local M = {} ---@return ColorScheme function M.setup(opts) opts = opts or {} + local config = require("tokyonight.config").options -- Color Palette ---@class ColorScheme diff --git a/lua/tokyonight/config.lua b/lua/tokyonight/config.lua index 83821e0..682db58 100644 --- a/lua/tokyonight/config.lua +++ b/lua/tokyonight/config.lua @@ -1,6 +1,3 @@ --- shim vim for kitty and other generators -vim = vim or { g = {}, o = {} } - local M = {} ---@class Config @@ -32,6 +29,10 @@ function M.setup(options) M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) end +function M.extend(options) + M.options = vim.tbl_deep_extend("force", {}, M.options or defaults, options or {}) +end + M.setup() return M diff --git a/lua/tokyonight/init.lua b/lua/tokyonight/init.lua index c4cbb62..6cd4ec0 100644 --- a/lua/tokyonight/init.lua +++ b/lua/tokyonight/init.lua @@ -3,8 +3,13 @@ local theme = require("tokyonight.theme") local M = {} -function M.colorscheme() +function M.load(opts) + if opts then + require("tokyonight.config").extend(opts) + end util.load(theme.setup()) end +M.colorscheme = M.load + return M From 81a68450989dcf304decbc27a69658f21a9c6038 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:10:05 +0200 Subject: [PATCH 05/13] fix: access config.options within setup instead of global --- lua/tokyonight/theme.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/tokyonight/theme.lua b/lua/tokyonight/theme.lua index 6c98fa7..4b93497 100644 --- a/lua/tokyonight/theme.lua +++ b/lua/tokyonight/theme.lua @@ -1,6 +1,5 @@ local util = require("tokyonight.util") local colors = require("tokyonight.colors") -local config = require("tokyonight.config").options local M = {} -- @@ -14,6 +13,7 @@ local M = {} ---@return Theme function M.setup() + local config = require("tokyonight.config").options ---@class Theme ---@field base Highlights ---@field plugins Highlights From 70ca40cfe7bfdd5c4b7a7b1ef7a06ee2bbf9db0a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:17:10 +0200 Subject: [PATCH 06/13] fix: improved extra generation (fixes some wrong color) --- extras/kitty_tokyonight_day.conf | 4 +- extras/kitty_tokyonight_night.conf | 4 +- extras/kitty_tokyonight_storm.conf | 2 +- extras/tmux_tokyonight_day.tmux | 14 +++---- extras/tmux_tokyonight_night.tmux | 14 +++---- lua/tokyonight/extra/init.lua | 65 ++++++++++++++++-------------- 6 files changed, 54 insertions(+), 49 deletions(-) diff --git a/extras/kitty_tokyonight_day.conf b/extras/kitty_tokyonight_day.conf index d0c95b5..6a11bc7 100644 --- a/extras/kitty_tokyonight_day.conf +++ b/extras/kitty_tokyonight_day.conf @@ -16,7 +16,7 @@ cursor_text_color #e1e2e7 # Tabs active_tab_background #2e7de9 -active_tab_foreground #d4d6e4 +active_tab_foreground #e9e9ec inactive_tab_background #c4c8da inactive_tab_foreground #8990b3 #tab_bar_background #e9e9ed @@ -44,4 +44,4 @@ color15 #3760bf # extended colors color16 #b15c00 color17 #c64343 - + \ No newline at end of file diff --git a/extras/kitty_tokyonight_night.conf b/extras/kitty_tokyonight_night.conf index fa4e665..b9dc2db 100644 --- a/extras/kitty_tokyonight_night.conf +++ b/extras/kitty_tokyonight_night.conf @@ -16,7 +16,7 @@ cursor_text_color #1a1b26 # Tabs active_tab_background #7aa2f7 -active_tab_foreground #1f2335 +active_tab_foreground #16161e inactive_tab_background #292e42 inactive_tab_foreground #545c7e #tab_bar_background #15161E @@ -44,4 +44,4 @@ color15 #c0caf5 # extended colors color16 #ff9e64 color17 #db4b4b - + \ No newline at end of file diff --git a/extras/kitty_tokyonight_storm.conf b/extras/kitty_tokyonight_storm.conf index 8b6fa00..4288f34 100644 --- a/extras/kitty_tokyonight_storm.conf +++ b/extras/kitty_tokyonight_storm.conf @@ -44,4 +44,4 @@ color15 #c0caf5 # extended colors color16 #ff9e64 color17 #db4b4b - + \ No newline at end of file diff --git a/extras/tmux_tokyonight_day.tmux b/extras/tmux_tokyonight_day.tmux index 65f1119..c6b1fea 100644 --- a/extras/tmux_tokyonight_day.tmux +++ b/extras/tmux_tokyonight_day.tmux @@ -13,7 +13,7 @@ set -g pane-active-border-style "fg=#2e7de9" set -g status "on" set -g status-justify "left" -set -g status-style "fg=#2e7de9,bg=#d4d6e4" +set -g status-style "fg=#2e7de9,bg=#e9e9ec" set -g status-left-length "100" set -g status-right-length "100" @@ -21,12 +21,12 @@ set -g status-right-length "100" set -g status-left-style NONE set -g status-right-style NONE -set -g status-left "#[fg=#e9e9ed,bg=#2e7de9,bold] #S #[fg=#2e7de9,bg=#d4d6e4,nobold,nounderscore,noitalics]" -set -g status-right "#[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#d4d6e4] #{prefix_highlight} #[fg=#a8aecb,bg=#d4d6e4,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb] %Y-%m-%d  %I:%M %p #[fg=#2e7de9,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#e9e9ed,bg=#2e7de9,bold] #h " +set -g status-left "#[fg=#e9e9ed,bg=#2e7de9,bold] #S #[fg=#2e7de9,bg=#e9e9ec,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#e9e9ec] #{prefix_highlight} #[fg=#a8aecb,bg=#e9e9ec,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb] %Y-%m-%d  %I:%M %p #[fg=#2e7de9,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#e9e9ed,bg=#2e7de9,bold] #h " -setw -g window-status-activity-style "underscore,fg=#6172b0,bg=#d4d6e4" +setw -g window-status-activity-style "underscore,fg=#6172b0,bg=#e9e9ec" setw -g window-status-separator "" -setw -g window-status-style "NONE,fg=#6172b0,bg=#d4d6e4" -setw -g window-status-format "#[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]" -setw -g window-status-current-format "#[fg=#d4d6e4,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb,bold] #I  #W #F #[fg=#a8aecb,bg=#d4d6e4,nobold,nounderscore,noitalics]" +setw -g window-status-style "NONE,fg=#6172b0,bg=#e9e9ec" +setw -g window-status-format "#[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]" +setw -g window-status-current-format "#[fg=#e9e9ec,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb,bold] #I  #W #F #[fg=#a8aecb,bg=#e9e9ec,nobold,nounderscore,noitalics]" \ No newline at end of file diff --git a/extras/tmux_tokyonight_night.tmux b/extras/tmux_tokyonight_night.tmux index 656f3ff..49adf9d 100644 --- a/extras/tmux_tokyonight_night.tmux +++ b/extras/tmux_tokyonight_night.tmux @@ -13,7 +13,7 @@ set -g pane-active-border-style "fg=#7aa2f7" set -g status "on" set -g status-justify "left" -set -g status-style "fg=#7aa2f7,bg=#1f2335" +set -g status-style "fg=#7aa2f7,bg=#16161e" set -g status-left-length "100" set -g status-right-length "100" @@ -21,12 +21,12 @@ set -g status-right-length "100" set -g status-left-style NONE set -g status-right-style NONE -set -g status-left "#[fg=#15161E,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1f2335,nobold,nounderscore,noitalics]" -set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d  %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#7aa2f7,bold] #h " +set -g status-left "#[fg=#15161E,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#16161e,nobold,nounderscore,noitalics]" +set -g status-right "#[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#16161e] #{prefix_highlight} #[fg=#3b4261,bg=#16161e,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d  %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#7aa2f7,bold] #h " -setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#1f2335" +setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#16161e" setw -g window-status-separator "" -setw -g window-status-style "NONE,fg=#a9b1d6,bg=#1f2335" -setw -g window-status-format "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]" -setw -g window-status-current-format "#[fg=#1f2335,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I  #W #F #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]" +setw -g window-status-style "NONE,fg=#a9b1d6,bg=#16161e" +setw -g window-status-format "#[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]#[default] #I  #W #F #[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]" +setw -g window-status-current-format "#[fg=#16161e,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I  #W #F #[fg=#3b4261,bg=#16161e,nobold,nounderscore,noitalics]" \ No newline at end of file diff --git a/lua/tokyonight/extra/init.lua b/lua/tokyonight/extra/init.lua index 329b07a..3791349 100644 --- a/lua/tokyonight/extra/init.lua +++ b/lua/tokyonight/extra/init.lua @@ -1,6 +1,4 @@ -package.path = "./lua/?/init.lua;./lua/?.lua" - -local config = require("tokyonight.config").options +local M = {} local function write(str, fileName) print("[write] extra/" .. fileName) @@ -9,33 +7,40 @@ local function write(str, fileName) file:close() end --- map of plugin name to plugin extension -local extras = { - kitty = "conf", - fish = "fish", - alacritty = "yml", - wezterm = "toml", - tmux = "tmux", - xresources = "Xresources", - xfceterm = "theme", - foot = "ini", - tilix = "json", -} --- map of style to style name -local styles = { - storm = " Storm", - night = "", - day = " Day", -} +function M.setup() + local config = require("tokyonight.config") + vim.o.background = "dark" -for extra, ext in pairs(extras) do - local plugin = require("tokyonight.extra." .. extra) - for style, style_name in pairs(styles) do - config.style = style - local colors = require("tokyonight.colors").setup({ transform = true }) - local fname = extra .. "_tokyonight_" .. style .. "." .. ext - colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname - colors["_style_name"] = "Tokyo Night" .. style_name - write(plugin.generate(colors), fname) + -- map of plugin name to plugin extension + local extras = { + kitty = "conf", + fish = "fish", + alacritty = "yml", + wezterm = "toml", + tmux = "tmux", + xresources = "Xresources", + xfceterm = "theme", + foot = "ini", + tilix = "json", + } + -- map of style to style name + local styles = { + storm = " Storm", + night = "", + day = " Day", + } + + for extra, ext in pairs(extras) do + local plugin = require("tokyonight.extra." .. extra) + for style, style_name in pairs(styles) do + config.setup({ style = style }) + local colors = require("tokyonight.colors").setup({ transform = true }) + local fname = extra .. "_tokyonight_" .. style .. "." .. ext + colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname + colors["_style_name"] = "Tokyo Night" .. style_name + write(plugin.generate(colors), fname) + end end end + +return M From 28b790dbd6d0dd87f762293cd20c652fd5db01aa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:55:26 +0200 Subject: [PATCH 07/13] optim: refactored color methods --- lua/tokyonight/util.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index 929ce2c..f0ff1d9 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -8,21 +8,16 @@ util.bg = "#000000" util.fg = "#ffffff" util.day_brightness = 0.3 -local function hexToRgb(hex_str) - local hex = "[abcdef0-9][abcdef0-9]" - local pat = "^#(" .. hex .. ")(" .. hex .. ")(" .. hex .. ")$" - hex_str = string.lower(hex_str) - - assert(string.find(hex_str, pat) ~= nil, "hex_to_rgb: invalid hex_str: " .. tostring(hex_str)) - - local r, g, b = string.match(hex_str, pat) - return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) } +---@param c string +local function hexToRgb(c) + c = string.lower(c) + return { tonumber(c:sub(2, 3), 16), tonumber(c:sub(4, 5), 16), tonumber(c:sub(6, 7), 16) } end ---@param fg string foreground color ---@param bg string background color ---@param alpha number number between 0 and 1. 0 results in bg, 1 results in fg -function util.blend(fg, bg, alpha) +function M.blend(fg, bg, alpha) bg = hexToRgb(bg) fg = hexToRgb(fg) @@ -31,7 +26,7 @@ function util.blend(fg, bg, alpha) return math.floor(math.min(math.max(0, ret), 255) + 0.5) end - return string.format("#%02X%02X%02X", blendChannel(1), blendChannel(2), blendChannel(3)) + return string.format("#%02x%02x%02x", blendChannel(1), blendChannel(2), blendChannel(3)) end function util.darken(hex, amount, bg) From 426aed0670ae395d20e37193d3af31d1245531a3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:56:09 +0200 Subject: [PATCH 08/13] feat: use vim.api.nvim_set_hl instead of ":hi" --- lua/tokyonight/util.lua | 129 +++++++++++++--------------------------- 1 file changed, 41 insertions(+), 88 deletions(-) diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index f0ff1d9..a713f3d 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -1,12 +1,8 @@ -local hsluv = require("tokyonight.hsluv") +local M = {} -local util = {} - -util.colorsUsed = {} - -util.bg = "#000000" -util.fg = "#ffffff" -util.day_brightness = 0.3 +M.bg = "#000000" +M.fg = "#ffffff" +M.day_brightness = 0.3 ---@param c string local function hexToRgb(c) @@ -29,83 +25,38 @@ function M.blend(fg, bg, alpha) return string.format("#%02x%02x%02x", blendChannel(1), blendChannel(2), blendChannel(3)) end -function util.darken(hex, amount, bg) - return util.blend(hex, bg or util.bg, math.abs(amount)) +function M.darken(hex, amount, bg) + return M.blend(hex, bg or M.bg, math.abs(amount)) end -function util.lighten(hex, amount, fg) - return util.blend(hex, fg or util.fg, math.abs(amount)) +function M.lighten(hex, amount, fg) + return M.blend(hex, fg or M.fg, math.abs(amount)) end -function util.brighten(color, percentage) - local hsl = hsluv.hex_to_hsluv(color) - local larpSpace = 100 - hsl[3] - if percentage < 0 then - larpSpace = hsl[3] - end - hsl[3] = hsl[3] + larpSpace * percentage - return hsluv.hsluv_to_hex(hsl) -end - -function util.invert_color(color) +function M.invert_color(color) + local hsluv = require("tokyonight.hsluv") if color ~= "NONE" then local hsl = hsluv.hex_to_hsluv(color) hsl[3] = 100 - hsl[3] if hsl[3] < 40 then - hsl[3] = hsl[3] + (100 - hsl[3]) * util.day_brightness + hsl[3] = hsl[3] + (100 - hsl[3]) * M.day_brightness end return hsluv.hsluv_to_hex(hsl) end return color end --- local ns = vim.api.nvim_create_namespace("tokyonight") -function util.highlight(group, color) - if color.fg then - util.colorsUsed[color.fg] = true - end - if color.bg then - util.colorsUsed[color.bg] = true - end - if color.sp then - util.colorsUsed[color.sp] = true - end - - local style = color.style and "gui=" .. color.style or "gui=NONE" - local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE" - local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE" - local sp = color.sp and "guisp=" .. color.sp or "" - - local hl = "highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp - - if color.link then - vim.cmd("highlight! link " .. group .. " " .. color.link) - else - -- local data = {} - -- if color.fg then data.foreground = color.fg end - -- if color.bg then data.background = color.bg end - -- if color.sp then data.special = color.sp end - -- if color.style then data[color.style] = true end - -- vim.api.nvim_set_hl(ns, group, data) - vim.cmd(hl) - end -end - -function util.debug(colors) - colors = colors or require("tokyonight.colors") - -- Dump unused colors - for name, color in pairs(colors) do - if type(color) == "table" then - util.debug(color) - else - if util.colorsUsed[color] == nil then - print("not used: " .. name .. " : " .. color) - end +function M.highlight(group, color) + local hl = { fg = color.fg, bg = color.bg, sp = color.sp, link = color.link } + if color.style and color.style:lower() ~= "none" then + for s in string.gmatch(color.style, "([^,]+)") do + hl[s] = true end end + vim.api.nvim_set_hl(0, group, hl) end --- Delete the autocmds when the theme changes to something else -function util.onColorScheme() +function M.onColorScheme() if vim.g.colors_name ~= "tokyonight" then vim.cmd([[autocmd! TokyoNight]]) vim.cmd([[augroup! TokyoNight]]) @@ -113,7 +64,7 @@ function util.onColorScheme() end ---@param config Config -function util.autocmds(config) +function M.autocmds(config) vim.cmd([[augroup TokyoNight]]) vim.cmd([[ autocmd!]]) vim.cmd([[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]]) @@ -136,20 +87,20 @@ end -- ---@param str string template string ---@param table table key value pairs to replace in the string -function util.template(str, table) +function M.template(str, table) return (str:gsub("($%b{})", function(w) return table[w:sub(3, -2)] or w end)) end -function util.syntax(syntax) +function M.syntax(syntax) for group, colors in pairs(syntax) do - util.highlight(group, colors) + M.highlight(group, colors) end end ---@param colors ColorScheme -function util.terminal(colors) +function M.terminal(colors) -- dark vim.g.terminal_color_0 = colors.black vim.g.terminal_color_8 = colors.terminal_black @@ -179,33 +130,33 @@ function util.terminal(colors) end ---@param colors ColorScheme -function util.invert_colors(colors) +function M.invert_colors(colors) if type(colors) == "string" then ---@diagnostic disable-next-line: return-type-mismatch - return util.invert_color(colors) + return M.invert_color(colors) end for key, value in pairs(colors) do - colors[key] = util.invert_colors(value) + colors[key] = M.invert_colors(value) end end ---@param hls Highlights -function util.invert_highlights(hls) +function M.invert_highlights(hls) for _, hl in pairs(hls) do if hl.fg then - hl.fg = util.invert_color(hl.fg) + hl.fg = M.invert_color(hl.fg) end if hl.bg then - hl.bg = util.invert_color(hl.bg) + hl.bg = M.invert_color(hl.bg) end if hl.sp then - hl.sp = util.invert_color(hl.sp) + hl.sp = M.invert_color(hl.sp) end end end ---@param theme Theme -function util.load(theme) +function M.load(theme) -- only needed to clear when not the default colorscheme if vim.g.colors_name then vim.cmd("hi clear") @@ -215,22 +166,24 @@ function util.load(theme) vim.g.colors_name = "tokyonight" -- vim.api.nvim__set_hl_ns(ns) -- load base theme - util.syntax(theme.base) - util.syntax(theme.plugins) + M.syntax(theme.base) + M.syntax(theme.plugins) + + -- vim.api.nvim_set_hl_ns(M.ns) if theme.config.terminalColors then - util.terminal(theme.colors) + M.terminal(theme.colors) end - util.autocmds(theme.config) + M.autocmds(theme.config) vim.defer_fn(function() - util.syntax(theme.defer) + M.syntax(theme.defer) end, 100) end ---@param config Config ---@param colors ColorScheme -function util.color_overrides(colors, config) +function M.color_overrides(colors, config) if type(config.colors) == "table" then for key, value in pairs(config.colors) do if not colors[key] then @@ -239,7 +192,7 @@ function util.color_overrides(colors, config) -- Patch: https://github.com/ful1e5/onedark.nvim/issues/6 if type(colors[key]) == "table" then - util.color_overrides(colors[key], { colors = value }) + M.color_overrides(colors[key], { colors = value }) else if value:lower() == "none" then -- set to none @@ -259,4 +212,4 @@ function util.color_overrides(colors, config) end end -return util +return M From 9268b4c39f0e82fb21f6f00feb64800f6df6ffe2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:56:39 +0200 Subject: [PATCH 09/13] optim: updated colors to no longer need brighten --- lua/tokyonight/colors.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index 552d439..f8461ac 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -57,9 +57,9 @@ function M.setup(opts) } colors.gitSigns = { - add = util.brighten("#164846", 0.2), - change = util.brighten("#394b70", 0.2), - delete = util.brighten("#823c41", 0.2), + add = "#266d6a", + change = "#536c9e", + delete = "#b2555b", } colors.git.ignore = colors.dark3 From ec13e0f44fd8f2920c291cb60aa745da1e59148e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 16:56:58 +0200 Subject: [PATCH 10/13] style: added lua annotations to init methods --- lua/tokyonight/config.lua | 2 ++ lua/tokyonight/init.lua | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lua/tokyonight/config.lua b/lua/tokyonight/config.lua index 682db58..f2b4eff 100644 --- a/lua/tokyonight/config.lua +++ b/lua/tokyonight/config.lua @@ -25,10 +25,12 @@ local defaults = { ---@type Config M.options = {} +---@param options Config|nil function M.setup(options) M.options = vim.tbl_deep_extend("force", {}, defaults, options or {}) end +---@param options Config|nil function M.extend(options) M.options = vim.tbl_deep_extend("force", {}, M.options or defaults, options or {}) end diff --git a/lua/tokyonight/init.lua b/lua/tokyonight/init.lua index 6cd4ec0..4571503 100644 --- a/lua/tokyonight/init.lua +++ b/lua/tokyonight/init.lua @@ -1,8 +1,10 @@ local util = require("tokyonight.util") local theme = require("tokyonight.theme") +local config = require("tokyonight.config") local M = {} +---@param opts Config|nil function M.load(opts) if opts then require("tokyonight.config").extend(opts) @@ -10,6 +12,9 @@ function M.load(opts) util.load(theme.setup()) end +M.setup = config.setup + +-- keep for backward compatibility M.colorscheme = M.load return M From 12649d34fec045b6cd92c252a4210cabe78748c8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 20:32:31 +0200 Subject: [PATCH 11/13] feat: callbacks to easily override (or add) colors and highlights --- lua/lualine/themes/tokyonight.lua | 3 +- lua/tokyonight/colors.lua | 14 ++++--- lua/tokyonight/config.lua | 37 +++++++++++------ lua/tokyonight/theme.lua | 66 +++++++++++++++---------------- lua/tokyonight/util.lua | 42 ++------------------ 5 files changed, 71 insertions(+), 91 deletions(-) diff --git a/lua/lualine/themes/tokyonight.lua b/lua/lualine/themes/tokyonight.lua index 29cdffd..8c48cde 100644 --- a/lua/lualine/themes/tokyonight.lua +++ b/lua/lualine/themes/tokyonight.lua @@ -1,4 +1,5 @@ local colors = require("tokyonight.colors").setup({ transform = true }) +local config = require("tokyonight.config").options local tokyonight = {} @@ -34,7 +35,7 @@ tokyonight.inactive = { c = { bg = colors.bg_statusline, fg = colors.fg_gutter }, } -if vim.g.tokyonight_lualine_bold then +if config.lualine_bold then for _, mode in pairs(tokyonight) do mode.a.gui = "bold" end diff --git a/lua/tokyonight/colors.lua b/lua/tokyonight/colors.lua index f8461ac..22431d4 100644 --- a/lua/tokyonight/colors.lua +++ b/lua/tokyonight/colors.lua @@ -47,7 +47,7 @@ function M.setup(opts) colors.bg_dark = "#16161e" end util.bg = colors.bg - util.day_brightness = config.dayBrightness + util.day_brightness = config.day_brightness colors.diff = { add = util.darken(colors.green2, 0.15), @@ -72,8 +72,13 @@ function M.setup(opts) colors.bg_statusline = colors.bg_dark -- Sidebar and Floats are configurable - colors.bg_sidebar = (config.transparentSidebar and colors.none) or config.darkSidebar and colors.bg_dark or colors.bg - colors.bg_float = config.darkFloat and colors.bg_dark or colors.bg + colors.bg_sidebar = config.styles.sidebars == "transparent" and colors.none + or config.styles.sidebars == "dark" and colors.bg_dark + or colors.bg + + colors.bg_float = config.styles.floats == "transparent" and colors.none + or config.styles.floats == "dark" and colors.bg_dark + or colors.bg colors.bg_visual = util.darken(colors.blue0, 0.7) colors.bg_search = colors.blue0 @@ -84,8 +89,7 @@ function M.setup(opts) colors.info = colors.blue2 colors.hint = colors.teal - util.color_overrides(colors, config) - + config.on_colors(colors) if opts.transform and (config.style == "day" or vim.o.background == "light") then util.invert_colors(colors) end diff --git a/lua/tokyonight/config.lua b/lua/tokyonight/config.lua index f2b4eff..68a9700 100644 --- a/lua/tokyonight/config.lua +++ b/lua/tokyonight/config.lua @@ -2,24 +2,35 @@ local M = {} ---@class Config local defaults = { - style = "storm", + style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day` + transparent = false, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim | styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value `:help attr-list` comments = "italic", - functions = "NONE", keywords = "italic", + functions = "NONE", variables = "NONE", + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows }, - colors = {}, - darkFloat = true, - darkSidebar = true, - dayBrightness = 0.3, - dev = false, - hideInactiveStatusline = false, - lualineBold = false, - sidebars = {}, - terminalColors = true, - transparent = false, - transparentSidebar = false, + sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` | + day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors | + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold | + + --- You can override specific color groups to use other groups or a hex color | + --- fucntion will be called with a ColorScheme table + ---@param colors ColorScheme + on_colors = function(colors) end, + + --- You can override specific highlights to use other groups or a hex color | + --- fucntion will be called with a Highlights and ColorScheme table + ---@param highlights Highlights + ---@param colors ColorScheme + on_highlights = function(highlights, colors) end, } ---@type Config diff --git a/lua/tokyonight/theme.lua b/lua/tokyonight/theme.lua index 4b93497..b08bb83 100644 --- a/lua/tokyonight/theme.lua +++ b/lua/tokyonight/theme.lua @@ -15,8 +15,7 @@ local M = {} function M.setup() local config = require("tokyonight.config").options ---@class Theme - ---@field base Highlights - ---@field plugins Highlights + ---@field highlights Highlights local theme = { config = config, colors = colors.setup(), @@ -24,7 +23,9 @@ function M.setup() local c = theme.colors - theme.base = { + theme.highlights = { + Foo = { bg = c.magenta2, fg = c.magenta2 }, + Comment = { fg = c.comment, style = config.styles.comments }, -- any comment ColorColumn = { bg = c.black }, -- used for the columns set with 'colorcolumn' Conceal = { fg = c.dark5 }, -- placeholder characters substituted for concealed text (see 'conceallevel') @@ -43,6 +44,7 @@ function M.setup() -- TermCursorNC= { }, -- cursor in an unfocused terminal ErrorMsg = { fg = c.error }, -- error messages on the command line VertSplit = { fg = c.border }, -- the column separating vertically split windows + WinSeparator = { fg = c.border, style = "bold" }, -- the column separating vertically split windows Folded = { fg = c.blue, bg = c.fg_gutter }, -- line used for closed folds FoldColumn = { bg = c.bg, fg = c.comment }, -- 'foldcolumn' SignColumn = { bg = config.transparent and c.none or c.bg, fg = c.fg_gutter }, -- column where |signs| are displayed @@ -188,26 +190,6 @@ function M.setup() ALEErrorSign = { fg = c.error }, ALEWarningSign = { fg = c.warning }, - } - - if not vim.diagnostic then - local severity_map = { - Error = "Error", - Warn = "Warning", - Info = "Information", - Hint = "Hint", - } - local types = { "Default", "VirtualText", "Underline" } - for _, type in ipairs(types) do - for snew, sold in pairs(severity_map) do - theme.base["LspDiagnostics" .. type .. sold] = { - link = "Diagnostic" .. (type == "Default" and "" or type) .. snew, - } - end - end - end - - theme.plugins = { -- These groups are for the neovim tree-sitter highlights. -- As of writing, tree-sitter support is a WIP, group names may change. @@ -284,9 +266,9 @@ function M.setup() rainbowcol7 = { fg = c.red }, -- LspTrouble - LspTroubleText = { fg = c.fg_dark }, - LspTroubleCount = { fg = c.magenta, bg = c.fg_gutter }, - LspTroubleNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar }, + TroubleText = { fg = c.fg_dark }, + TroubleCount = { fg = c.magenta, bg = c.fg_gutter }, + TroubleNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar }, -- Illuminate illuminatedWord = { bg = c.fg_gutter }, @@ -325,8 +307,8 @@ function M.setup() GitSignsDelete = { fg = c.gitSigns.delete }, -- diff mode: Deleted line |diff.txt| -- Telescope - TelescopeBorder = { fg = c.border_highlight, bg = config.transparent and c.bg_float or c.bg }, - TelescopeNormal = { fg = c.fg, bg = config.transparent and c.bg_float or c.bg }, + TelescopeBorder = { fg = c.border_highlight, bg = c.bg_float }, + TelescopeNormal = { fg = c.fg, bg = c.bg_float }, -- NvimTree NvimTreeNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar }, @@ -555,13 +537,30 @@ function M.setup() MiniTrailspace = { bg = c.red }, } + if not vim.diagnostic then + local severity_map = { + Error = "Error", + Warn = "Warning", + Info = "Information", + Hint = "Hint", + } + local types = { "Default", "VirtualText", "Underline" } + for _, type in ipairs(types) do + for snew, sold in pairs(severity_map) do + theme.highlights["LspDiagnostics" .. type .. sold] = { + link = "Diagnostic" .. (type == "Default" and "" or type) .. snew, + } + end + end + end + theme.defer = {} - if config.hideInactiveStatusline then + if config.hide_inactive_statusline then local inactive = { style = "underline", bg = c.none, fg = c.bg, sp = c.border } -- StatusLineNC - theme.base.StatusLineNC = inactive + theme.highlights.StatusLineNC = inactive -- LuaLine for _, section in ipairs({ "a", "b", "c" }) do @@ -569,13 +568,14 @@ function M.setup() end -- mini.statusline - theme.plugins.MiniStatuslineInactive = inactive + theme.highlights.MiniStatuslineInactive = inactive end + config.on_highlights(theme.highlights, theme.colors) + if config.style == "day" or vim.o.background == "light" then util.invert_colors(theme.colors) - util.invert_highlights(theme.base) - util.invert_highlights(theme.plugins) + util.invert_highlights(theme.highlights) end return theme diff --git a/lua/tokyonight/util.lua b/lua/tokyonight/util.lua index a713f3d..5f7c203 100644 --- a/lua/tokyonight/util.lua +++ b/lua/tokyonight/util.lua @@ -68,9 +68,6 @@ function M.autocmds(config) vim.cmd([[augroup TokyoNight]]) vim.cmd([[ autocmd!]]) vim.cmd([[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]]) - if config.dev then - vim.cmd([[ autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight]]) - end for _, sidebar in ipairs(config.sidebars) do if sidebar == "terminal" then vim.cmd([[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]) @@ -164,13 +161,11 @@ function M.load(theme) vim.o.termguicolors = true vim.g.colors_name = "tokyonight" - -- vim.api.nvim__set_hl_ns(ns) - -- load base theme - M.syntax(theme.base) - M.syntax(theme.plugins) + + M.syntax(theme.highlights) -- vim.api.nvim_set_hl_ns(M.ns) - if theme.config.terminalColors then + if theme.config.terminal_colors then M.terminal(theme.colors) end @@ -181,35 +176,4 @@ function M.load(theme) end, 100) end ----@param config Config ----@param colors ColorScheme -function M.color_overrides(colors, config) - if type(config.colors) == "table" then - for key, value in pairs(config.colors) do - if not colors[key] then - error("Color " .. key .. " does not exist") - end - - -- Patch: https://github.com/ful1e5/onedark.nvim/issues/6 - if type(colors[key]) == "table" then - M.color_overrides(colors[key], { colors = value }) - else - if value:lower() == "none" then - -- set to none - colors[key] = "NONE" - elseif string.sub(value, 1, 1) == "#" then - -- hex override - colors[key] = value - else - -- another group - if not colors[value] then - error("Color " .. value .. " does not exist") - end - colors[key] = colors[value] - end - end - end - end -end - return M From fb47f6348a8d46b734d97cef6118f73263d22bf3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 5 Sep 2022 21:02:16 +0200 Subject: [PATCH 12/13] docs!: added docs for the new settings --- README.md | 96 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 22f7fee..d285919 100644 --- a/README.md +++ b/README.md @@ -107,56 +107,68 @@ The theme comes in three styles, `storm`, a darker variant `night` and `day`. The **day** style will be used if: -- `vim.g.tokyonight_style = "day"` +- `{ style = "day"}` was passed to `setup(options)` - or `vim.o.background = "light"` -| Option | Default | Description | -| ----------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| tokyonight_style | `"storm"` | The theme comes in three styles, `storm`, a darker variant `night` and `day`. | -| tokyonight_terminal_colors | `true` | Configure the colors used when opening a `:terminal` in Neovim | -| tokyonight_italic_comments | `true` | Make comments italic | -| tokyonight_italic_keywords | `true` | Make keywords italic | -| tokyonight_italic_functions | `false` | Make functions italic | -| tokyonight_italic_variables | `false` | Make variables and identifiers italic | -| tokyonight_transparent | `false` | Enable this to disable setting the background color | -| tokyonight_hide_inactive_statusline | `false` | Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | -| tokyonight_sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` | -| tokyonight_transparent_sidebar | `false` | Sidebar like windows like `NvimTree` get a transparent background | -| tokyonight_dark_sidebar | `true` | Sidebar like windows like `NvimTree` get a darker background | -| tokyonight_dark_float | `true` | Float windows like the lsp diagnostics windows get a darker background. | -| tokyonight_colors | `{}` | You can override specific color groups to use other groups or a hex color | -| tokyonight_day_brightness | `0.3` | Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors | -| tokyonight_lualine_bold | `false` | When `true`, section headers in the lualine theme will be bold | +TokyoNight will use the default options, unless you call `setup`. + +```lua +require("tokyonight").setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day` + transparent = false, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim | + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value `:help attr-list` + comments = "italic", + keywords = "italic", + functions = "NONE", + variables = "NONE", + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows + }, + sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` | + day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors | + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold | + + --- You can override specific color groups to use other groups or a hex color | + --- fucntion will be called with a ColorScheme table + ---@param colors ColorScheme + on_colors = function(colors) end, + + --- You can override specific highlights to use other groups or a hex color | + --- fucntion will be called with a Highlights and ColorScheme table + ---@param highlights Highlights + ---@param colors ColorScheme + on_highlights = function(highlights, colors) end, +} +``` ```lua -- Example config in Lua -vim.g.tokyonight_style = "night" -vim.g.tokyonight_italic_functions = true -vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" } - --- Change the "hint" color to the "orange" color, and make the "error" color bright red -vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" } +require("tokyonight").setup({ + -- use the night style + style = "night", + -- disable italic for functions + styles = { + functions = "NONE" + }, + sidebars = { "qf", "vista_kind", "terminal", "packer" }, + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + on_colors = function(colors) { + colors.hint = colors.orange + colors.error = "#ff0000" + } +}) -- Load the colorscheme vim.cmd[[colorscheme tokyonight]] ``` -```vim -" Example config in VimScript -let g:tokyonight_style = "night" -let g:tokyonight_italic_functions = 1 -let g:tokyonight_sidebars = [ "qf", "vista_kind", "terminal", "packer" ] - -" Change the "hint" color to the "orange" color, and make the "error" color bright red -let g:tokyonight_colors = { - \ 'hint': 'orange', - \ 'error': '#ff0000' -\ } - -" Load the colorscheme -colorscheme tokyonight -``` - ### Making `undercurls` work properly in **Tmux** To have undercurls show up and in color, add the following to your **Tmux** config file: @@ -177,7 +189,7 @@ Extra color configs for **Kitty**, **Alacritty**, **Fish**, **WezTerm**, **iTerm You can easily use the color palette for other plugins inside your Neovim config: ```lua -local colors = require("tokyonight.colors").setup({}) -- pass in any of the config options as explained above +local colors = require("tokyonight.colors").setup() -- pass in any of the config options as explained above local util = require("tokyonight.util") aplugin.background = colors.bg_dark @@ -192,5 +204,5 @@ How to add a new extra template: 1. create a file like `lua/tokyonight/extra/cool-app.lua` 2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua` -3. in the root directory, run `$ lua lua/tokyonight/extra/init.lua` to generate / update extra themes +3. in Nvim, run `:lua require("tokyonight.extra").setup()` to generate / update extra themes 4. commit the newly created themes under `extra/` From f1c9d0169419d0acea42821f20b7f473629db989 Mon Sep 17 00:00:00 2001 From: folke Date: Mon, 5 Sep 2022 19:02:47 +0000 Subject: [PATCH 13/13] chore(docs): auto generate vimdoc --- doc/tokyonight.txt | 92 ++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/doc/tokyonight.txt b/doc/tokyonight.txt index cd19144..86ff2c0 100644 --- a/doc/tokyonight.txt +++ b/doc/tokyonight.txt @@ -153,56 +153,68 @@ The theme comes in three styles, `storm`, a darker variant `night` and `day`. The **day** style will be used if: -- `vim.g.tokyonight_style = "day"` +- `{ style = "day"}` was passed to `setup(options)` - or `vim.o.background = "light"` -│ Option │ Default │ Description │ -│tokyonight_style │"storm" │The theme comes in three styles, storm, a darker variant night and day. │ -│tokyonight_terminal_colors │true │Configure the colors used when opening a :terminal in Neovim │ -│tokyonight_italic_comments │true │Make comments italic │ -│tokyonight_italic_keywords │true │Make keywords italic │ -│tokyonight_italic_functions │false │Make functions italic │ -│tokyonight_italic_variables │false │Make variables and identifiers italic │ -│tokyonight_transparent │false │Enable this to disable setting the background color │ -│tokyonight_hide_inactive_statusline│false │Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.│ -│tokyonight_sidebars │{} │Set a darker background on sidebar-like windows. For example: ["qf", "vista_kind", "terminal", "packer"] │ -│tokyonight_transparent_sidebar │false │Sidebar like windows like NvimTree get a transparent background │ -│tokyonight_dark_sidebar │true │Sidebar like windows like NvimTree get a darker background │ -│tokyonight_dark_float │true │Float windows like the lsp diagnostics windows get a darker background. │ -│tokyonight_colors │{} │You can override specific color groups to use other groups or a hex color │ -│tokyonight_day_brightness │0.3 │Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors │ -│tokyonight_lualine_bold │false │When true, section headers in the lualine theme will be bold │ - +TokyoNight will use the default options, unless you call `setup`. > - -- Example config in Lua - vim.g.tokyonight_style = "night" - vim.g.tokyonight_italic_functions = true - vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" } + require("tokyonight").setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day` + transparent = false, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim | + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value `:help attr-list` + comments = "italic", + keywords = "italic", + functions = "NONE", + variables = "NONE", + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows + }, + sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` | + day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors | + hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. | + lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold | - -- Change the "hint" color to the "orange" color, and make the "error" color bright red - vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" } + --- You can override specific color groups to use other groups or a hex color | + --- fucntion will be called with a ColorScheme table + ---@param colors ColorScheme + on_colors = function(colors) end, - -- Load the colorscheme - vim.cmd[[colorscheme tokyonight]] + --- You can override specific highlights to use other groups or a hex color | + --- fucntion will be called with a Highlights and ColorScheme table + ---@param highlights Highlights + ---@param colors ColorScheme + on_highlights = function(highlights, colors) end, + } < > - " Example config in VimScript - let g:tokyonight_style = "night" - let g:tokyonight_italic_functions = 1 - let g:tokyonight_sidebars = [ "qf", "vista_kind", "terminal", "packer" ] + -- Example config in Lua + require("tokyonight").setup({ + -- use the night style + style = "night", + -- disable italic for functions + styles = { + functions = "NONE" + }, + sidebars = { "qf", "vista_kind", "terminal", "packer" }, + -- Change the "hint" color to the "orange" color, and make the "error" color bright red + on_colors = function(colors) { + colors.hint = colors.orange + colors.error = "#ff0000" + } + }) - " Change the "hint" color to the "orange" color, and make the "error" color bright red - let g:tokyonight_colors = { - \ 'hint': 'orange', - \ 'error': '#ff0000' - \ } - - " Load the colorscheme - colorscheme tokyonight + -- Load the colorscheme + vim.cmd[[colorscheme tokyonight]] < @@ -234,7 +246,7 @@ You can easily use the color palette for other plugins inside your Neovim config: > - local colors = require("tokyonight.colors").setup({}) -- pass in any of the config options as explained above + local colors = require("tokyonight.colors").setup() -- pass in any of the config options as explained above local util = require("tokyonight.util") aplugin.background = colors.bg_dark @@ -252,7 +264,7 @@ How to add a new extra template: 1. create a file like `lua/tokyonight/extra/cool-app.lua` 2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua` -3. in the root directory, run `$ lua lua/tokyonight/extra/init.lua` to generate / update extra themes +3. in Nvim, run `:lua require("tokyonight.extra").setup()` to generate / update extra themes 4. commit the newly created themes under `extra/`