Skip to content

Commit

Permalink
Merge pull request #19 from pauchiner/feature/high-contrast-theme
Browse files Browse the repository at this point in the history
Add high contrast theme variant
  • Loading branch information
pauchiner authored Feb 14, 2024
2 parents 0761fae + c463761 commit 2bc28b7
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 22 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ First install the theme with your preferred package manager:

```vim
colorscheme pastelnight
" There are also a theme variant with greater contrast
colorscheme pastelnight-high-contrast
```
##### Lua

```lua
vim.api.nvim_command [[colorscheme pastelnight]]

-- There are also a theme variant with greater contrast
vim.api.nvim_command [[colorscheme pastelnight-high-contrast]]
```

#### 🔌 Other supported plugins
Expand Down Expand Up @@ -141,6 +147,9 @@ let g:lightline = {'colorscheme': 'pastelnight'}
```lua
require("pastelnight").setup({

--- The theme comes in two styles, `default` and `highContrast`.
style = "default"

--- Enable this to disable setting the background color.
transparent = false,

Expand Down
1 change: 1 addition & 0 deletions colors/pastelnight-high-contrast.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("pastelnight")._load("highContrast")
2 changes: 1 addition & 1 deletion colors/pastelnight.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require("pastelnight").load()
require("pastelnight")._load()
72 changes: 70 additions & 2 deletions lua/pastelnight/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,81 @@ M.default = {
green400 = hsl(137, 047, 52),
}

M.highContrast = function()
local ret = {
none = 'NONE',

base = hsl(220, 100, 99),
base50 = hsl(220, 007, 91),
base100 = hsl(231, 005, 74),
base200 = hsl(235, 006, 68),
base300 = hsl(232, 007, 45),
base400 = hsl(233, 008, 32),

base500 = hsl(234, 018, 20),
base600 = hsl(233, 020, 13),
base700 = hsl(232, 021, 10),
base800 = hsl(235, 021, 07),
base900 = hsl(234, 024, 04),

yellow50 = hsl(039, 100, 86),
yellow100 = hsl(039, 100, 80),
yellow200 = hsl(039, 100, 67),
yellow300 = hsl(039, 067, 61),
yellow400 = hsl(039, 047, 52),

orange50 = hsl(019, 100, 86),
orange100 = hsl(019, 100, 76),
orange200 = hsl(019, 100, 62),
orange300 = hsl(019, 070, 56),
orange400 = hsl(019, 055, 48),

red50 = hsl(000, 100, 86),
red100 = hsl(000, 100, 76),
red200 = hsl(000, 100, 62),
red300 = hsl(000, 070, 56),
red400 = hsl(000, 055, 48),

pink50 = hsl(318, 100, 92),
pink100 = hsl(318, 100, 86),
pink200 = hsl(318, 100, 77),
pink300 = hsl(318, 058, 69),
pink400 = hsl(318, 038, 59),

purple50 = hsl(272, 053, 88),
purple100 = hsl(272, 051, 79),
purple200 = hsl(272, 050, 67),
purple300 = hsl(272, 033, 61),
purple400 = hsl(272, 024, 52),

blue50 = hsl(221, 100, 90),
blue100 = hsl(221, 100, 83),
blue200 = hsl(221, 100, 72),
blue300 = hsl(221, 063, 65),
blue400 = hsl(221, 042, 56),

sky50 = hsl(191, 100, 91),
sky100 = hsl(191, 100, 84),
sky200 = hsl(191, 100, 72),
sky300 = hsl(191, 063, 65),
sky400 = hsl(191, 043, 55),

green50 = hsl(137, 100, 90),
green100 = hsl(137, 100, 81),
green200 = hsl(137, 100, 67),
green300 = hsl(137, 067, 61),
green400 = hsl(137, 047, 52),
}
return ret
end

---@return ColorScheme
function M.setup(opts)
local config = require('pastelnight.config')
opts = opts or {}

local palette = M['default'] or {}
local style = config.options.style
local palette = M[style] or {}
if type(palette) == 'function' then
palette = palette()
end
Expand All @@ -96,7 +165,6 @@ function M.setup(opts)
colors.fg = colors.base

util.bg = colors.bg
util.day_brightness = config.options.day_brightness

colors.black = util.darken(colors.bg, 0.8, '#000000')
colors.border = colors.black
Expand Down
46 changes: 28 additions & 18 deletions lua/pastelnight/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,39 @@ local M = {}
---@field on_colors fun(colors: ColorScheme)
---@field on_highlights fun(highlights: Highlights, colors: ColorScheme)
local defaults = {
style = 'storm', -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
light_style = 'day', -- The theme is used when the background is set to light
transparent = false, -- Enable this to disable setting the background color
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim
--- The theme comes in two styles, `default` and `highContrast`.
style = 'default',

--- Enable this to disable setting the background color
transparent = false,

--- Configure the colors used when opening a `:terminal` in Neovim
terminal_colors = true,

--- Style to be applied to different syntax groups
--- Value is any valid attr-list value for `:help nvim_set_hl`
styles = {
-- Style to be applied to different syntax groups
-- Value is any valid attr-list value for `:help nvim_set_hl`
comments = { italic = true },
keywords = { italic = true },
functions = {},
variables = {},

-- Background styles. Can be "dark", "transparent" or "normal"
sidebars = 'normal', -- style for sidebars, see below
floats = 'dark', -- style for floating windows
sidebars = 'normal',
floats = 'dark',
},
sidebars = { 'qf', 'help' }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors
hide_inactive_statusline = false, -- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold

--- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]`
sidebars = { 'qf', 'help' },

--- Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**.
hide_inactive_statusline = false,

--- Dims inactive windows.
dim_inactive = false,

--- When `true`, section headers in the lualine theme will be bold.
lualine_bold = false,

--- You can override specific color groups to use other groups or a hex color
--- function will be called with a ColorScheme table
Expand All @@ -37,7 +50,8 @@ local defaults = {
---@param colors ColorScheme
---@diagnostic disable-next-line: unused-local
on_highlights = function(highlights, colors) end,
use_background = true, -- can be light/dark/auto. When auto, background will be set to vim.o.background

use_background = true,
}

---@type Config
Expand All @@ -54,10 +68,6 @@ function M.extend(options)
M.options = vim.tbl_deep_extend('force', {}, M.options or defaults, options or {})
end

function M.is_day()
return M.options.style == 'day' or M.options.use_background and vim.o.background == 'light'
end

M.setup()

return M
12 changes: 12 additions & 0 deletions lua/pastelnight/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ local config = require('pastelnight.config')

local M = {}

function M._load(style)
if style and not M._style then
M._style = require('pastelnight.config').options.style
end
if not style and M._style then
---@diagnostic disable-next-line: inject-field
require('pastelnight.config').options.style = M._style
M._style = nil
end
M.load({ style = style, use_background = style == nil })
end

---@param opts Config|nil
function M.load(opts)
if opts then
Expand Down
1 change: 0 additions & 1 deletion lua/pastelnight/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ local M = {}

M.bg = '#000000'
M.fg = '#ffffff'
M.day_brightness = 0.3

---@param c string
local function hexToRgb(c)
Expand Down

0 comments on commit 2bc28b7

Please sign in to comment.