nvim: Add dieter/dieter-nocolor variants. Switch with <Leader>uc

This commit is contained in:
Daniel Lundin 2025-01-02 19:46:32 +01:00
parent 091442fcdf
commit 13348be8e9
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
5 changed files with 156 additions and 112 deletions

View file

@ -154,7 +154,7 @@ in
};
type = "lua";
config = ''
vim.cmd.colorscheme "dieter"
vim.cmd.colorscheme "dieter-nocolor"
'';
}

View file

@ -0,0 +1,2 @@
package.loaded["dieter"] = nil
require("dieter").setup_nocolor()

View file

@ -1,2 +1,2 @@
package.loaded["dieter"] = nil
require("dieter")
require("dieter").setup()

View file

@ -42,7 +42,7 @@ local colors = {
background = "NONE",
foreground = "NONE",
accent1 = hsl(202, 57, 57), -- Blue
accent1 = hsl(202, 57, 57), -- Blue
accent2 = hsl(40, 57, 57), -- Yellow
dimmed = hsl(212, 19, 25),
@ -93,136 +93,171 @@ local colors = {
}
local c = colors[vim.o.background]
c.dialog_fg = c.foreground
c.dialog_bg = c.background
local setupGroups = function(c)
c.dialog_fg = c.foreground
c.dialog_bg = c.background
local theme = {
Normal = { fg = c.foreground, bg = c.background },
return {
Normal = { fg = c.foreground, bg = c.background },
Constant = { link = "NormalNC" },
Delimiter = { link = "NormalNC" },
Function = { fg = c.func },
Identifier = { link = "NormalNC" },
Keyword = { fg = c.foreground, bold = true },
Operator = { link = "NormalNC" },
Special = { link = "NormalNC" },
Type = { link = "NormalNC" },
Constant = { link = "NormalNC" },
Delimiter = { link = "NormalNC" },
Function = { fg = c.func },
Identifier = { link = "NormalNC" },
Keyword = { fg = c.foreground, bold = true },
Operator = { link = "NormalNC" },
Special = { link = "NormalNC" },
Type = { link = "NormalNC" },
String = { fg = c.string },
String = { fg = c.string },
Comment = { fg = c.comment, italic = true, bold = true },
CommentError = { fg = c.comment_error, italic = true, bold = true },
["@comment.note"] = { link = "Comment" },
["@comment.todo"] = { link = "CommentError" },
["@comment.error"] = { link = "CommentError" },
["@comment.warning"] = { link = "CommentError" },
Visual = { bg = c.selection },
DiffAdd = { fg = c.add, bg = c.add_quarter },
GitSignsAdd = { fg = c.add, bg = c.background },
GitSignsAddNr = { link = "DiffAdd" },
DiffChange = { fg = c.change, bg = c.change_quarter },
GitSignsChange = { fg = c.change, bg = c.background },
GitSignsChangeNr = { link = "DiffChange" },
DiffDelete = { fg = c.delete, bg = c.delete_quarter },
GitSignsDelete = { fg = c.delete, bg = c.background },
GitSignsDeleteNr = { link = "DiffDelete" },
Comment = { fg = c.comment, italic = true, bold = true },
CommentError = { fg = c.comment_error, italic = true, bold = true },
["@comment.note"] = { link = "Comment" },
["@comment.todo"] = { link = "CommentError" },
["@comment.error"] = { link = "CommentError" },
["@comment.warning"] = { link = "CommentError" },
-- Treesitter
-- ["@function"] = { link = "NormalNC" },
["@punctuation.special"] = { fg = c.punc },
["@special"] = { link = "NormalNC" },
["@variable"] = { link = "NormalNC" },
["@variable.member"] = { fg = c.member },
["@variable.parameter"] = { fg = c.accent2 },
-- ["@lsp.type.variable"] = { fg = c.dimmed_subtle, italic = true },
DiffAdd = { fg = c.add, bg = c.add_quarter },
GitSignsAdd = { fg = c.add, bg = c.background },
GitSignsAddNr = { link = "DiffAdd" },
DiffChange = { fg = c.change, bg = c.change_quarter },
GitSignsChange = { fg = c.change, bg = c.background },
GitSignsChangeNr = { link = "DiffChange" },
DiffDelete = { fg = c.delete, bg = c.delete_quarter },
GitSignsDelete = { fg = c.delete, bg = c.background },
GitSignsDeleteNr = { link = "DiffDelete" },
-- UI Elements
CursorLine = { bg = c.highlight_subtle },
-- Treesitter
-- ["@function"] = { link = "NormalNC" },
["@punctuation.special"] = { fg = c.punc },
["@special"] = { link = "NormalNC" },
["@variable"] = { link = "NormalNC" },
["@variable.member"] = { fg = c.member },
["@variable.parameter"] = { fg = c.accent2 },
-- ["@lsp.type.variable"] = { fg = c.dimmed_subtle, italic = true },
DiagnosticError = { fg = c.diagnostic_error, italic = true },
DiagnosticFloatingError = { fg = c.diagnostic_error, bg = c.popup_error_bg },
DiagnosticFloatingWarn = { fg = c.diagnostic_warning, bg = c.popup_warning_bg },
DiagnosticFloatingInfo = { fg = c.diagnostic_info, bg = c.popup_info_bg },
DiagnosticFloatingHint = { fg = c.diagnostic_hint, bg = c.popup_hint_bg },
DiagnosticUnderlineError = { fg = c.diagnostic_error, undercurl = true },
DiagnosticUnderlineWarn = { fg = c.diagnostic_warn, undercurl = true },
DiagnosticUnderlineInfo = { fg = c.diagnostic_info, undercurl = true },
DiagnosticUnderlinehint = { fg = c.diagnostic_hint, undercurl = true },
-- UI Elements
CursorLine = { bg = c.highlight_subtle },
DiagnosticSignError = { fg = c.diagnostic_error },
DiagnosticSignHint = { fg = c.diagnostic_hint },
DiagnosticSignInfo = { fg = c.diagnostic_info },
DiagnosticSignWarn = { fg = c.diagnostic_warning },
LineNr = { fg = c.dimmed, italic = true },
CursorLineNr = { fg = c.dimmed_subtle, bg = c.highlight_subtle, bold = true },
DiagnosticError = { fg = c.diagnostic_error, italic = true },
DiagnosticFloatingError = { fg = c.diagnostic_error, bg = c.popup_error_bg },
DiagnosticFloatingWarn = { fg = c.diagnostic_warning, bg = c.popup_warning_bg },
DiagnosticFloatingInfo = { fg = c.diagnostic_info, bg = c.popup_info_bg },
DiagnosticFloatingHint = { fg = c.diagnostic_hint, bg = c.popup_hint_bg },
DiagnosticUnderlineError = { fg = c.diagnostic_error, undercurl = true },
DiagnosticUnderlineWarn = { fg = c.diagnostic_warn, undercurl = true },
DiagnosticUnderlineInfo = { fg = c.diagnostic_info, undercurl = true },
DiagnosticUnderlinehint = { fg = c.diagnostic_hint, undercurl = true },
IndentLine = { fg = c.dimmed },
IndentLineCurrent = { fg = c.dimmed_subtle },
MiniIndentscopeSymbol = { link = "IndentLine" },
MiniIndentscopeSymbolOff = { link = "IndentLine" },
DiagnosticSignError = { fg = c.diagnostic_error },
DiagnosticSignHint = { fg = c.diagnostic_hint },
DiagnosticSignInfo = { fg = c.diagnostic_info },
DiagnosticSignWarn = { fg = c.diagnostic_warning },
LineNr = { fg = c.dimmed, italic = true },
CursorLineNr = { fg = c.dimmed_subtle, bg = c.highlight_subtle, bold = true },
TreesitterContext = { reverse = true },
TreesitterContextLineNumber = { bg = c.dimmed, reverse = true, italic = true },
InclineNormal = { bg = c.background },
InclineNormalNC = { bg = c.background },
IndentLine = { fg = c.dimmed },
IndentLineCurrent = { fg = c.dimmed_subtle },
MiniIndentscopeSymbol = { link = "IndentLine" },
MiniIndentscopeSymbolOff = { link = "IndentLine" },
WinSeparator = { bg = c.dialog_bg, fg = c.dialog_fg },
NormalFloat = { bg = c.doc_bg, fg = c.doc_fg },
FloatBorder = { fg = c.doc_fg },
FloatTitle = { fg = c.doc_fg, bold = true },
TreesitterContext = { reverse = true },
TreesitterContextLineNumber = { bg = c.dimmed, reverse = true, italic = true },
InclineNormal = { bg = c.background },
InclineNormalNC = { bg = c.background },
Title = { fg = c.foreground, bold = true },
WinSeparator = { bg = c.dialog_bg, fg = c.dialog_fg },
NormalFloat = { bg = c.doc_bg, fg = c.doc_fg },
FloatBorder = { fg = c.doc_fg },
FloatTitle = { fg = c.doc_fg, bold = true },
MiniPickNormal = { link = "Normal" },
MiniPickBorder = { link = "MiniPickNormal" },
MiniPickBorderText = { link = "MiniPickBorder" },
MiniPickMatchCurrent = { bg = c.background, fg = c.foreground, reverse = true },
Title = { fg = c.foreground, bold = true },
MiniClueBorder = { link = "MiniPickNormal" },
MiniClueTitle = { bg = c.background, fg = c.foreground, bold = true },
MiniClueNextKey = { link = "MiniClueTitle" },
MiniClueDescGroup = { bg = c.background, fg = c.foreground, italic = true },
MiniClueDescSingle = { bg = c.background, fg = c.foreground },
MiniClueSeparator = { link = "MiniClueBorder" },
MiniPickNormal = { link = "Normal" },
MiniPickBorder = { link = "MiniPickNormal" },
MiniPickBorderText = { link = "MiniPickBorder" },
MiniPickMatchCurrent = { bg = c.background, fg = c.foreground, reverse = true },
MiniStarterCurrent = { link = "MiniPickMatchCurrent" },
MiniClueBorder = { link = "MiniPickNormal" },
MiniClueTitle = { bg = c.background, fg = c.foreground, bold = true },
MiniClueNextKey = { link = "MiniClueTitle" },
MiniClueDescGroup = { bg = c.background, fg = c.foreground, italic = true },
MiniClueDescSingle = { bg = c.background, fg = c.foreground },
MiniClueSeparator = { link = "MiniClueBorder" },
BlinkCmpMenu = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpMenuSelection = { bg = c.cmp_selected_bg, fg = c.cmp_selected_fg, reverse = false },
BlinkCmpMenuBorder = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpLabel = { link = 'BlinkCmpMenu' },
BlinkCmpLabelMatch = { link = 'BlinkCmpMenu', underline = true },
MiniStarterCurrent = { link = "MiniPickMatchCurrent" },
BlinkCmpDoc = { bg = c.doc_bg, fg = c.foreground },
BlinkCmpDocBorder = { bg = c.doc_bg, fg = c.doc_fg },
BlinkCmpDocDetail = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelp = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelpBorder = { link = 'BlinkCmpDocBorder' },
BlinkCmpMenu = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpMenuSelection = { bg = c.cmp_selected_bg, fg = c.cmp_selected_fg, reverse = false },
BlinkCmpMenuBorder = { bg = c.cmp_bg, fg = c.cmp_fg },
BlinkCmpLabel = { link = 'BlinkCmpMenu' },
BlinkCmpLabelMatch = { link = 'BlinkCmpMenu', underline = true },
NeoCodeiumSuggestion = { fg = c.suggestion , bold = true, italic = true },
BlinkCmpDoc = { bg = c.doc_bg, fg = c.foreground },
BlinkCmpDocBorder = { bg = c.doc_bg, fg = c.doc_fg },
BlinkCmpDocDetail = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelp = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelpBorder = { link = 'BlinkCmpDocBorder' },
NoiceMini = { fg = c.foreground, italic = true },
TelescopeNormal = { fg = c.foreground, bg = c.background },
TelescopeBorder = { bold = true },
TelescopeSelection = { bg = c.selection },
TelescopeResultsNormal = { fg = c.foreground, bold = true },
TelescopeResultsComment = { fg = c.dimmed_subtle, italic = true, bold = false },
Visual = { bg = c.selection },
LspReferenceText = { fg = c.highlight_intense, undercurl = true },
LspInlayHint = { fg = c.accent1, italic = true, bold = true },
}
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") == 1 then
vim.cmd("syntax reset")
NeoCodeiumSuggestion = { fg = c.suggestion, bold = true, italic = true },
LspReferenceText = { fg = c.highlight_intense, undercurl = true },
LspInlayHint = { fg = c.accent1, italic = true, bold = true },
}
end
for group, hl in pairs(theme) do
vim.api.nvim_set_hl(0, group, hl)
local setupGroupsNoColor = function(c)
local g = setupGroups(c)
local cl = { link = "NormalNC" }
g.Constant = cl
g.Delimiter = cl
g.Function = cl
g.Identifier = cl
g.Keyword = cl
g.Operator = cl
g["@punctuation.special"] = cl
g["@special"] = cl
g["@string"] = cl
g["@lsp.type.string"] = cl
g.Special = cl
g.String = cl
g.Type = cl
g.Variable = cl
g["@variable"] = cl
g["@variable.member"] = cl
g["@variable.parameter"] = cl
g.Comment = { fg = c.dimmed_subtle, italic = true, bold = true }
g.CommentError = { link = "Comment" }
return g
end
vim.g.colors_name = "dieter"
local setup_common = function(groups)
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") == 1 then
vim.cmd("syntax reset")
end
for group, hl in pairs(groups) do
vim.api.nvim_set_hl(0, group, hl)
end
end
local T = {}
T.setup = function()
local c = colors[vim.o.background]
local groups = setupGroups(c)
setup_common(groups)
vim.g.colors_name = "dieter"
end
T.setup_nocolor = function()
local c = colors[vim.o.background]
local groups = setupGroupsNoColor(c)
setup_common(groups)
vim.g.colors_name = "dieter-nocolor"
end
return T

View file

@ -154,6 +154,13 @@ vim.keymap.set("n", "K", function()
vim.keymap.set("n", "<Leader>ub", function()
vim.o.background = (vim.o.background == "light" and "dark" or "light")
end, opts("Toggle dark/light background"))
vim.keymap.set("n", "<Leader>uc", function()
if vim.g.colors_name == "dieter-nocolor" then
vim.cmd [[colorscheme dieter]]
else
vim.cmd [[colorscheme dieter-nocolor]]
end
end, opts("Toggle Dieter colors"))
vim.keymap.set("n", "<Leader>uh", "<cmd>InlayHintsToggle<cr>", opts("Toggle inlay hints"))
vim.keymap.set("n", "<Leader>uw","<cmd>set invwrap<cr>", opts("Toggle line wrapping"))