From c43a6c4aa2466f15d83f3bc0b7354cac595cd7ee Mon Sep 17 00:00:00 2001
From: Scott McKendry <39483124+scottmckendry@users.noreply.github.com>
Date: Fri, 7 Feb 2025 11:04:13 +1300
Subject: [PATCH] feat(config)!: replace `theme` and `borderless_telescope`
options
---
README.md | 117 ++++++++++++------------
lua/cyberdream/config.lua | 32 +++----
lua/cyberdream/extensions/fzflua.lua | 2 +-
lua/cyberdream/extensions/grapple.lua | 2 +-
lua/cyberdream/extensions/snacks.lua | 2 +-
lua/cyberdream/extensions/telescope.lua | 2 +-
lua/cyberdream/init.lua | 2 +-
lua/cyberdream/theme.lua | 10 +-
lua/cyberdream/util.lua | 6 +-
lua/lualine/themes/cyberdream.lua | 4 +-
10 files changed, 87 insertions(+), 92 deletions(-)
diff --git a/README.md b/README.md
index 6819353..e4c179a 100644
--- a/README.md
+++ b/README.md
@@ -138,17 +138,23 @@ Below is an example of all the available configuration options with their defaul
```lua
require("cyberdream").setup({
+ -- Set light or dark variant
+ variant = "default", -- use "light" for the light variant. Also accepts "auto" to set dark or light colors based on the current value of `vim.o.background`
+
-- Enable transparent background
transparent = false,
+ -- Reduce the overall saturation of colours for a more muted look
+ saturation = 1, -- accepts a value between 0 and 1. 0 will be fully desaturated (greyscale) and 1 will be the full color (default)
+
-- Enable italics comments
italic_comments = false,
-- Replace all fillchars with ' ' for the ultimate clean look
hide_fillchars = false,
- -- Modern borderless telescope theme - also applies to fzf-lua
- borderless_telescope = true,
+ -- Apply a modern borderless look to pickers like Telescope, Snacks Picker & Fzf-Lua
+ borderless_pickers = false,
-- Set terminal colors used in `:terminal`
terminal_colors = true,
@@ -156,36 +162,33 @@ require("cyberdream").setup({
-- Improve start up time by caching highlights. Generate cache with :CyberdreamBuildCache and clear with :CyberdreamClearCache
cache = false,
- theme = {
- variant = "default", -- use "light" for the light variant. Also accepts "auto" to set dark or light colors based on the current value of `vim.o.background`
- saturation = 1, -- accepts a value between 0 and 1. 0 will be fully desaturated (greyscale) and 1 will be the full color (default)
- highlights = {
- -- Highlight groups to override, adding new groups is also possible
- -- See `:h highlight-groups` for a list of highlight groups or run `:hi` to see all groups and their current values
+ -- Override highlight groups with your own colour values
+ highlights = {
+ -- Highlight groups to override, adding new groups is also possible
+ -- See `:h highlight-groups` for a list of highlight groups or run `:hi` to see all groups and their current values
- -- Example:
- Comment = { fg = "#696969", bg = "NONE", italic = true },
+ -- Example:
+ Comment = { fg = "#696969", bg = "NONE", italic = true },
- -- Complete list can be found in `lua/cyberdream/theme.lua`
- },
+ -- More examples can be found in `lua/cyberdream/extensions/*.lua`
+ },
- -- Override a highlight group entirely using the color palette
- overrides = function(colors) -- NOTE: This function nullifies the `highlights` option
- -- Example:
- return {
- Comment = { fg = colors.green, bg = "NONE", italic = true },
- ["@property"] = { fg = colors.magenta, bold = true },
- }
- end,
-
- -- Override a color entirely
- colors = {
- -- For a list of colors see `lua/cyberdream/colours.lua`
- -- Example:
- bg = "#000000",
- green = "#00ff00",
- magenta = "#ff00ff",
- },
+ -- Override a highlight group entirely using the built-in colour palette
+ overrides = function(colors) -- NOTE: This function nullifies the `highlights` option
+ -- Example:
+ return {
+ Comment = { fg = colors.green, bg = "NONE", italic = true },
+ ["@property"] = { fg = colors.magenta, bold = true },
+ }
+ end,
+
+ -- Override a color entirely
+ colors = {
+ -- For a list of colors see `lua/cyberdream/colours.lua`
+ -- Example:
+ bg = "#000000",
+ green = "#00ff00",
+ magenta = "#ff00ff",
},
-- Disable or enable colorscheme extensions
@@ -263,44 +266,44 @@ vim.api.nvim_create_autocmd("User", {
Dark
-| 🖌 | Hex | Color |
-| --------------------------------------------------------- | --------- | ----------- |
-| ![#16181a](https://place-hold.it/15/16181a/16181a?text=+) | `#16181a` | bg |
+| 🖌 | Hex | Color |
+| --------------------------------------------------------- | --------- | ------------ |
+| ![#16181a](https://place-hold.it/15/16181a/16181a?text=+) | `#16181a` | bg |
| ![#1e2124](https://place-hold.it/15/1e2124/1e2124?text=+) | `#1e2124` | bg_alt |
| ![#3c4048](https://place-hold.it/15/3c4048/3c4048?text=+) | `#3c4048` | bg_highlight |
-| ![#ffffff](https://place-hold.it/15/ffffff/ffffff?text=+) | `#ffffff` | fg |
-| ![#7b8496](https://place-hold.it/15/7b8496/7b8496?text=+) | `#7b8496` | grey |
-| ![#5ea1ff](https://place-hold.it/15/5ea1ff/5ea1ff?text=+) | `#5ea1ff` | blue |
-| ![#5eff6c](https://place-hold.it/15/5eff6c/5eff6c?text=+) | `#5eff6c` | green |
-| ![#5ef1ff](https://place-hold.it/15/5ef1ff/5ef1ff?text=+) | `#5ef1ff` | cyan |
-| ![#ff6e5e](https://place-hold.it/15/ff6e5e/ff6e5e?text=+) | `#ff6e5e` | red |
-| ![#f1ff5e](https://place-hold.it/15/f1ff5e/f1ff5e?text=+) | `#f1ff5e` | yellow |
-| ![#ff5ef1](https://place-hold.it/15/ff5ef1/ff5ef1?text=+) | `#ff5ef1` | magenta |
-| ![#ff5ea0](https://place-hold.it/15/ff5ea0/ff5ea0?text=+) | `#ff5ea0` | pink |
-| ![#ffbd5e](https://place-hold.it/15/ffbd5e/ffbd5e?text=+) | `#ffbd5e` | orange |
-| ![#bd5eff](https://place-hold.it/15/bd5eff/bd5eff?text=+) | `#bd5eff` | purple |
+| ![#ffffff](https://place-hold.it/15/ffffff/ffffff?text=+) | `#ffffff` | fg |
+| ![#7b8496](https://place-hold.it/15/7b8496/7b8496?text=+) | `#7b8496` | grey |
+| ![#5ea1ff](https://place-hold.it/15/5ea1ff/5ea1ff?text=+) | `#5ea1ff` | blue |
+| ![#5eff6c](https://place-hold.it/15/5eff6c/5eff6c?text=+) | `#5eff6c` | green |
+| ![#5ef1ff](https://place-hold.it/15/5ef1ff/5ef1ff?text=+) | `#5ef1ff` | cyan |
+| ![#ff6e5e](https://place-hold.it/15/ff6e5e/ff6e5e?text=+) | `#ff6e5e` | red |
+| ![#f1ff5e](https://place-hold.it/15/f1ff5e/f1ff5e?text=+) | `#f1ff5e` | yellow |
+| ![#ff5ef1](https://place-hold.it/15/ff5ef1/ff5ef1?text=+) | `#ff5ef1` | magenta |
+| ![#ff5ea0](https://place-hold.it/15/ff5ea0/ff5ea0?text=+) | `#ff5ea0` | pink |
+| ![#ffbd5e](https://place-hold.it/15/ffbd5e/ffbd5e?text=+) | `#ffbd5e` | orange |
+| ![#bd5eff](https://place-hold.it/15/bd5eff/bd5eff?text=+) | `#bd5eff` | purple |
Light
-| 🖌 | Hex | Color |
-| --------------------------------------------------------- | --------- | ----------- |
-| ![#ffffff](https://place-hold.it/15/ffffff/ffffff?text=+) | `#ffffff` | bg |
+| 🖌 | Hex | Color |
+| --------------------------------------------------------- | --------- | ------------ |
+| ![#ffffff](https://place-hold.it/15/ffffff/ffffff?text=+) | `#ffffff` | bg |
| ![#eaeaea](https://place-hold.it/15/eaeaea/eaeaea?text=+) | `#eaeaea` | bg_alt |
| ![#acacac](https://place-hold.it/15/acacac/acacac?text=+) | `#acacac` | bg_highlight |
-| ![#16181a](https://place-hold.it/15/16181a/16181a?text=+) | `#16181a` | fg |
-| ![#7b8496](https://place-hold.it/15/7b8496/7b8496?text=+) | `#7b8496` | grey |
-| ![#0057d1](https://place-hold.it/15/0057d1/0057d1?text=+) | `#0057d1` | blue |
-| ![#008b0c](https://place-hold.it/15/008b0c/008b0c?text=+) | `#008b0c` | green |
-| ![#008c99](https://place-hold.it/15/008c99/008c99?text=+) | `#008c99` | cyan |
-| ![#d11500](https://place-hold.it/15/d11500/d11500?text=+) | `#d11500` | red |
-| ![#997b00](https://place-hold.it/15/997b00/997b00?text=+) | `#997b00` | yellow |
-| ![#d100bf](https://place-hold.it/15/d100bf/d100bf?text=+) | `#d100bf` | magenta |
-| ![#f40064](https://place-hold.it/15/f40064/f40064?text=+) | `#f40064` | pink |
-| ![#d17c00](https://place-hold.it/15/d17c00/d17c00?text=+) | `#d17c00` | orange |
-| ![#a018ff](https://place-hold.it/15/a018ff/a018ff?text=+) | `#a018ff` | purple |
+| ![#16181a](https://place-hold.it/15/16181a/16181a?text=+) | `#16181a` | fg |
+| ![#7b8496](https://place-hold.it/15/7b8496/7b8496?text=+) | `#7b8496` | grey |
+| ![#0057d1](https://place-hold.it/15/0057d1/0057d1?text=+) | `#0057d1` | blue |
+| ![#008b0c](https://place-hold.it/15/008b0c/008b0c?text=+) | `#008b0c` | green |
+| ![#008c99](https://place-hold.it/15/008c99/008c99?text=+) | `#008c99` | cyan |
+| ![#d11500](https://place-hold.it/15/d11500/d11500?text=+) | `#d11500` | red |
+| ![#997b00](https://place-hold.it/15/997b00/997b00?text=+) | `#997b00` | yellow |
+| ![#d100bf](https://place-hold.it/15/d100bf/d100bf?text=+) | `#d100bf` | magenta |
+| ![#f40064](https://place-hold.it/15/f40064/f40064?text=+) | `#f40064` | pink |
+| ![#d17c00](https://place-hold.it/15/d17c00/d17c00?text=+) | `#d17c00` | orange |
+| ![#a018ff](https://place-hold.it/15/a018ff/a018ff?text=+) | `#a018ff` | purple |
diff --git a/lua/cyberdream/config.lua b/lua/cyberdream/config.lua
index dc59b81..58a27b3 100644
--- a/lua/cyberdream/config.lua
+++ b/lua/cyberdream/config.lua
@@ -13,15 +13,6 @@ local M = {}
---@alias CyberdreamOverrideFn fun(palette: CyberdreamPalette): CyberdreamHighlight
----@class ThemeConfig
----@field variant? "default" | "light" | "auto"
----@field saturation? number
----@field colors? CyberdreamPalette
----@field highlights? table
----@field overrides? CyberdreamOverrideFn
-
----@alias CyberdreamTelescopeStyle "nvchad" | "flat"
-
---@class extensions
---@field alpha? boolean
---@field blinkcmp? boolean
@@ -55,29 +46,30 @@ local M = {}
---@class Config
---@field transparent? boolean
+---@field variant? "default" | "light" | "auto"
+---@field saturation? number
+---@field colors? CyberdreamPalette
+---@field highlights? table
+---@field overrides? CyberdreamOverrideFn
---@field italic_comments? boolean
---@field hide_fillchars? boolean
----@field borderless_telescope? boolean | { border: boolean, style: CyberdreamTelescopeStyle }
+---@field borderless_pickers? boolean
---@field terminal_colors? boolean
---@field cache? boolean
----@field theme? ThemeConfig
---@field extensions? extensions
local default_options = {
transparent = false,
+ variant = "default",
+ saturation = 1,
+ ---@diagnostic disable-next-line: missing-fields
+ colors = {},
+ highlights = {},
italic_comments = false,
hide_fillchars = false,
- borderless_telescope = true,
+ borderless_pickers = false,
terminal_colors = true,
cache = false,
- theme = {
- variant = "default",
- saturation = 1,
- ---@diagnostic disable-next-line: missing-fields
- colors = {},
- highlights = {},
- },
-
extensions = {
alpha = true,
blinkcmp = true,
diff --git a/lua/cyberdream/extensions/fzflua.lua b/lua/cyberdream/extensions/fzflua.lua
index cd1eae6..1efd2f2 100644
--- a/lua/cyberdream/extensions/fzflua.lua
+++ b/lua/cyberdream/extensions/fzflua.lua
@@ -21,7 +21,7 @@ function M.get(opts, t)
FzfLuaFzfInfo = { fg = t.cyan },
}
- if not opts.borderless_telescope then
+ if not opts.borderless_pickers then
highlights.FzfLuaNormal.bg = t.bg
highlights.FzfLuaPreviewNormal.bg = t.bg
highlights.FzfLuaBorder = { link = "FloatBorder" }
diff --git a/lua/cyberdream/extensions/grapple.lua b/lua/cyberdream/extensions/grapple.lua
index b561d81..30adb1e 100644
--- a/lua/cyberdream/extensions/grapple.lua
+++ b/lua/cyberdream/extensions/grapple.lua
@@ -12,7 +12,7 @@ function M.get(opts, t)
}
-- Inherit borderless theme from telescope (if enabled)
- if opts.borderless_telescope then
+ if opts.borderless_pickers then
highlights.GrappleNormal = { bg = t.bg_alt }
highlights.GrappleBorder = { fg = t.bg_alt, bg = t.bg_alt }
highlights.GrappleTitle = { fg = t.bg_alt, bg = t.cyan }
diff --git a/lua/cyberdream/extensions/snacks.lua b/lua/cyberdream/extensions/snacks.lua
index d1dbaa5..0ede89c 100644
--- a/lua/cyberdream/extensions/snacks.lua
+++ b/lua/cyberdream/extensions/snacks.lua
@@ -56,7 +56,7 @@ function M.get(opts, t)
SnacksPickerPrompt = { fg = t.blue, bold = true },
}
- if opts.borderless_telescope then
+ if opts.borderless_pickers then
highlights.SnacksPickerBorder = { fg = t.bg_alt, bg = t.bg_alt }
highlights.SnacksPickerNormal = { bg = t.bg_alt }
highlights.SnacksPickerBox = { bg = t.bg_alt }
diff --git a/lua/cyberdream/extensions/telescope.lua b/lua/cyberdream/extensions/telescope.lua
index 4b88a4c..1175123 100644
--- a/lua/cyberdream/extensions/telescope.lua
+++ b/lua/cyberdream/extensions/telescope.lua
@@ -65,7 +65,7 @@ function M.get(opts, t)
TelescopeResultsDiffUntracked = { link = "NonText" },
}
- if opts.borderless_telescope then
+ if opts.borderless_pickers then
highlights.TelescopeBorder = { fg = t.bg_alt, bg = t.bg_alt }
highlights.TelescopeNormal = { bg = t.bg_alt }
highlights.TelescopePreviewBorder = { fg = t.bg_alt, bg = t.bg_alt }
diff --git a/lua/cyberdream/init.lua b/lua/cyberdream/init.lua
index 3220e5b..b54b7b6 100644
--- a/lua/cyberdream/init.lua
+++ b/lua/cyberdream/init.lua
@@ -33,7 +33,7 @@ end, {})
vim.api.nvim_create_autocmd("OptionSet", {
pattern = "background",
callback = function()
- if vim.g.cyberdream_opts.theme.variant ~= "auto" or vim.fn.execute("colorscheme"):find("cyberdream") == nil then
+ if vim.g.cyberdream_opts.variant ~= "auto" or vim.fn.execute("colorscheme"):find("cyberdream") == nil then
return
end
util.toggle_lualine_theme()
diff --git a/lua/cyberdream/theme.lua b/lua/cyberdream/theme.lua
index 31061db..8db761f 100644
--- a/lua/cyberdream/theme.lua
+++ b/lua/cyberdream/theme.lua
@@ -9,12 +9,12 @@ function M.setup()
local theme = {}
---@type CyberdreamPalette
local t = colors.default
- if opts.theme.variant == "light" then
+ if opts.variant == "light" then
---@type CyberdreamPalette
t = colors.light
end
- if opts.theme.variant == "auto" then
+ if opts.variant == "auto" then
if vim.o.background == "light" then
---@type CyberdreamPalette
t = colors.light
@@ -22,11 +22,11 @@ function M.setup()
end
-- Apply user defined saturation
- t = util.apply_saturation(t, opts.theme.saturation)
+ t = util.apply_saturation(t, opts.saturation)
-- Override colors with user defined colors
---@type CyberdreamPalette
- t = vim.tbl_deep_extend("force", t, opts.theme.colors)
+ t = vim.tbl_deep_extend("force", t, opts.colors)
t.bg_solid = t.bg ~= "NONE" and t.bg or t.bg_alt
if opts.transparent then
@@ -89,7 +89,7 @@ function M.setup()
end
-- Parse user defined overrides and apply them
- local overrides = opts.theme.overrides or opts.theme.highlights
+ local overrides = opts.overrides or opts.highlights
if type(overrides) == "function" then
overrides = overrides(t)
end
diff --git a/lua/cyberdream/util.lua b/lua/cyberdream/util.lua
index 3e1cd99..422789d 100644
--- a/lua/cyberdream/util.lua
+++ b/lua/cyberdream/util.lua
@@ -229,15 +229,15 @@ end
function M.toggle_theme_variant()
local opts = vim.g.cyberdream_opts
-- Handle the "auto" variant without overwriting the value in opts.
- if opts.theme.variant == "auto" then
+ if opts.variant == "auto" then
return M.toggle_theme_auto()
end
- opts.theme.variant = opts.theme.variant == "default" and "light" or "default"
+ opts.variant = opts.variant == "default" and "light" or "default"
M.set_options(opts)
M.apply_options(opts)
- return opts.theme.variant
+ return opts.variant
end
--- Used for toggling the theme variant when the variant is set to "auto". Uses the 'set background' command to toggle between 'light' and 'dark'.
diff --git a/lua/lualine/themes/cyberdream.lua b/lua/lualine/themes/cyberdream.lua
index 46ba9a1..646e4cf 100644
--- a/lua/lualine/themes/cyberdream.lua
+++ b/lua/lualine/themes/cyberdream.lua
@@ -2,11 +2,11 @@
local colors = require("cyberdream.colors").default
local opts = require("cyberdream.config").options
-if opts.theme.variant == "light" then
+if opts.variant == "light" then
colors = require("cyberdream.colors").light
end
-if opts.theme.variant == "auto" then
+if opts.variant == "auto" then
if vim.o.background == "light" then
colors = require("cyberdream.colors").light
end