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 11 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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ require 'nordic' .setup {
-- Enable bold keywords.
bold_keywords = false,
-- Enable italic comments.
italic_comments = true,
-- Enable general editor background transparency.
transparent_bg = false,
italic_comments = true, -- 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
14 changes: 7 additions & 7 deletions lua/nordic/colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function C.extend_palette()
-- Some of the format is from @folke/tokyonight.nvim.

-- Backgrounds
C.bg = (options.transparent_bg and C.none) or ((options.swap_backgrounds and C.black1) or C.gray0)
C.bg_dark = (options.transparent_bg and C.none) or C.black0
C.bg_sidebar = (options.transparent_bg and C.none) or C.bg
C.bg_popup = (options.transparent_bg and C.none) or C.bg
C.bg = (options.transparent.bg and C.none) or ((options.swap_backgrounds and C.black1) or C.gray0)
C.bg_dark = (options.transparent.bg and C.none) or C.black0
C.bg_sidebar = (options.transparent.bg and C.none) or C.bg
C.bg_popup = (options.transparent.float and C.none) or C.bg
C.bg_statusline = C.black0
C.bg_selected = U.blend(C.gray2, C.black0, 0.4)
C.bg_fold = C.gray2
Expand All @@ -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 All @@ -60,7 +60,7 @@ function C.extend_palette()
C.fg_popup_border = C.border_fg

-- Floating windows
C.bg_float = (options.transparent_bg and C.none) or ((options.swap_backgrounds and C.gray0) or C.black1)
C.bg_float = (options.transparent.float and C.none) or ((options.swap_backgrounds and C.gray0) or C.black1)
C.fg_float = C.fg
C.bg_float_border = C.bg_float
C.fg_float_border = C.border_fg
Expand Down
23 changes: 23 additions & 0 deletions lua/nordic/compatibility.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local function compatability(options)
-- All backwards compatibility

-- Log level
local level = vim.log.levels.WARN
-- Message Options
local message_options = {
title = 'Warning from nordic.nvim',
}

-- transparent_bg
if options.transparent_bg ~= nil then
vim.notify_once('Nordic.nvim: config.transparent_bg is deprecated, use config.transparent instead', level, message_options)
options.transparent = {
bg = options.transparent_bg,
float = options.transparent_bg,
}
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