Skip to content

Commit

Permalink
refactor(config): change the floating window style logic (#156)
Browse files Browse the repository at this point in the history
* refactor(telescope): rework config styling logic

* refactor(base): change floating window style logic

* chore: ignore doc folder for typos

---------

Co-authored-by: Micah Halter <[email protected]>
  • Loading branch information
A-Lamia and mehalter authored Jan 2, 2025
1 parent 7aa05c0 commit 701e3bd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ba = "ba"
aadd = "aadd"

[files]
extend-exclude = ["CHANGELOG.md"]
extend-exclude = ["CHANGELOG.md", "doc/*"]
34 changes: 17 additions & 17 deletions lua/astrotheme/groups/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
local function callback(c, opts)
local color = require "astrotheme.lib.color"
local base = color.new(c.ui.base)

local float_bg = (opts.border and opts.float and opts.inactive and c.ui.float)
or (opts.border and opts.float and opts.transparent and c.ui.base)
or (opts.border and opts.float and c.ui.float)
or (opts.border and opts.inactive and c.ui.base)
or (opts.border and opts.transparent and c.none)
or (opts.float and c.ui.float)
or (opts.inactive and c.ui.base)
or (opts.border and c.ui.base)
or c.ui.base

return {
--------------------
--- Normal
Expand All @@ -20,32 +31,21 @@ local function callback(c, opts)
--------------------
FloatTitle = {
fg = (opts.title_invert and c.ui.tool) or c.ui.title,
bg = (opts.title_invert and c.ui.title)
or (opts.inactive and c.ui.float)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
bg = (opts.title_invert and c.ui.title) or float_bg,
bold = true,
},
FloatBorder = {
fg = (opts.border and opts.float and c.ui.border)
or (opts.transparent and opts.float and c.ui.base)
or (opts.border and opts.inactive and c.ui.border)
or (opts.float and c.ui.float)
or (opts.transparent and c.ui.base)
or (opts.border and c.ui.border)
or c.ui.base,
bg = (opts.inactive and c.ui.float)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
bg = float_bg,
},
NormalFloat = {
fg = c.ui.text,
bg = (opts.inactive and c.ui.float)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
bg = float_bg,
},

--------------------
Expand Down
68 changes: 22 additions & 46 deletions lua/astrotheme/groups/plugins/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
---@type AstroThemeCallback
local function callback(c, opts)
local title = {
fg = (opts.title_invert and c.ui.float) or c.ui.title,
bg = (opts.title_invert and c.ui.title)
or (opts.inactive and c.ui.base)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
bold = true,
}

local normal = {
fg = c.ui.text,
bg = (opts.inactive and c.ui.base)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
}

local border = {
fg = (opts.border and c.ui.border) or (opts.inactive and c.ui.base) or (opts.float and c.ui.float) or c.ui.base,
bg = (opts.border and opts.inactive and c.ui.base)
or (opts.transparent and opts.float and c.ui.base)
or (opts.float and c.ui.float)
or (opts.transparent and c.none)
or c.ui.base,
}
local prompt_bg = (opts.border and opts.float and opts.inactive and c.ui.float)
or (opts.border and opts.float and opts.transparent and c.ui.base)
or (opts.border and opts.float and c.ui.float)
or (opts.border and opts.inactive and c.ui.base)
or (opts.border and opts.transparent and c.none)
or (opts.border and c.ui.base)
or c.ui.prompt

return {
----------------
Expand All @@ -36,14 +15,11 @@ local function callback(c, opts)

TelescopePromptTitle = {
fg = (opts.title_invert and c.ui.float) or c.ui.title,
bg = (opts.title_invert and c.ui.title)
or (opts.float and c.ui.prompt)
or (opts.transparent and c.none)
or c.ui.base,
bg = (opts.title_invert and c.ui.title) or prompt_bg,
bold = true,
},
TelescopeResultsTitle = title,
TelescopePreviewTitle = title,
TelescopeResultsTitle = { link = "FloatTitle" },
TelescopePreviewTitle = { link = "FloatTitle" },

-- TelescopeTitle = "FloatTitle",
-- TelescopePromptTitle = "TelescopeTitle",
Expand All @@ -56,15 +32,10 @@ local function callback(c, opts)

TelescopePromptNormal = {
fg = c.ui.text,
bg = (opts.border and opts.inactive and c.ui.base)
or (opts.border and opts.float and c.ui.base)
or (opts.inactive and c.ui.prompt)
or (opts.float and c.ui.prompt)
or (opts.transparent and c.none)
or c.ui.base,
bg = prompt_bg,
},
TelescopeResultsNormal = normal,
TelescopePreviewNormal = normal,
TelescopeResultsNormal = { link = "NormalFloat" },
TelescopePreviewNormal = { link = "NormalFloat" },

-- TelescopeNormal = "NormalFloat",
-- TelescopePromptNormal = "TelescopeNormal",
Expand All @@ -76,11 +47,16 @@ local function callback(c, opts)
----------------

TelescopePromptBorder = {
fg = (opts.border and c.ui.border) or (opts.inactive and c.ui.base) or (opts.float and c.ui.prompt) or c.ui.base,
bg = (opts.border and opts.inactive and c.ui.base) or (opts.float and c.ui.prompt) or c.ui.prompt,
fg = (opts.border and opts.float and c.ui.border)
or (opts.border and opts.inactive and c.ui.border)
or (opts.border and opts.transparent and c.ui.base)
or (opts.border and c.ui.border)
or c.ui.prompt,
bg = prompt_bg,
},
TelescopeResultsBorder = border,
TelescopePreviewBorder = border,
-- TelescopePromptBorder = border,
TelescopeResultsBorder = { link = "FloatBorder" },
TelescopePreviewBorder = { link = "FloatBorder" },

-- TelescopeBorder = "FloatBorder",
-- TelescopePromptBorder = "TelescopeBorder",
Expand Down

0 comments on commit 701e3bd

Please sign in to comment.