-
-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Move config into separate file - Deprecate `bold_vert_split` in favor of `highlight_groups = { VertSplit = { fg = 'highlight_med', bg = 'highlight_med' } }` - Deprecate `dim_nc_background` in favor of `highlight_groups = { NormalNC = { fg = 'text', bg = 'surface' } }`
- Loading branch information
Showing
4 changed files
with
623 additions
and
600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,22 @@ | ||
local util = require('rose-pine.util') | ||
|
||
local config = require('rose-pine.config') | ||
local M = {} | ||
|
||
local config = { | ||
bold_vert_split = false, | ||
dark_variant = 'main', | ||
dim_nc_background = false, | ||
disable_background = false, | ||
disable_float_background = false, | ||
disable_italics = false, | ||
|
||
groups = { | ||
background = 'base', | ||
panel = 'surface', | ||
border = 'highlight_med', | ||
comment = 'muted', | ||
link = 'iris', | ||
punctuation = 'muted', | ||
|
||
error = 'love', | ||
hint = 'iris', | ||
info = 'foam', | ||
warn = 'gold', | ||
|
||
git_add = 'foam', | ||
git_change = 'rose', | ||
git_delete = 'love', | ||
git_dirty = 'rose', | ||
git_ignore = 'muted', | ||
git_merge = 'iris', | ||
git_rename = 'pine', | ||
git_stage = 'iris', | ||
git_text = 'rose', | ||
|
||
headings = { | ||
h1 = 'iris', | ||
h2 = 'foam', | ||
h3 = 'rose', | ||
h4 = 'gold', | ||
h5 = 'pine', | ||
h6 = 'foam', | ||
}, | ||
}, | ||
highlight_groups = {}, | ||
} | ||
|
||
function M.setup(opts) | ||
opts = opts or {} | ||
vim.g.rose_pine_variant = opts.dark_variant or 'main' | ||
|
||
if opts.groups and type(opts.groups.headings) == 'string' then | ||
opts.groups.headings = { | ||
h1 = opts.groups.headings, | ||
h2 = opts.groups.headings, | ||
h3 = opts.groups.headings, | ||
h4 = opts.groups.headings, | ||
h5 = opts.groups.headings, | ||
h6 = opts.groups.headings, | ||
} | ||
---@param options Config|nil | ||
function M.colorscheme(options) | ||
if options then | ||
config.extend(options) | ||
end | ||
|
||
config.user_variant = opts.dark_variant or nil | ||
config = vim.tbl_deep_extend('force', config, opts) | ||
end | ||
|
||
function M.colorscheme() | ||
if vim.g.colors_name then | ||
vim.cmd('hi clear') | ||
end | ||
|
||
vim.opt.termguicolors = true | ||
vim.g.colors_name = 'rose-pine' | ||
|
||
local theme = require('rose-pine.theme').get(config) | ||
|
||
-- Set theme highlights | ||
for group, color in pairs(theme) do | ||
-- Skip highlight group if user overrides | ||
if config.highlight_groups[group] == nil then | ||
util.highlight(group, color) | ||
end | ||
end | ||
|
||
-- Set user highlights | ||
for group, color in pairs(config.highlight_groups) do | ||
util.highlight(group, color) | ||
end | ||
require('rose-pine.theme')._load(config.options) | ||
end | ||
|
||
M.setup = config.setup | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
local M = {} | ||
|
||
---@class Groups | ||
---@field background string | ||
---@field panel string | ||
---@field border string | ||
---@field comment string | ||
---@field link string | ||
---@field punctuation string | ||
---@field error string | ||
---@field hint string | ||
---@field info string | ||
---@field warn string | ||
---@field git_add string | ||
---@field git_change string | ||
---@field git_delete string | ||
---@field git_dirty string | ||
---@field git_ignore string | ||
---@field git_merge string | ||
---@field git_rename string | ||
---@field git_stage string | ||
---@field git_text string | ||
---@field headings Headings|string | ||
|
||
---@class Headings | ||
---@field h1 string | ||
---@field h2 string | ||
---@field h3 string | ||
---@field h4 string | ||
---@field h5 string | ||
---@field h6 string | ||
|
||
---@class Config | ||
---@field dark_variant 'main'|'moon' | ||
---@field disable_background boolean | ||
---@field disable_float_background boolean | ||
---@field disable_italics boolean | ||
---@field groups Groups | ||
---@field highlight_groups table<string, any> | ||
local defaults = { | ||
dark_variant = 'main', | ||
disable_background = false, | ||
disable_float_background = false, | ||
disable_italics = false, | ||
highlight_groups = {}, | ||
|
||
---@deprecated Use `highlight_groups = { VertSplit = { fg = 'highlight_med', bg = 'highlight_med' } }` instead. | ||
bold_vert_split = false, | ||
---@deprecated Use `highlight_groups = { NormalNC = { fg = 'text', bg = 'surface' } }` instead. | ||
dim_nc_background = false, | ||
|
||
groups = { | ||
background = 'base', | ||
panel = 'surface', | ||
border = 'highlight_med', | ||
comment = 'muted', | ||
link = 'iris', | ||
punctuation = 'muted', | ||
error = 'love', | ||
hint = 'iris', | ||
info = 'foam', | ||
warn = 'gold', | ||
git_add = 'foam', | ||
git_change = 'rose', | ||
git_delete = 'love', | ||
git_dirty = 'rose', | ||
git_ignore = 'muted', | ||
git_merge = 'iris', | ||
git_rename = 'pine', | ||
git_stage = 'iris', | ||
git_text = 'rose', | ||
headings = { | ||
h1 = 'iris', | ||
h2 = 'foam', | ||
h3 = 'rose', | ||
h4 = 'gold', | ||
h5 = 'pine', | ||
h6 = 'foam', | ||
}, | ||
}, | ||
} | ||
|
||
---@type Config | ||
M.options = {} | ||
|
||
---@param options Config|nil | ||
function M.setup(options) | ||
M.options = vim.tbl_deep_extend('force', {}, defaults, options or {}) | ||
end | ||
|
||
---@param options Config|nil | ||
function M.extend(options) | ||
M.options = | ||
vim.tbl_deep_extend('force', {}, M.options or defaults, options or {}) | ||
end | ||
|
||
M.setup() | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.