mirror of
https://github.com/rose-pine/neovim.git
synced 2025-10-15 12:38:53 +02:00
BREAKING!: rewrite config api and update styles
- move config to lua - use rose for search match - fix background flicker when automatically switching to dawn - remove unneeded highlights (please report regressions) - remove deprecated `LspDiagnostics*` - remove `LspReference*` - improve overall consistency between elements - non-treesitter updates to match treesitter styles - update popup menu scrollbar and selection - update telescope selection - match cursorcolumn to cursorline
This commit is contained in:
parent
1a3d0c279e
commit
b77bd8e7ce
9 changed files with 595 additions and 599 deletions
|
|
@ -1,5 +1,112 @@
|
|||
local palette = require('rose-pine.palette')
|
||||
|
||||
local M = {}
|
||||
|
||||
---@class RosePineConfig
|
||||
---@field variant 'main'|'moon'|'dawn'
|
||||
---@field bold_vert_split boolean
|
||||
---@field dim_nc_background boolean
|
||||
---@field disable_background boolean
|
||||
---@field disable_float_background boolean
|
||||
---@field disable_italics boolean
|
||||
---@field groups RosePineGroups
|
||||
|
||||
---@class RosePineGroups
|
||||
---@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 RosePineGit
|
||||
---@field headings string|RosePineHeadings
|
||||
|
||||
---@class RosePineGit
|
||||
---@field add string
|
||||
---@field change string
|
||||
---@field delete string
|
||||
---@field dirty string
|
||||
---@field ignore string
|
||||
---@field merge string
|
||||
---@field rename string
|
||||
---@field stage string
|
||||
---@field text string
|
||||
|
||||
---@class RosePineHeadings
|
||||
---@field h1 string
|
||||
---@field h2 string
|
||||
---@field h3 string
|
||||
---@field h4 string
|
||||
---@field h5 string
|
||||
---@field h6 string
|
||||
|
||||
---@type RosePineConfig
|
||||
local config = {}
|
||||
|
||||
---@param opts RosePineConfig
|
||||
function M.setup(opts)
|
||||
vim.g.rose_pine_variant = opts.variant or 'main'
|
||||
|
||||
local default_config = {
|
||||
variant = 'main',
|
||||
bold_vert_split = false,
|
||||
dim_nc_background = false,
|
||||
disable_background = false,
|
||||
disable_float_background = false,
|
||||
disable_italics = false,
|
||||
|
||||
groups = {
|
||||
border = 'highlight_med',
|
||||
comment = 'muted',
|
||||
link = 'iris',
|
||||
punctuation = 'subtle',
|
||||
|
||||
error = 'love',
|
||||
hint = 'iris',
|
||||
info = 'foam',
|
||||
warn = 'gold',
|
||||
|
||||
git = {
|
||||
add = 'foam',
|
||||
change = 'rose',
|
||||
delete = 'love',
|
||||
dirty = 'rose',
|
||||
ignore = 'muted',
|
||||
merge = 'iris',
|
||||
rename = 'pine',
|
||||
stage = 'iris',
|
||||
text = 'rose',
|
||||
},
|
||||
|
||||
headings = {
|
||||
h1 = 'iris',
|
||||
h2 = 'foam',
|
||||
h3 = 'rose',
|
||||
h4 = 'gold',
|
||||
h5 = 'pine',
|
||||
h6 = 'foam',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local groups = opts.groups or {}
|
||||
if type(groups.headings) == 'string' then
|
||||
groups.headings = {
|
||||
h1 = groups.headings,
|
||||
h2 = groups.headings,
|
||||
h3 = groups.headings,
|
||||
h4 = groups.headings,
|
||||
h5 = groups.headings,
|
||||
h6 = groups.headings,
|
||||
}
|
||||
end
|
||||
|
||||
config.user_variant = opts.variant or nil
|
||||
config = vim.tbl_deep_extend('force', default_config, opts)
|
||||
end
|
||||
|
||||
function M.colorscheme()
|
||||
if vim.g.colors_name then
|
||||
vim.cmd('hi clear')
|
||||
|
|
@ -8,20 +115,34 @@ function M.colorscheme()
|
|||
vim.opt.termguicolors = true
|
||||
vim.g.colors_name = 'rose-pine'
|
||||
|
||||
-- Match terminal theme if no variant is set
|
||||
if vim.g.rose_pine_variant == nil and vim.o.background == 'light' then
|
||||
vim.g.rose_pine_variant = 'dawn'
|
||||
elseif vim.g.rose_pine_variant == 'dawn' then
|
||||
-- match variant to vim background
|
||||
if config.user_variant == nil and vim.o.background == 'light' then
|
||||
config.variant = 'dawn'
|
||||
end
|
||||
|
||||
-- match vim background to variant
|
||||
if config.user_variant == 'main' or config.user_variant == 'moon' then
|
||||
vim.o.background = 'dark'
|
||||
elseif config.user_variant == 'dawn' then
|
||||
vim.o.background = 'light'
|
||||
end
|
||||
|
||||
---@param color string
|
||||
local function get_palette_color(color)
|
||||
if color and not color:find('#') then
|
||||
return palette[config.variant][color:lower()]
|
||||
end
|
||||
|
||||
return color:lower()
|
||||
end
|
||||
|
||||
---@param group string
|
||||
---@param color table<string, string>
|
||||
local function highlight(group, color)
|
||||
local style = color.style and 'gui=' .. color.style or 'gui=NONE'
|
||||
local fg = color.fg and 'guifg=' .. color.fg or 'guifg=NONE'
|
||||
local bg = color.bg and 'guibg=' .. color.bg or 'guibg=NONE'
|
||||
local sp = color.sp and 'guisp=' .. color.sp or ''
|
||||
local fg = color.fg and 'guifg=' .. get_palette_color(color.fg) or 'guifg=NONE'
|
||||
local bg = color.bg and 'guibg=' .. get_palette_color(color.bg) or 'guibg=NONE'
|
||||
local sp = color.sp and 'guisp=' .. get_palette_color(color.sp) or ''
|
||||
|
||||
local hl = 'highlight ' .. group .. ' ' .. style .. ' ' .. fg .. ' ' .. bg .. ' ' .. sp
|
||||
|
||||
|
|
@ -31,15 +152,16 @@ function M.colorscheme()
|
|||
end
|
||||
end
|
||||
|
||||
for group, colors in pairs(require('rose-pine.theme')) do
|
||||
highlight(group, colors)
|
||||
local theme = require('rose-pine.theme').get(config)
|
||||
for group, color in pairs(theme) do
|
||||
highlight(group, color)
|
||||
end
|
||||
|
||||
require('rose-pine.galaxyline.theme')
|
||||
end
|
||||
|
||||
function M.set(variant)
|
||||
vim.g.rose_pine_variant = variant
|
||||
config.variant = variant
|
||||
vim.cmd('colorscheme rose-pine')
|
||||
end
|
||||
|
||||
|
|
@ -52,7 +174,7 @@ function M.toggle(variants)
|
|||
end
|
||||
|
||||
if vim.g.rose_pine_current_variant == nil then
|
||||
vim.g.rose_pine_current_variant = index[vim.g.rose_pine_variant] or 0
|
||||
vim.g.rose_pine_current_variant = index[config.variant] or 0
|
||||
end
|
||||
|
||||
vim.g.rose_pine_current_variant = (vim.g.rose_pine_current_variant % #variants) + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue