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"; type = "lua";
config = '' 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 package.loaded["dieter"] = nil
require("dieter") require("dieter").setup()

View file

@ -93,11 +93,11 @@ local colors = {
} }
local c = colors[vim.o.background] local setupGroups = function(c)
c.dialog_fg = c.foreground c.dialog_fg = c.foreground
c.dialog_bg = c.background c.dialog_bg = c.background
local theme = { return {
Normal = { fg = c.foreground, bg = c.background }, Normal = { fg = c.foreground, bg = c.background },
Constant = { link = "NormalNC" }, Constant = { link = "NormalNC" },
@ -111,6 +111,8 @@ local theme = {
String = { fg = c.string }, String = { fg = c.string },
Visual = { bg = c.selection },
Comment = { fg = c.comment, italic = true, bold = true }, Comment = { fg = c.comment, italic = true, bold = true },
CommentError = { fg = c.comment_error, italic = true, bold = true }, CommentError = { fg = c.comment_error, italic = true, bold = true },
["@comment.note"] = { link = "Comment" }, ["@comment.note"] = { link = "Comment" },
@ -200,29 +202,62 @@ local theme = {
BlinkCmpSignatureHelp = { link = 'BlinkCmpDoc' }, BlinkCmpSignatureHelp = { link = 'BlinkCmpDoc' },
BlinkCmpSignatureHelpBorder = { link = 'BlinkCmpDocBorder' }, BlinkCmpSignatureHelpBorder = { link = 'BlinkCmpDocBorder' },
NeoCodeiumSuggestion = { fg = c.suggestion , bold = true, italic = true }, NeoCodeiumSuggestion = { fg = c.suggestion, bold = true, italic = true },
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 }, LspReferenceText = { fg = c.highlight_intense, undercurl = true },
LspInlayHint = { fg = c.accent1, italic = true, bold = true }, LspInlayHint = { fg = c.accent1, italic = true, bold = true },
} }
end
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") == 1 then 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
local setup_common = function(groups)
vim.cmd("hi clear")
if vim.fn.exists("syntax_on") == 1 then
vim.cmd("syntax reset") vim.cmd("syntax reset")
end end
for group, hl in pairs(groups) do
for group, hl in pairs(theme) do
vim.api.nvim_set_hl(0, group, hl) vim.api.nvim_set_hl(0, group, hl)
end
end end
vim.g.colors_name = "dieter" 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.keymap.set("n", "<Leader>ub", function()
vim.o.background = (vim.o.background == "light" and "dark" or "light") vim.o.background = (vim.o.background == "light" and "dark" or "light")
end, opts("Toggle dark/light background")) 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>uh", "<cmd>InlayHintsToggle<cr>", opts("Toggle inlay hints"))
vim.keymap.set("n", "<Leader>uw","<cmd>set invwrap<cr>", opts("Toggle line wrapping")) vim.keymap.set("n", "<Leader>uw","<cmd>set invwrap<cr>", opts("Toggle line wrapping"))