diff --git a/.github/workflows/check_pr_meta.yml b/.github/workflows/check_pr_meta.yml index 51afd7dd..b58179fe 100644 --- a/.github/workflows/check_pr_meta.yml +++ b/.github/workflows/check_pr_meta.yml @@ -11,7 +11,7 @@ jobs: check-pr-meta: runs-on: ubuntu-20.04 env: - REGEX_VALIDATION_PATTERN: '^(feat|themes|highlights|utils|plugins|config|fix|refactor|chore|tests|docs|style|perf|build|ci|revert|deps)(\(.*\))?:\ .*\ \(DEV-[0-9]+\)$' + REGEX_VALIDATION_PATTERN: '^(feat|themes|highlights|utils|plugins|config|fix|refactor|chore|tests|docs|style|perf|build|ci|revert|deps)(\(.*\))?(!)?:\ .*\ \(DEV-[0-9]+\)$' steps: - name: Check PR Title @@ -43,7 +43,8 @@ jobs: fi for commit_sha in $(git rev-list --no-merges "${commit_range}"); do - commit_message=$(git log --format=%B -n 1 "${commit_sha}") + commit_message=$(git log --format=%B -n 1 "${commit_sha}" | head -n 1) + echo "Checking commit message: \"${commit_message}\"" if [[ ! "${commit_message}" =~ ${{ env.REGEX_VALIDATION_PATTERN }} ]]; then echo "Error: Commit message in wrong format: \"${commit_message}\"" echo "Please suffix the commit message with the issue number followed by a space, a conventional commit prefix, and a colon (e.g. feat: (DEV-XXXX))" diff --git a/README.md b/README.md index 37aca9ce..20ccb96d 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,8 @@ return { priority = 1000, ---@type BlackAtomCore.Config opts = { - -- Set up your default theme and variant here - theme = "fall", - variant = "night", + -- Set up your default theme + theme = "terra_summer_night", }, keys = { -- You can also select a theme via a keymap diff --git a/colors/terra_fall_night.lua b/colors/terra_fall_night.lua index 558c6068..c49896e2 100644 --- a/colors/terra_fall_night.lua +++ b/colors/terra_fall_night.lua @@ -1,5 +1,2 @@ -require("black-atom-core").setup({ - theme = "fall", - variant = "night", -}) +require("black-atom-core").setup({ theme = "terra_fall_night" }) require("black-atom-core").load_colorscheme("terra_fall_night") diff --git a/colors/terra_spring_night.lua b/colors/terra_spring_night.lua index db595993..a2a7c34e 100644 --- a/colors/terra_spring_night.lua +++ b/colors/terra_spring_night.lua @@ -1,5 +1,2 @@ -require("black-atom-core").setup({ - theme = "spring", - variant = "night", -}) +require("black-atom-core").setup({ theme = "terra_spring_night" }) require("black-atom-core").load_colorscheme("terra_spring_night") diff --git a/colors/terra_summer_night.lua b/colors/terra_summer_night.lua index 8c742843..ca3388c5 100644 --- a/colors/terra_summer_night.lua +++ b/colors/terra_summer_night.lua @@ -1,5 +1,2 @@ -require("black-atom-core").setup({ - theme = "summer", - variant = "night", -}) +require("black-atom-core").setup({ theme = "terra_summer_night" }) require("black-atom-core").load_colorscheme("terra_summer_night") diff --git a/colors/terra_winter_night.lua b/colors/terra_winter_night.lua index 3f5d468e..e91c94cc 100644 --- a/colors/terra_winter_night.lua +++ b/colors/terra_winter_night.lua @@ -1,5 +1,2 @@ -require("black-atom-core").setup({ - theme = "winter", - variant = "night", -}) +require("black-atom-core").setup({ theme = "terra_winter_night" }) require("black-atom-core").load_colorscheme("terra_winter_night") diff --git a/lua/black-atom-core/colors.lua b/lua/black-atom-core/colors.lua index aa06eaab..f56f4a65 100644 --- a/lua/black-atom-core/colors.lua +++ b/lua/black-atom-core/colors.lua @@ -4,9 +4,8 @@ local M = {} ---@return BlackAtomCore.Colors function M.get() local theme = BlackAtomCoreConfig.theme - local variant = BlackAtomCoreConfig.variant - return require(require("black-atom-core.themes")[theme].variants[variant].path) + return require(require("black-atom-core.themes")[theme].path) end return M diff --git a/lua/black-atom-core/config.lua b/lua/black-atom-core/config.lua index e668ee83..f4559a2e 100644 --- a/lua/black-atom-core/config.lua +++ b/lua/black-atom-core/config.lua @@ -1,12 +1,12 @@ local M = {} +-- Escaped plugin name. Used to find its own installation path. M.plugin_name = "black%-atom%-core%.nvim" ---@type BlackAtomCore.Config M.default_config = { debug = false, - theme = "spring", - variant = "night", + theme = "terra_spring_night", term_colors = true, styles = { ending_tildes = false, diff --git a/lua/black-atom-core/init.lua b/lua/black-atom-core/init.lua index aa92ee5c..ba7f30aa 100644 --- a/lua/black-atom-core/init.lua +++ b/lua/black-atom-core/init.lua @@ -5,12 +5,12 @@ local lib = require("black-atom-core.lib") local M = {} ----@param colorscheme_name BlackAtomCore.Config.ColorSchemeName +---TODO: Handle `vim.background`: https://linear.app/black-atom-industries/issue/DEV-119/proper-handling-of-vimoptbackground-=-darklight +---@param colorscheme_name BlackAtomCore.Config.ThemeKey ---@return nil function M.load_colorscheme(colorscheme_name) lib.hls.reset() - lib.config.sync_vim_bg_with_variant(BlackAtomCoreConfig.variant) vim.o.termguicolors = true vim.g.colors_name = colorscheme_name diff --git a/lua/black-atom-core/lib/config.lua b/lua/black-atom-core/lib/config.lua index 224f99fe..774c451a 100644 --- a/lua/black-atom-core/lib/config.lua +++ b/lua/black-atom-core/lib/config.lua @@ -13,48 +13,24 @@ function M.set_config(options) BlackAtomCoreConfig = vim.tbl_deep_extend("force", BlackAtomCoreConfig, options) end ----Syncs `vim.o.background` of Vim with `variant` of BlackAtomCore.Config ----@param variant BlackAtomCore.Config.ThemeVariantKey ----@return nil -function M.sync_vim_bg_with_variant(variant) - if variant == "day" then - vim.o.background = "light" - else - vim.o.background = "dark" - end -end - ----Syncs `variant` of BlackAtomCore.Config with `vim.o.background` of Vim ----@param background "light" | "dark" ----@return nil -function M.sync_variant_with_vim_bg(background) - if background == "light" then - M.set_config({ - variant = "day", - }) - end -end - ---Notify the user about the status of the current theme ---@param themes BlackAtomCore.Config.ThemeDefinitionMap ---@param theme_key? BlackAtomCore.Config.ThemeKey ----@param variant_key? BlackAtomCore.Config.ThemeVariantKey ---@param on_allow? fun(): nil Callback which is called when the theme is allowed to use ---@return nil ---@diagnostic disable-next-line: redefined-local -function M.dev_status_warning(themes, theme_key, variant_key, on_allow) +function M.dev_status_warning(themes, theme_key, on_allow) theme_key = theme_key or BlackAtomCoreConfig.theme - variant_key = variant_key or BlackAtomCoreConfig.variant - local theme = themes[theme_key] - local status = theme.variants[variant_key].status + local theme = require("black-atom-core.lib.themes").get_theme_definition(themes, theme_key) + local status = theme.status if status == "development" then local error_message = string.format( "Theme '%s %s' is currently in %s status.\nThis is not ready to be used. Theme switch aborted.", theme.label, - theme.variants[variant_key].label, - theme.variants[variant_key].status + theme.label, + theme.status ) require("black-atom-core.lib.ui").notify(error_message, vim.log.levels.ERROR, { @@ -66,8 +42,8 @@ function M.dev_status_warning(themes, theme_key, variant_key, on_allow) local error_message = string.format( "Theme '%s %s' is currently in %s status.\nBugs and Errors are to be expected. Use at your own risk.", theme.label, - theme.variants[variant_key].label, - theme.variants[variant_key].status + theme.key.label, + theme.key.status ) require("black-atom-core.lib.ui").notify(error_message, vim.log.levels.WARN, { @@ -102,25 +78,13 @@ function M.select_theme() prompt = "Black Atom Core - Please select a Theme: ", format_item = function(theme_key) ---@type BlackAtomCore.Config.ThemeDefinition - local theme = themes[theme_key] - - ---@type BlackAtomCore.Config.ThemeVariantKey - local variant_key = BlackAtomCoreConfig.variant + local theme = require("black-atom-core.lib.themes").get_theme_definition(themes, theme_key) - return string.format( - "%s %s %s %s", - theme.icon, - theme.variants[variant_key].icon, - theme.label, - theme.variants[variant_key].label - ) + return string.format("%s %s %s %s", theme.icon, theme.label) end, }, ---@param selected_theme_key BlackAtomCore.Config.ThemeKey|nil function(selected_theme_key) - ---@type BlackAtomCore.Config.ThemeDefinition - local themeConfig = themes[selected_theme_key] - if selected_theme_key == nil then require("black-atom-core.lib.ui").notify("Aborted: No Theme selected!", vim.log.levels.INFO, { title = "Warning", @@ -129,7 +93,10 @@ function M.select_theme() return end - M.dev_status_warning(themes, selected_theme_key, BlackAtomCoreConfig.variant, function() + ---@type BlackAtomCore.Config.ThemeDefinition + local theme = require("black-atom-core.lib.themes").get_theme_definition(themes, selected_theme_key) + + M.dev_status_warning(themes, selected_theme_key, function() M.set_config({ theme = selected_theme_key, }) @@ -137,95 +104,15 @@ function M.select_theme() local colorscheme_name = require("black-atom-core.lib.themes").get_variant_value( themes, selected_theme_key, - BlackAtomCoreConfig.variant, "colorscheme_name" ) require("black-atom-core").load_colorscheme(colorscheme_name) - require("black-atom-core.lib.ui").notify( - "You selected '" .. themeConfig.label .. "'!", - vim.log.levels.INFO, - { - title = themeConfig.label, - icon = themeConfig.icon, - } - ) - end) - end - ) -end - ----Select a variant during runtime ----@return nil -function M.select_variant() - ---@param theme BlackAtomCore.Config.ThemeDefinition - ---@param variant_key BlackAtomCore.Config.ThemeVariantKey - local function formatted_variant(theme, variant_key) - return string.format( - "%s %s %s %s", - theme.icon, - theme.variants[variant_key].icon, - theme.label, - theme.variants[variant_key].label - ) - end - - local sorted_variant_keys = require("black-atom-core.lib.themes").get_sorted_variant_keys(themes) - - -- filter out current variant_key from the list of variants - local variant_select_items = vim.tbl_filter(function(variant_key) - return variant_key ~= BlackAtomCoreConfig.variant - end, sorted_variant_keys) - - vim.ui.select( - variant_select_items, - { - prompt = "Black Atom Core - Please select a variant for your current theme: ", - format_item = function(variant_key) - return formatted_variant(themes[BlackAtomCoreConfig.theme], variant_key) - end, - }, - - ---@param selected_variant_key BlackAtomCore.Config.ThemeVariantKey|nil - function(selected_variant_key) - if selected_variant_key == nil then - require("black-atom-core.lib.ui").notify("Aborted: No variant selected!", vim.log.levels.INFO, { - title = "Info", - icon = " ", + require("black-atom-core.lib.ui").notify("You selected '" .. theme.label .. "'!", vim.log.levels.INFO, { + title = theme.label, + icon = theme.icon, }) - return - end - - ---@type BlackAtomCore.Config.ThemeKey - local current_theme_key = BlackAtomCoreConfig.theme - local current_theme = themes[current_theme_key] - local formatted_variant_label = formatted_variant(current_theme, selected_variant_key) - - M.dev_status_warning(themes, current_theme_key, selected_variant_key, function() - require("black-atom-core.lib.ui").notify( - string.format("You selected '%s'!", formatted_variant_label), - vim.log.levels.INFO, - { - title = formatted_variant_label, - icon = current_theme.icon, - } - ) - - M.set_config({ - variant = selected_variant_key, - }) - - M.sync_vim_bg_with_variant(BlackAtomCoreConfig.variant) - - local colorscheme_name = require("black-atom-core.lib.themes").get_variant_value( - themes, - BlackAtomCore.Config.theme, - selected_variant_key, - "colorscheme_name" - ) - - require("black-atom-core").load_colorscheme(colorscheme_name) end) end ) diff --git a/lua/black-atom-core/lib/themes.lua b/lua/black-atom-core/lib/themes.lua index cd4b4269..fc9fb846 100644 --- a/lua/black-atom-core/lib/themes.lua +++ b/lua/black-atom-core/lib/themes.lua @@ -13,31 +13,35 @@ function M.get_ordered_theme_keys(themes) return ordered_theme_keys end ---- Get all unique variant keys from all themes +--- Get all unique theme keys from all theme definitions ---@param themes BlackAtomCore.Config.ThemeDefinitionMap ----@return BlackAtomCore.Config.ThemeVariantKey[] -function M.get_sorted_variant_keys(themes) - local sorted_variant_keys = {} +---@return BlackAtomCore.Config.ThemeKey[] +function M.get_sorted_theme_keys(themes) + local sorted_theme_keys = {} - for _, theme in pairs(themes) do - for _, variant in pairs(theme.variants) do - -- if the variant is not already in the array, add it - if not vim.tbl_contains(sorted_variant_keys, variant.key) then - table.insert(sorted_variant_keys, variant.key) - end + for theme_key in pairs(themes) do + if not vim.tbl_contains(sorted_theme_keys, theme_key) then + table.insert(sorted_theme_keys, theme_key) end end - return sorted_variant_keys + return sorted_theme_keys end ----Get a property value from a theme variant +---Get a property value from a theme definition ---@param themes BlackAtomCore.Config.ThemeDefinitionMap ---@param theme_key BlackAtomCore.Config.ThemeKey ----@param variant_key BlackAtomCore.Config.ThemeVariantKey ---@param property string -function M.get_variant_value(themes, theme_key, variant_key, property) - return themes[theme_key].variants[variant_key][property] +function M.get_variant_value(themes, theme_key, property) + return themes[theme_key][property] +end + +---Get the theme definition for a given theme key +---@param themes BlackAtomCore.Config.ThemeDefinitionMap +---@param theme_key BlackAtomCore.Config.ThemeKey +---@return BlackAtomCore.Config.ThemeDefinition +function M.get_theme_definition(themes, theme_key) + return themes[theme_key] end return M diff --git a/lua/black-atom-core/themes.lua b/lua/black-atom-core/themes.lua index 049d4a66..6b5d1534 100644 --- a/lua/black-atom-core/themes.lua +++ b/lua/black-atom-core/themes.lua @@ -1,108 +1,84 @@ ---@type BlackAtomCore.Config.ThemeDefinitionMap local themes = { - spring = { + terra_spring_day = { order = 1, - key = "spring", - label = "Spring", - icon = "󰧲 ", + key = "terra_spring_day", + label = "Terra Spring Day", + icon = "󰧲  ", + path = "black-atom-core.themes.spring_day", group = "seasons", - path = "black-atom-core.themes.spring", - variants = { - day = { - key = "day", - label = "Day", - icon = " ", - status = "development", - colorscheme_name = "terra_spring_day", - path = "black-atom-core.themes.spring_day", - }, - night = { - key = "night", - label = "Night", - icon = "󰖔 ", - status = "release", - colorscheme_name = "terra_spring_night", - path = "black-atom-core.themes.spring_night", - }, - }, + status = "development", + appearance = "light", }, - summer = { + terra_spring_night = { order = 2, - key = "summer", - label = "Summer", - icon = "󰂒 ", - path = "black-atom-core.themes.summer", + key = "terra_spring_night", + label = "Terra Spring Night", + icon = "󰧲 󰖔 ", + path = "black-atom-core.themes.spring_night", group = "seasons", - variants = { - day = { - key = "day", - label = "Day", - icon = " ", - status = "development", - colorscheme_name = "terra_summer_day", - path = "black-atom-core.themes.summer_day", - }, - night = { - key = "night", - label = "Night", - icon = "󰖔 ", - status = "release", - colorscheme_name = "terra_summer_night", - path = "black-atom-core.themes.summer_night", - }, - }, + status = "release", + appearance = "dark", }, - fall = { + terra_summer_day = { order = 3, - label = "Fall", - key = "fall", - icon = " ", - path = "black-atom-core.themes.fall", + key = "terra_summer_day", + label = "Terra Summer Day", + icon = "󰂒  ", + path = "black-atom-core.themes.summer_day", group = "seasons", - variants = { - day = { - key = "day", - label = "Day", - icon = " ", - status = "development", - colorscheme_name = "terra_fall_day", - path = "black-atom-core.themes.fall_day", - }, - night = { - key = "night", - label = "Night", - icon = "󰖔 ", - status = "release", - colorscheme_name = "terra_fall_night", - path = "black-atom-core.themes.fall_night", - }, - }, + status = "development", + appearance = "light", }, - winter = { + terra_summer_night = { order = 4, - label = "Winter", - key = "winter", - icon = " ", - path = "black-atom-core.themes.winter", + key = "terra_summer_night", + label = "Terra Summer Night", + icon = "󰂒 󰖔 ", + path = "black-atom-core.themes.summer_night", group = "seasons", - variants = { - day = { - key = "day", - label = "Day", - icon = " ", - status = "development", - colorscheme_name = "terra_winter_day", - path = "black-atom-core.themes.winter_day", - }, - night = { - key = "night", - label = "Night", - icon = "󰖔 ", - status = "beta", - colorscheme_name = "terra_winter_night", - path = "black-atom-core.themes.winter_night", - }, - }, + status = "release", + appearance = "dark", + }, + terra_fall_day = { + order = 5, + key = "terra_fall_day", + label = "Terra Fall Day", + icon = "  ", + path = "black-atom-core.themes.fall_day", + group = "seasons", + status = "development", + appearance = "light", + }, + terra_fall_night = { + order = 6, + key = "terra_fall_night", + label = "Terra Fall Night", + icon = " 󰖔 ", + path = "black-atom-core.themes.fall_night", + group = "seasons", + status = "release", + appearance = "dark", + }, + terra_winter_day = { + order = 7, + key = "terra_winter_day", + label = "Terra Winter Day", + icon = "  ", + path = "black-atom-core.themes.winter_day", + group = "seasons", + status = "development", + appearance = "light", + }, + terra_winter_night = { + order = 8, + key = "terra_winter_night", + label = "Terra Winter Night", + icon = " 󰖔 ", + path = "black-atom-core.themes.winter_night", + group = "seasons", + status = "release", + appearance = "dark", }, } diff --git a/lua/black-atom-core/types.lua b/lua/black-atom-core/types.lua index f7aab269..1c86e3bd 100644 --- a/lua/black-atom-core/types.lua +++ b/lua/black-atom-core/types.lua @@ -89,26 +89,17 @@ ---@field palette BlackAtomCore.Colors.Palette ---@field semantics BlackAtomCore.Colors.Semantics ----@alias BlackAtomCore.Config.ThemeVariantKey "day" | "night" ----@alias BlackAtomCore.Config.ThemeKey "spring" | "summer" | "fall" | "winter" ----@alias BlackAtomCore.Config.ColorSchemeName "terra_spring_night" | "terra_spring_day" | "terra_summer_night" | "terra_summer_day" | "terra_fall_night" | "terra_fall_day" | "terra_winter_night" | "terra_winter_day" - ----@class BlackAtomCore.Config.VariantDefinition ----@field label string Display name ----@field key BlackAtomCore.Config.ThemeVariantKey Unique Variant Key ----@field icon string Icon to display in the UI ----@field colorscheme_name BlackAtomCore.Config.ColorSchemeName Name of the colorscheme which will appear in :colorscheme ----@field path string Path to the variant module ----@field status "development" | "beta" | "release" Status of the variant +---@alias BlackAtomCore.Config.ThemeKey "terra_spring_night" | "terra_spring_day" | "terra_summer_night" | "terra_summer_day" | "terra_fall_night" | "terra_fall_day" | "terra_winter_night" | "terra_winter_day" ---@class BlackAtomCore.Config.ThemeDefinition ---@field label string Display name ----@field key BlackAtomCore.Config.ThemeKey Unique Theme Key +---@field key BlackAtomCore.Config.ThemeKey (Unique) Theme Key ---@field icon string Icon to display in the UI ---@field path string Path to the theme module ---@field order integer Order in which the theme will appear in custom picker +---@field appearance "light" | "dark" ---@field group "seasons" Theme group to which the theme belongs ----@field variants table +---@field status "development" | "beta" | "release" Status of the theme ---@alias BlackAtomCore.Config.ThemeDefinitionMap table @@ -118,7 +109,7 @@ ---@field functions? BlackAtomCore.HighlightDefinition ---@field strings? BlackAtomCore.HighlightDefinition ---@field variables? BlackAtomCore.HighlightDefinition ----@field messages? BlackAtomCore.HighlightDefinition Affects: `WarningMsg`, `ErrorMsg`, `MoreMsg`, `ModeMsg` +---@field messages? BlackAtomCore.HighlightDefinition ---@class BlackAtomCore.Config.Diagnostics ---@field undercurl? boolean Wether to use undercurls for diagnostics (Default: false) @@ -136,7 +127,6 @@ ---@class BlackAtomCore.Config ---@field debug? boolean Enables the Debug Mode (Enables various debug messages) (Default: false) ----@field theme? BlackAtomCore.Config.ThemeKey Currently set theme (Default: "spring") ----@field variant? BlackAtomCore.Config.ThemeVariantKey Currently set variant (Default: "night") +---@field theme? BlackAtomCore.Config.ThemeKey Currently set theme (Default: "terra_spring_night") ---@field term_colors? boolean Wether to enable terminal colors (Default: true) ---@field styles? BlackAtomCore.Config.Styles Various styles related settings (Default: See Documentation) diff --git a/lua/black-atom-core/util.lua b/lua/black-atom-core/util.lua index d14bbca4..2d69d3b3 100644 --- a/lua/black-atom-core/util.lua +++ b/lua/black-atom-core/util.lua @@ -5,6 +5,4 @@ local M = {} M.select_theme = require("black-atom-core.lib.config").select_theme -M.select_variant = require("black-atom-core.lib.config").select_variant - return M