refactor theme

This commit is contained in:
mvllow 2021-08-20 11:06:35 -05:00
commit 5d560dfb11
2 changed files with 292 additions and 328 deletions

View file

@ -1,9 +1,68 @@
local p = require('rose-pine.palette')
local theme = {}
local maybe_base = p.base
if vim.g.rose_pine_disable_background then
maybe_base = p.none
end
theme.base = {
ColorColumn = { bg = p.highlight_overlay },
-- Conceal = {},
-- Cursor = {},
CursorColumn = { bg = p.highlight },
-- CursorIM = {},
CursorLine = { bg = p.highlight_inactive },
CursorLineNr = { fg = p.text },
DarkenedPanel = { bg = p.surface },
DarkenedStatusline = { bg = p.surface },
DiffAdd = { fg = p.foam },
DiffChange = { fg = p.rose },
DiffDelete = { fg = p.love },
DiffText = { fg = p.text },
Directory = { fg = p.foam, bg = p.none },
-- EndOfBuffer = {},
ErrorMsg = { fg = p.love, style = 'bold' },
FloatBorder = { fg = p.highlight, bg = p.surface },
FoldColumn = {},
Folded = { fg = p.text, bg = p.surface },
IncSearch = { bg = p.highlight },
LineNr = { fg = p.inactive },
MatchParen = { fg = p.text, bg = p.overlay },
-- ModeMsg = {},
MoreMsg = { fg = p.iris },
NonText = { fg = p.inactive },
Normal = { fg = p.text, bg = maybe_base },
-- NormalFloat = {},
Pmenu = { fg = p.subtle, bg = p.surface },
PmenuSbar = { bg = p.overlay },
PmenuSel = { fg = p.text, bg = p.overlay },
PmenuThumb = { bg = p.inactive },
Question = { fg = p.gold },
-- QuickFixLine = {},
Search = { fg = p.iris, bg = p.highlight_overlay },
SpecialKey = { fg = p.foam },
SpellBad = { style = 'undercurl', sp = p.love },
SpellCap = { style = 'undercurl', sp = p.subtle },
SpellLocal = { style = 'undercurl', sp = p.subtle },
SpellRare = { style = 'undercurl', sp = p.subtle },
SignColumn = { fg = p.text, bg = maybe_base },
StatusLine = { fg = p.text, bg = p.surface },
StatusLineNC = { fg = p.subtle, bg = p.surface },
-- StatusLineTerm = {},
-- StatusLineTermNC = {},
-- TabLine = {},
-- TabLineFill = {},
-- TabLineSel = {},
Title = { fg = p.rose },
VertSplit = { fg = p.overlay },
Visual = { bg = p.highlight },
-- VisualNOS = {},
WarningMsg = { fg = p.gold },
-- Whitespace = {},
-- WildMenu = {},
theme.loadSyntax = function()
local syntax = {
Boolean = { fg = p.gold },
Character = { fg = p.gold },
Comment = {
@ -38,94 +97,49 @@ theme.loadSyntax = function()
String = { fg = p.gold },
Structure = { fg = p.foam },
Tag = { fg = p.rose },
Title = { fg = p.text },
Todo = { fg = p.iris },
Type = { fg = p.foam },
Typedef = { fg = p.foam },
Underlined = { fg = p.foam, style = 'underline' },
-- html
htmlArg = { fg = p.iris },
htmlEndTag = { fg = p.subtle },
htmlLink = { fg = p.text },
htmlTag = { fg = p.subtle },
htmlTagN = { fg = p.love },
htmlTagName = { fg = p.foam },
}
return syntax
end
LspDiagnosticsDefaultHint = { fg = p.iris },
LspDiagnosticsDefaultInformation = { fg = p.foam },
LspDiagnosticsDefaultWarning = { fg = p.gold },
LspDiagnosticsDefaultError = { fg = p.love },
theme.loadEditor = function()
local editor = {
ColorColumn = { bg = p.highlight_overlay },
-- Conceal = {},
-- Cursor = {},
CursorColumn = { bg = p.highlight },
-- CursorIM = {},
CursorLine = { bg = p.highlight_inactive },
CursorLineNr = { fg = p.text },
DarkenedPanel = { bg = p.surface },
DarkenedStatusline = { bg = p.surface },
DiffAdd = { fg = p.foam },
DiffChange = { fg = p.rose },
DiffDelete = { fg = p.love },
DiffText = { fg = p.text },
Directory = { fg = p.foam, bg = p.none },
-- EndOfBuffer = {},
ErrorMsg = { fg = p.love, style = 'bold' },
FloatBorder = { fg = p.highlight, bg = p.surface },
FoldColumn = {},
Folded = { fg = p.text, bg = p.surface },
IncSearch = { bg = p.highlight },
LineNr = { fg = p.inactive },
MatchParen = { fg = p.text, bg = p.overlay },
-- ModeMsg = {},
MoreMsg = { fg = p.iris },
NonText = { fg = p.inactive },
Normal = { fg = p.text },
-- NormalFloat = {},
Pmenu = { fg = p.subtle, bg = p.surface },
PmenuSbar = { bg = p.overlay },
PmenuSel = { fg = p.text, bg = p.overlay },
PmenuThumb = { bg = p.inactive },
Question = { fg = p.gold },
-- QuickFixLine = {},
Search = { fg = p.iris, bg = p.highlight_overlay },
SpecialKey = { fg = p.foam },
SpellBad = { style = 'undercurl', sp = p.love },
SpellCap = { style = 'undercurl', sp = p.subtle },
SpellLocal = { style = 'undercurl', sp = p.subtle },
SpellRare = { style = 'undercurl', sp = p.subtle },
SignColumn = {},
StatusLine = { fg = p.text, bg = p.surface },
StatusLineNC = { fg = p.subtle, bg = p.surface },
-- StatusLineTerm = {},
-- StatusLineTermNC = {},
-- TabLine = {},
-- TabLineFill = {},
-- TabLineSel = {},
Title = { fg = p.rose },
VertSplit = { fg = p.overlay },
Visual = { bg = p.highlight },
-- VisualNOS = {},
WarningMsg = { fg = p.gold },
-- Whitespace = {},
-- WildMenu = {},
}
LspDiagnosticsFloatingHint = { fg = p.iris },
LspDiagnosticsFloatingInformation = { fg = p.foam },
LspDiagnosticsFloatingWarning = { fg = p.gold },
LspDiagnosticsFloatingError = { fg = p.love },
if vim.g.rose_pine_disable_background == true then
editor.Normal = { fg = p.text, bg = p.none }
editor.SignColumn = { fg = p.text, bg = p.none }
else
editor.Normal = { fg = p.text, bg = p.base }
editor.SignColumn = { fg = p.text, bg = p.base }
end
LspDiagnosticsSignHint = { fg = p.iris },
LspDiagnosticsSignInformation = { fg = p.foam },
LspDiagnosticsSignWarning = { fg = p.gold },
LspDiagnosticsSignError = { fg = p.love },
return editor
end
LspDiagnosticsUnderlineHint = { style = 'undercurl', sp = p.iris },
LspDiagnosticsUnderlineInformation = { style = 'undercurl', sp = p.foam },
LspDiagnosticsUnderlineWarning = { style = 'undercurl', sp = p.gold },
LspDiagnosticsUnderlineError = { style = 'undercurl', sp = p.love },
theme.loadTerminal = function()
LspDiagnosticsVirtualTextHint = { fg = p.iris },
LspDiagnosticsVirtualTextInformation = { fg = p.foam },
LspDiagnosticsVirtualTextWarning = { fg = p.gold },
LspDiagnosticsVirtualTextError = { fg = p.love },
LspReferenceText = { fg = p.rose, bg = p.highlight },
LspReferenceRead = { fg = p.rose, bg = p.highlight },
LspReferenceWrite = { fg = p.rose, bg = p.highlight },
}
function theme.load_terminal()
-- black
vim.g.terminal_color_0 = p.overlay
vim.g.terminal_color_8 = p.subtle
@ -152,8 +166,7 @@ theme.loadTerminal = function()
vim.g.terminal_color_15 = p.text
end
theme.loadTreesitter = function()
local treesitter = {
theme.treesitter = {
-- TSAnnotation = {},
-- TSAttribute = {},
TSBoolean = { fg = p.rose },
@ -217,43 +230,9 @@ theme.loadTreesitter = function()
style = vim.g.rose_pine_enable_italics and 'italic',
},
TSVariableBuiltin = { fg = p.love },
}
}
return treesitter
end
theme.loadLsp = function()
local lsp = {
LspDiagnosticsDefaultError = { fg = p.love },
LspDiagnosticsDefaultHint = { fg = p.iris },
LspDiagnosticsDefaultInformation = { fg = p.foam },
LspDiagnosticsDefaultWarning = { fg = p.gold },
LspDiagnosticsFloatingError = { fg = p.love },
LspDiagnosticsFloatingHint = { fg = p.iris },
LspDiagnosticsFloatingInformation = { fg = p.foam },
LspDiagnosticsFloatingWarning = { fg = p.gold },
LspDiagnosticsSignError = { fg = p.love },
LspDiagnosticsSignHint = { fg = p.iris },
LspDiagnosticsSignInformation = { fg = p.foam },
LspDiagnosticsSignWarning = { fg = p.gold },
LspDiagnosticsUnderlineError = { style = 'undercurl', sp = p.love },
LspDiagnosticsUnderlineHint = { style = 'undercurl', sp = p.iris },
LspDiagnosticsUnderlineInformation = { style = 'undercurl', sp = p.foam },
LspDiagnosticsUnderlineWarning = { style = 'undercurl', sp = p.gold },
LspDiagnosticsVirtualTextError = { fg = p.love },
LspDiagnosticsVirtualTextHint = { fg = p.iris },
LspDiagnosticsVirtualTextInformation = { fg = p.foam },
LspDiagnosticsVirtualTextWarning = { fg = p.gold },
LspReferenceRead = { fg = p.rose, bg = p.highlight },
LspReferenceText = { fg = p.rose, bg = p.highlight },
LspReferenceWrite = { fg = p.rose, bg = p.highlight },
}
return lsp
end
theme.loadPlugins = function()
local plugins = {
theme.plugins = {
-- barbar.nvim
-- https://github.com/romgrk/barbar.nvim
BufferTabpageFill = { bg = p.none },
@ -313,14 +292,6 @@ theme.loadPlugins = function()
NvimTreeGitRenamed = { fg = p.pine },
NvimTreeGitStaged = { fg = p.iris },
-- which-key.nvim
-- https://github.com/folke/which-key.nvim
WhichKey = { fg = p.iris },
WhichKeyGroup = { fg = p.foam },
WhichKeySeparator = { fg = p.subtle },
WhichKeyDesc = { fg = p.gold },
WhichKeyFloat = { bg = p.surface },
WhichKeyValue = { fg = p.rose },
-- todo-comments.nvim
-- https://github.com/folke/todo-comments.nvim
@ -347,9 +318,15 @@ theme.loadPlugins = function()
TodoBgNOTE = { fg = '#000000', bg = p.iris },
TodoFgNOTE = { fg = p.iris, bg = p.base },
TodoSignNOTE = { fg = p.iris, bg = p.base },
}
return plugins
end
-- which-key.nvim
-- https://github.com/folke/which-key.nvim
WhichKey = { fg = p.iris },
WhichKeyGroup = { fg = p.foam },
WhichKeySeparator = { fg = p.subtle },
WhichKeyDesc = { fg = p.gold },
WhichKeyFloat = { bg = p.surface },
WhichKeyValue = { fg = p.rose },
}
return theme

View file

@ -1,5 +1,4 @@
local util = {}
local theme = require('rose-pine.theme')
util.highlight = function(group, color)
local style = color.style and 'gui=' .. color.style or 'gui=NONE'
@ -25,11 +24,13 @@ util.highlight = function(group, color)
end
function util.load()
if vim.g.colors_name then
vim.cmd('hi clear')
if vim.fn.exists('syntax_on') then
vim.cmd('syntax reset')
end
if
vim.o.termguicolors = true
vim.g.colors_name = 'rose-pine'
vim.g.rose_pine_variant == 'dawn'
or vim.g.rose_pine_variant == 'rose-pine-dawn'
then
@ -37,25 +38,18 @@ function util.load()
else
vim.opt.background = 'dark'
end
vim.o.termguicolors = true
vim.g.colors_name = 'rose-pine'
local theme = require('rose-pine.theme')
local async
async = vim.loop.new_async(vim.schedule_wrap(function()
theme.loadTerminal()
local plugins = theme.loadPlugins()
local treesitter = theme.loadTreesitter()
local lsp = theme.loadLsp()
theme.load_terminal()
for group, colors in pairs(plugins) do
for group, colors in pairs(theme.treesitter) do
util.highlight(group, colors)
end
for group, colors in pairs(treesitter) do
util.highlight(group, colors)
end
for group, colors in pairs(lsp) do
for group, colors in pairs(theme.plugins) do
util.highlight(group, colors)
end
@ -63,18 +57,11 @@ function util.load()
end))
-- load priority groups first
local editor = theme.loadEditor()
local syntax = theme.loadSyntax()
for group, colors in pairs(editor) do
for group, colors in pairs(theme.base) do
util.highlight(group, colors)
end
for group, colors in pairs(syntax) do
util.highlight(group, colors)
end
-- load enhancements (eg. lsp, treesitter, plugins)
-- load enhancements (eg. treesitter, plugins)
async:send()
end