Skip to content

Commit

Permalink
feat(config)!: replace theme and borderless_telescope options
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmckendry committed Feb 6, 2025
1 parent 893edb0 commit c43a6c4
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 92 deletions.
117 changes: 60 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,54 +138,57 @@ 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,

-- 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
Expand Down Expand Up @@ -263,44 +266,44 @@ vim.api.nvim_create_autocmd("User", {
<details>
<summary><b>Dark</b></summary>

| 🖌 | 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 |

</details>

<details>
<summary><b>Light</b></summary>

| 🖌 | 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 |

</details>

Expand Down
32 changes: 12 additions & 20 deletions lua/cyberdream/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, CyberdreamHighlight>
---@field overrides? CyberdreamOverrideFn

---@alias CyberdreamTelescopeStyle "nvchad" | "flat"

---@class extensions
---@field alpha? boolean
---@field blinkcmp? boolean
Expand Down Expand Up @@ -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<string, CyberdreamHighlight>
---@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,
Expand Down
2 changes: 1 addition & 1 deletion lua/cyberdream/extensions/fzflua.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion lua/cyberdream/extensions/grapple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lua/cyberdream/extensions/snacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lua/cyberdream/extensions/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lua/cyberdream/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions lua/cyberdream/theme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ 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
end
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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lua/cyberdream/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
4 changes: 2 additions & 2 deletions lua/lualine/themes/cyberdream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c43a6c4

Please sign in to comment.