Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transparency)!: add decoupled transparency options; #127

Merged
merged 13 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ require 'nordic' .setup {
bold_keywords = false,
-- Enable italic comments.
italic_comments = true,
-- Enable general editor background transparency.
transparent_bg = false,
-- Enable editor background transparency.
transparent = {
-- Enable transparent background.
bg = false,
-- Enable transparent background for floating windows.
float = false,
},
-- Enable brighter float border.
bright_border = false,
-- Reduce the overall amount of blue in the theme (diverges from base Nord).
Expand Down
4 changes: 2 additions & 2 deletions lua/nordic/colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function C.extend_palette()
options.cursorline.bg = C.black0
end

C.bg_visual = (options.transparent_bg and options.cursorline.bg)
C.bg_visual = ((options.transparent.bg or options.transparent.float) and options.cursorline.bg)
AlexvZyl marked this conversation as resolved.
Show resolved Hide resolved
or U.blend(options.cursorline.bg, C.bg, options.cursorline.blend)

-- Borders
C.border_fg = (options.bright_border and C.white0) or C.black0
C.border_bg = (options.transparent_bg and C.none) or C.bg
C.border_bg = (options.transparent.bg and C.none) or C.bg

-- Foregrounds
C.fg = C.white0
Expand Down
20 changes: 20 additions & 0 deletions lua/nordic/compatibility.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local function compatability(options)
-- All backwards compatibility

-- Log level
local level = vim.log.levels.WARN

if options.transparent_bg then
vim.notify('Nordic.nvim: transparent_bg is deprecated, use transparent instead', level)
AlexvZyl marked this conversation as resolved.
Show resolved Hide resolved
if not options.transparent then
options.transparent = {
bg = true,
float = true,
}
end
end

return options
end

return compatability
13 changes: 11 additions & 2 deletions lua/nordic/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ local defaults = {
bold_keywords = false,
-- Enable italic comments.
italic_comments = true,
-- Enable general editor background transparency.
transparent_bg = false,
-- Enable editor background transparency.
transparent = {
-- Enable transparent background.
bg = false,
-- Enable transparent background for floating windows.
float = false,
},
-- Enable brighter float border.
bright_border = false,
-- Adjusts some colors to make the theme a bit nicer (imo).
Expand Down Expand Up @@ -52,6 +57,10 @@ M.options = defaults

-- called automatically by load
function M.setup(options)
-- backwards compatibility
options = require('nordic.compatibility')(options)

-- set defaults
M.options = vim.tbl_deep_extend('force', M.options or defaults, options or {})
end

Expand Down
3 changes: 2 additions & 1 deletion lua/nordic/tests/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ end
-- Flip all fields
config.bold_keywords = not config.bold_keywords
config.italic_comments = not config.italic_comments
config.transparent_bg = not config.transparent_bg
config.transparent.bg = not config.transparent.bg
config.transparent.float = not config.transparent.float
config.bright_border = not config.bright_border
config.reduced_blue = not config.reduced_blue
config.swap_backgrounds = not config.swap_backgrounds
Expand Down
Loading