Skip to content

Change border_style to a more adaptable border_style with options #174

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ require('nordic').setup({
-- Enable transparent background for floating windows.
float = false,
},
-- Enable brighter float border.
bright_border = false,
-- Options: "flat", "bright", "default"
border_style = 'default',
-- Reduce the overall amount of blue in the theme (diverges from base Nord).
reduced_blue = true,
-- Swap the dark background with the normal one.
Expand Down
4 changes: 2 additions & 2 deletions doc/nordic.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ default configuration.
-- Enable transparent background for floating windows.
float = false,
},
-- Enable brighter float border.
bright_border = false,
-- Options: "flat", "bright", "default"
border_style = 'default',
-- Reduce the overall amount of blue in the theme (diverges from base Nord).
reduced_blue = true,
-- Swap the dark background with the normal one.
Expand Down
8 changes: 6 additions & 2 deletions lua/nordic/colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ function C.build_palette()
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_fg = (options.border_style == 'bright' and C.white0)
or options.border_style == 'default' and C.black0
or options.border_style == 'flat' and C.border_bg
C.border_bg = (options.transparent.bg and C.none) or C.bg

-- Foregrounds
Expand All @@ -61,7 +63,9 @@ function C.build_palette()
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
C.fg_float_border = options.border_style == 'bright' and C.white0
or options.border_style == 'default' and C.black0
or options.border_style == 'flat' and C.bg_float_border
Comment on lines +66 to +68
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
C.fg_float_border = options.border_style == 'bright' and C.white0
or options.border_style == 'default' and C.black0
or options.border_style == 'flat' and C.bg_float_border
C.fg_float_border = options.border_style == 'flat' and C.bg_float_border or C.border_f


-- Popups
C.bg_popup = C.bg_float
Expand Down
4 changes: 2 additions & 2 deletions lua/nordic/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ local defaults = {
-- Enable transparent background for floating windows.
float = false,
},
-- Enable brighter float border.
bright_border = false,
-- Options: "flat", "bright", "default"
border_style = 'default',
-- Reduce the overall amount of blue in the theme (diverges from base Nord).
reduced_blue = true,
-- Swap the dark background with the normal one.
Expand Down
2 changes: 1 addition & 1 deletion lua/nordic/groups/native.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function M.get_groups()
-- TermCursorNC= { } -- cursor in an unfocused terminal
G.ErrorMsg = { fg = C.error } -- error messages on the command line
G.VertSplit = { fg = C.border_fg } -- the column separating vertically split windows
G.WinSeparator = { fg = C.border_fg, bg = C.border_bg } -- the column separating vertically split windows
G.WinSeparator = { fg = O.border_style == 'bright' and C.white0 or C.black0, bg = C.border_bg } -- the column separating vertically split windows
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me this change isn't necessary, since border_fg will change based on the border_style already.

The only difference being that when border_style=flat there would be no visible separator between splits, which seems to me at least to fit with the "flat" style.

G.Folded = { fg = C.fg_fold, bg = C.bg_fold } -- line used for closed folds
G.FoldColumn = { bg = C.bg_fold, fg = C.fg_fold } -- 'foldcolumn'
G.SignColumn = { bg = C.bg_sidebar, fg = C.fg_sidebar } -- column where |signs| are displayed
Expand Down
16 changes: 11 additions & 5 deletions lua/nordic/tests/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,26 @@ assert_eq(
)
load({ transparent = { float = false } })

-- bright_border
-- border_style
assert_eq(
get_highlight('WinSeparator').fg,
base_palette.black0,
'bright_border: all highlights that use `border_fg` should be `black0` by default'
'border_style: all highlights that use `border_fg` should be `black0` if `border_style` is `default`'
)
load({ bright_border = true })
load({ border_style = 'flat' })
assert_eq(
get_highlight('VertSplit').fg,
base_palette.gray0,
'border_style: all highlights that use `border_fg` should be `gray0` if `border_style` is `flat`'
)
load({ border_style = 'bright' })
-- NOTE: This will fail if the wrong white0 variant is used
assert_eq(
get_highlight('WinSeparator').fg,
base_palette.white0_reduce_blue,
'bright_border: all highlights that use `border_fg` should be `white0_reduce_blue` if `bright_border` is true'
'border_style: all highlights that use `border_fg` should be `white0_reduce_blue` if `border_style` is `bright`'
)
load({ bright_border = false })
load({ border_style = 'default' })

-- reduced_blue
assert_eq(
Expand Down