mirror of
https://github.com/webhooked/kanso.nvim.git
synced 2026-05-30 21:57:02 +02:00
Add config field to disable bold styles across the whole theme
This commit is contained in:
parent
f7080992e7
commit
aaa72b68b6
6 changed files with 649 additions and 575 deletions
|
|
@ -11,9 +11,9 @@ function M.setup(colors, config)
|
|||
-- ColorColumn Used for the columns set with 'colorcolumn'.
|
||||
ColorColumn = { bg = theme.ui.bg_p1 },
|
||||
-- Conceal Placeholder characters substituted for concealed text (see 'conceallevel').
|
||||
Conceal = { fg = theme.ui.special, bold = true },
|
||||
Conceal = { fg = theme.ui.special, bold = config.bold },
|
||||
-- CurSearch Used for highlighting a search pattern under the cursor (see 'hlsearch').
|
||||
CurSearch = { fg = theme.ui.fg, bg = theme.ui.bg_search, bold = true },
|
||||
CurSearch = { fg = theme.ui.fg, bg = theme.ui.bg_search, bold = config.bold },
|
||||
-- Cursor Character under the cursor.
|
||||
Cursor = { fg = theme.ui.cursor_fg, bg = theme.ui.cursor_bg },
|
||||
-- lCursor Character under the cursor when |language-mapping| is used (see 'guicursor').
|
||||
|
|
@ -62,11 +62,11 @@ function M.setup(colors, config)
|
|||
-- CursorLineFold Like FoldColumn when 'cursorline' is set for the cursor line.
|
||||
-- CursorLineSign Like SignColumn when 'cursorline' is set for the cursor line.
|
||||
-- MatchParen Character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
|
||||
MatchParen = { fg = theme.diag.warning, bold = true },
|
||||
MatchParen = { fg = theme.diag.warning, bold = config.bold },
|
||||
-- ModeMsg 'showmode' message (e.g., "-- INSERT --").
|
||||
ModeMsg = { fg = theme.diag.warning, bold = true },
|
||||
ModeMsg = { fg = theme.diag.warning, bold = config.bold },
|
||||
-- MsgArea Area for messages and cmdline.
|
||||
MsgArea = vim.o.cmdheight == 0 and { link = 'StatusLine' } or { fg = theme.ui.fg_dim },
|
||||
MsgArea = vim.o.cmdheight == 0 and { link = "StatusLine" } or { fg = theme.ui.fg_dim },
|
||||
-- MsgSeparator Separator for scrolled messages |msgsep|.
|
||||
MsgSeparator = { bg = vim.o.cmdheight == 0 and theme.ui.bg or theme.ui.bg_m3 },
|
||||
-- MoreMsg |more-prompt|
|
||||
|
|
@ -78,9 +78,16 @@ function M.setup(colors, config)
|
|||
-- NormalFloat Normal text in floating windows.
|
||||
NormalFloat = { fg = theme.ui.float.fg, bg = config.transparent and theme.ui.none or theme.ui.float.bg },
|
||||
-- FloatBorder Border of floating windows.
|
||||
FloatBorder = { fg = theme.ui.float.fg_border, bg = config.transparent and theme.ui.none or theme.ui.float.bg_border },
|
||||
FloatBorder = {
|
||||
fg = theme.ui.float.fg_border,
|
||||
bg = config.transparent and theme.ui.none or theme.ui.float.bg_border,
|
||||
},
|
||||
-- FloatTitle Title of floating windows.
|
||||
FloatTitle = { fg = theme.ui.special, bg = config.transparent and theme.ui.none or theme.ui.float.bg_border, bold = true },
|
||||
FloatTitle = {
|
||||
fg = theme.ui.special,
|
||||
bg = config.transparent and theme.ui.none or theme.ui.float.bg_border,
|
||||
bold = config.bold,
|
||||
},
|
||||
-- FloatFooter Footer of floating windows.
|
||||
FloatFooter = { fg = theme.ui.nontext, bg = config.transparent and theme.ui.none or theme.ui.float.bg_border },
|
||||
-- NormalNC Normal text in non-current windows.
|
||||
|
|
@ -126,9 +133,13 @@ function M.setup(colors, config)
|
|||
-- TabLineFill Tab pages line, where there are no labels.
|
||||
TabLineFill = { bg = theme.ui.none },
|
||||
-- TabLineSel Tab pages line, active tab page label.
|
||||
TabLineSel = { fg = theme.ui.fg_dim, bg = not config.transparent and theme.ui.bg_p1 or theme.ui.none, bold = true },
|
||||
TabLineSel = {
|
||||
fg = theme.ui.fg_dim,
|
||||
bg = not config.transparent and theme.ui.bg_p1 or theme.ui.none,
|
||||
bold = config.bold,
|
||||
},
|
||||
-- Title Titles for output from ":set all", ":autocmd" etc.
|
||||
Title = { fg = theme.syn.fun, bold = true },
|
||||
Title = { fg = theme.syn.fun, bold = config.bold },
|
||||
-- Visual Visual mode selection.
|
||||
Visual = { bg = theme.ui.bg_visual },
|
||||
-- VisualNOS Visual mode selection when vim is "Not Owning the Selection".
|
||||
|
|
@ -177,10 +188,26 @@ function M.setup(colors, config)
|
|||
DiagnosticVirtualTextInfo = { link = "DiagnosticInfo" },
|
||||
DiagnosticVirtualTextHint = { link = "DiagnosticHint" },
|
||||
|
||||
DiagnosticUnderlineError = { undercurl = config.undercurl, underline = not config.undercurl, sp = theme.diag.error },
|
||||
DiagnosticUnderlineWarn = { undercurl = config.undercurl, underline = not config.undercurl, sp = theme.diag.warning },
|
||||
DiagnosticUnderlineInfo = { undercurl = config.undercurl, underline = not config.undercurl, sp = theme.diag.info },
|
||||
DiagnosticUnderlineHint = { undercurl = config.undercurl, underline = not config.undercurl, sp = theme.diag.hint },
|
||||
DiagnosticUnderlineError = {
|
||||
undercurl = config.undercurl,
|
||||
underline = not config.undercurl,
|
||||
sp = theme.diag.error,
|
||||
},
|
||||
DiagnosticUnderlineWarn = {
|
||||
undercurl = config.undercurl,
|
||||
underline = not config.undercurl,
|
||||
sp = theme.diag.warning,
|
||||
},
|
||||
DiagnosticUnderlineInfo = {
|
||||
undercurl = config.undercurl,
|
||||
underline = not config.undercurl,
|
||||
sp = theme.diag.info,
|
||||
},
|
||||
DiagnosticUnderlineHint = {
|
||||
undercurl = config.undercurl,
|
||||
underline = not config.undercurl,
|
||||
sp = theme.diag.hint,
|
||||
},
|
||||
|
||||
LspSignatureActiveParameter = { fg = theme.diag.warning },
|
||||
LspCodeLens = { fg = theme.syn.comment },
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ function M.setup(colors, config)
|
|||
-- ["@lsp.type.function"] = { link = "Function" },
|
||||
-- ["@lsp.type.interface"] = { link = "Structure" },
|
||||
["@lsp.type.macro"] = { link = "Macro" },
|
||||
["@lsp.type.method"] = { link = "@function.method" }, -- Function
|
||||
["@lsp.type.namespace"] = { link = "@module" }, -- Structure
|
||||
["@lsp.type.method"] = { link = "@function.method" }, -- Function
|
||||
["@lsp.type.namespace"] = { link = "@module" }, -- Structure
|
||||
["@lsp.type.parameter"] = { link = "@variable.parameter" }, -- Identifier
|
||||
-- ["@lsp.type.property"] = { link = "Identifier" },
|
||||
-- ["@lsp.type.struct"] = { link = "Structure" },
|
||||
-- ["@lsp.type.type"] = { link = "Type" },
|
||||
-- ["@lsp.type.typeParameter"] = { link = "TypeDef" },
|
||||
["@lsp.type.variable"] = { fg = "none" }, -- Identifier
|
||||
["@lsp.type.comment"] = { link = "Comment" }, -- Comment
|
||||
["@lsp.type.comment"] = { link = "Comment" }, -- Comment
|
||||
|
||||
["@lsp.type.const"] = { link = "Constant" },
|
||||
["@lsp.type.comparison"] = { link = "Operator" },
|
||||
|
|
@ -52,7 +52,7 @@ function M.setup(colors, config)
|
|||
|
||||
["@lsp.typemod.variable.injected"] = { link = "@variable" },
|
||||
|
||||
["@lsp.typemod.function.readonly"] = { fg = theme.syn.fun, bold = true },
|
||||
["@lsp.typemod.function.readonly"] = { fg = theme.syn.fun, bold = config.bold },
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,8 +9,11 @@ function M.setup(colors, config)
|
|||
|
||||
return {
|
||||
-- *Comment any comment
|
||||
Comment = vim.tbl_extend("force", { fg = theme.syn.comment }, config.disableItalics and {} or config
|
||||
.commentStyle),
|
||||
Comment = vim.tbl_extend(
|
||||
"force",
|
||||
{ fg = theme.syn.comment },
|
||||
config.disableItalics and {} or config.commentStyle
|
||||
),
|
||||
|
||||
-- *Constant any constant
|
||||
Constant = { fg = theme.syn.constant },
|
||||
|
|
@ -38,8 +41,11 @@ function M.setup(colors, config)
|
|||
-- Operator "sizeof", "+", "*", etc.
|
||||
Operator = { fg = theme.syn.operator },
|
||||
-- Keyword any other keyword
|
||||
Keyword = vim.tbl_extend("force", { fg = theme.syn.keyword }, config.disableItalics and {} or config
|
||||
.keywordStyle),
|
||||
Keyword = vim.tbl_extend(
|
||||
"force",
|
||||
{ fg = theme.syn.keyword },
|
||||
config.disableItalics and {} or config.keywordStyle
|
||||
),
|
||||
-- Exception try, catch, throw
|
||||
Exception = { fg = theme.syn.special2 },
|
||||
|
||||
|
|
@ -67,7 +73,7 @@ function M.setup(colors, config)
|
|||
|
||||
-- *Underlined text that stands out, HTML links
|
||||
Underlined = { fg = theme.syn.special1, underline = true },
|
||||
Bold = { bold = true },
|
||||
Bold = { bold = config.bold },
|
||||
Italic = { italic = not config.disableItalics },
|
||||
|
||||
-- *Ignore left blank, hidden |hl-Ignore|
|
||||
|
|
@ -77,7 +83,7 @@ function M.setup(colors, config)
|
|||
Error = { fg = theme.diag.error },
|
||||
|
||||
-- *Todo anything that needs extra attention; mostly the keywords TODO FIXME WARNING and XXX
|
||||
Todo = { fg = theme.ui.fg_reverse, bg = theme.diag.info, bold = true },
|
||||
Todo = { fg = theme.ui.fg_reverse, bg = theme.diag.info, bold = config.bold },
|
||||
|
||||
qfLineNr = { link = "lineNr" },
|
||||
qfFileName = { link = "Directory" },
|
||||
|
|
|
|||
|
|
@ -77,8 +77,11 @@ function M.setup(colors, config)
|
|||
-- @keyword.modifier keywords defining type modifiers (e.g. `const`, `static`, `public`)
|
||||
-- @keyword.repeat keywords related to loops (e.g. `for`, `while`)
|
||||
-- @keyword.return keywords like `return` and `yield`
|
||||
["@keyword.return"] = vim.tbl_extend("force", { fg = theme.syn.special3 },
|
||||
config.disableItalics and {} or config.keywordStyle),
|
||||
["@keyword.return"] = vim.tbl_extend(
|
||||
"force",
|
||||
{ fg = theme.syn.special3 },
|
||||
config.disableItalics and {} or config.keywordStyle
|
||||
),
|
||||
-- @keyword.debug keywords related to debugging
|
||||
-- @keyword.exception keywords related to exceptions (e.g. `throw`, `catch`)
|
||||
["@keyword.exception"] = vim.tbl_extend("force", { fg = theme.syn.special3 }, config.statementStyle),
|
||||
|
|
@ -102,15 +105,15 @@ function M.setup(colors, config)
|
|||
-- @comment.documentation comments documenting code
|
||||
--
|
||||
-- @comment.error error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED`)
|
||||
["@comment.error"] = { fg = theme.ui.fg, bg = theme.diag.error, bold = true },
|
||||
["@comment.error"] = { fg = theme.ui.fg, bg = theme.diag.error, bold = config.bold },
|
||||
-- @comment.warning warning-type comments (e.g. `WARNING`, `FIX`, `HACK`)
|
||||
["@comment.warning"] = { fg = theme.ui.fg_reverse, bg = theme.diag.warning, bold = true },
|
||||
["@comment.warning"] = { fg = theme.ui.fg_reverse, bg = theme.diag.warning, bold = config.bold },
|
||||
-- @comment.todo todo-type comments (e.g. `TODO`, `WIP`)
|
||||
-- @comment.note note-type comments (e.g. `NOTE`, `INFO`, `XXX`)
|
||||
["@comment.note"] = { fg = theme.ui.fg_reverse, bg = theme.diag.hint, bold = true },
|
||||
["@comment.note"] = { fg = theme.ui.fg_reverse, bg = theme.diag.hint, bold = config.bold },
|
||||
--
|
||||
-- @markup.strong bold text
|
||||
["@markup.strong"] = { bold = true },
|
||||
["@markup.strong"] = { bold = config.bold },
|
||||
-- @markup.italic italic text
|
||||
["@markup.italic"] = { italic = true },
|
||||
-- @markup.strikethrough struck-through text
|
||||
|
|
|
|||
|
|
@ -8,89 +8,90 @@ local M = {}
|
|||
--- default config
|
||||
---@class KansoConfig
|
||||
M.config = {
|
||||
undercurl = true,
|
||||
commentStyle = { italic = true },
|
||||
functionStyle = {},
|
||||
keywordStyle = { italic = true },
|
||||
statementStyle = {},
|
||||
typeStyle = {},
|
||||
transparent = false,
|
||||
dimInactive = false,
|
||||
terminalColors = true,
|
||||
disableItalics = false,
|
||||
colors = { theme = { zen = {}, pearl = {}, ink = {}, all = {} }, palette = {} },
|
||||
---@type fun(colors: KansoColorsSpec): table<string, table>
|
||||
overrides = function()
|
||||
return {}
|
||||
end,
|
||||
---@type { dark: string, light: string }
|
||||
background = { dark = "ink", light = "pearl" },
|
||||
theme = "ink",
|
||||
compile = false,
|
||||
bold = true,
|
||||
undercurl = true,
|
||||
commentStyle = { italic = true },
|
||||
functionStyle = {},
|
||||
keywordStyle = { italic = true },
|
||||
statementStyle = {},
|
||||
typeStyle = {},
|
||||
transparent = false,
|
||||
dimInactive = false,
|
||||
terminalColors = true,
|
||||
disableItalics = false,
|
||||
colors = { theme = { zen = {}, pearl = {}, ink = {}, all = {} }, palette = {} },
|
||||
---@type fun(colors: KansoColorsSpec): table<string, table>
|
||||
overrides = function()
|
||||
return {}
|
||||
end,
|
||||
---@type { dark: string, light: string }
|
||||
background = { dark = "ink", light = "pearl" },
|
||||
theme = "ink",
|
||||
compile = false,
|
||||
}
|
||||
|
||||
local function check_config(config)
|
||||
local err
|
||||
return not err
|
||||
local err
|
||||
return not err
|
||||
end
|
||||
|
||||
--- update global configuration with user settings
|
||||
---@param config? KansoConfig user configuration
|
||||
function M.setup(config)
|
||||
if check_config(config) then
|
||||
M.config = vim.tbl_deep_extend("force", M.config, config or {})
|
||||
else
|
||||
vim.notify("Kanso: Errors found while loading user config. Using default config.", vim.log.levels.ERROR)
|
||||
end
|
||||
if check_config(config) then
|
||||
M.config = vim.tbl_deep_extend("force", M.config, config or {})
|
||||
else
|
||||
vim.notify("Kanso: Errors found while loading user config. Using default config.", vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
|
||||
--- load the colorscheme
|
||||
---@param theme? string
|
||||
function M.load(theme)
|
||||
local utils = require("kanso.utils")
|
||||
local utils = require("kanso.utils")
|
||||
|
||||
theme = theme or M.config.background[vim.o.background] or M.config.theme
|
||||
M._CURRENT_THEME = theme
|
||||
theme = theme or M.config.background[vim.o.background] or M.config.theme
|
||||
M._CURRENT_THEME = theme
|
||||
|
||||
if vim.g.colors_name then
|
||||
vim.cmd("hi clear")
|
||||
end
|
||||
if vim.g.colors_name then
|
||||
vim.cmd("hi clear")
|
||||
end
|
||||
|
||||
vim.g.colors_name = "kanso"
|
||||
vim.o.termguicolors = true
|
||||
vim.g.colors_name = "kanso"
|
||||
vim.o.termguicolors = true
|
||||
|
||||
if M.config.compile then
|
||||
if utils.load_compiled(theme) then
|
||||
return
|
||||
end
|
||||
if M.config.compile then
|
||||
if utils.load_compiled(theme) then
|
||||
return
|
||||
end
|
||||
|
||||
M.compile()
|
||||
utils.load_compiled(theme)
|
||||
else
|
||||
local colors = require("kanso.colors").setup({ theme = theme, colors = M.config.colors })
|
||||
local highlights = require("kanso.highlights").setup(colors, M.config)
|
||||
require("kanso.highlights").highlight(highlights, M.config.terminalColors and colors.theme.term or {})
|
||||
end
|
||||
M.compile()
|
||||
utils.load_compiled(theme)
|
||||
else
|
||||
local colors = require("kanso.colors").setup({ theme = theme, colors = M.config.colors })
|
||||
local highlights = require("kanso.highlights").setup(colors, M.config)
|
||||
require("kanso.highlights").highlight(highlights, M.config.terminalColors and colors.theme.term or {})
|
||||
end
|
||||
end
|
||||
|
||||
function M.compile()
|
||||
for theme, _ in pairs(require("kanso.themes")) do
|
||||
local colors = require("kanso.colors").setup({ theme = theme, colors = M.config.colors })
|
||||
local highlights = require("kanso.highlights").setup(colors, M.config)
|
||||
require("kanso.utils").compile(theme, highlights, M.config.terminalColors and colors.theme.term or {})
|
||||
end
|
||||
for theme, _ in pairs(require("kanso.themes")) do
|
||||
local colors = require("kanso.colors").setup({ theme = theme, colors = M.config.colors })
|
||||
local highlights = require("kanso.highlights").setup(colors, M.config)
|
||||
require("kanso.utils").compile(theme, highlights, M.config.terminalColors and colors.theme.term or {})
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("KansoCompile", function()
|
||||
for mod, _ in pairs(package.loaded) do
|
||||
if mod:match("^kanso%.") then
|
||||
package.loaded[mod] = nil
|
||||
end
|
||||
end
|
||||
M.compile()
|
||||
vim.notify("Kanso: compiled successfully!", vim.log.levels.INFO)
|
||||
M.load(M._CURRENT_THEME)
|
||||
vim.api.nvim_exec_autocmds("ColorScheme", { modeline = false })
|
||||
for mod, _ in pairs(package.loaded) do
|
||||
if mod:match("^kanso%.") then
|
||||
package.loaded[mod] = nil
|
||||
end
|
||||
end
|
||||
M.compile()
|
||||
vim.notify("Kanso: compiled successfully!", vim.log.levels.INFO)
|
||||
M.load(M._CURRENT_THEME)
|
||||
vim.api.nvim_exec_autocmds("ColorScheme", { modeline = false })
|
||||
end, {})
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue