feat\!: replace disableItalics with italics config option

Replace the negative boolean `disableItalics` with positive `italics` option for better API ergonomics. This affects all italic styling throughout the theme including comments, keywords, and plugin highlights.

BREAKING CHANGE: Users must update their configuration from `disableItalics = true` to `italics = false`.
This commit is contained in:
Webhooked
2025-05-31 14:11:00 +02:00
parent c0355d2c16
commit 138f08461f
5 changed files with 10 additions and 18 deletions
+2 -2
View File
@@ -75,6 +75,7 @@ There is no need to call setup if you are ok with the defaults.
-- Default options: -- Default options:
require('kanso').setup({ require('kanso').setup({
bold = true, -- enable bold fonts bold = true, -- enable bold fonts
italics = true, -- enable italics
compile = false, -- enable compiling the colorscheme compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls undercurl = true, -- enable undercurls
commentStyle = { italic = true }, commentStyle = { italic = true },
@@ -82,7 +83,6 @@ require('kanso').setup({
keywordStyle = { italic = true}, keywordStyle = { italic = true},
statementStyle = {}, statementStyle = {},
typeStyle = {}, typeStyle = {},
disableItalics = false,
transparent = false, -- do not set background color transparent = false, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC` dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17} terminalColors = true, -- define vim.g.terminal_color_{0,17}
@@ -235,7 +235,7 @@ require('kanso').setup({
overrides = function(colors) overrides = function(colors)
return { return {
-- Assign a static color to strings -- Assign a static color to strings
String = { fg = colors.palette.carpYellow, italic = not config.disableItalics }, String = { fg = colors.palette.carpYellow, italic = config.italics },
-- theme colors will update dynamically when you change theme! -- theme colors will update dynamically when you change theme!
SomePluginHl = { fg = colors.theme.syn.type, bold = true }, SomePluginHl = { fg = colors.theme.syn.type, bold = true },
} }
+2 -2
View File
@@ -62,7 +62,7 @@ function M.setup(colors, config)
NvimTreeSymlink = { link = "Type" }, NvimTreeSymlink = { link = "Type" },
NvimTreeFolderName = { link = "Directory" }, NvimTreeFolderName = { link = "Directory" },
NvimTreeExecFile = { fg = theme.syn.string, bold = config.bold }, NvimTreeExecFile = { fg = theme.syn.string, bold = config.bold },
NvimTreeOpenedFile = { fg = theme.syn.special1, italic = not config.disableItalics }, NvimTreeOpenedFile = { fg = theme.syn.special1, italic = config.italics },
NvimTreeWinSeparator = { link = "WinSeparator" }, NvimTreeWinSeparator = { link = "WinSeparator" },
NvimTreeWindowPicker = { NvimTreeWindowPicker = {
bg = config.transparent and theme.ui.none or theme.ui.bg_m1, bg = config.transparent and theme.ui.none or theme.ui.bg_m1,
@@ -482,7 +482,7 @@ function M.setup(colors, config)
NeotestFile = { fg = theme.syn.fun }, NeotestFile = { fg = theme.syn.fun },
NeotestFocused = { bold = config.bold, underline = true }, NeotestFocused = { bold = config.bold, underline = true },
NeotestIndent = { fg = theme.ui.special, bold = config.bold }, NeotestIndent = { fg = theme.ui.special, bold = config.bold },
NeotestMarked = { fg = theme.diag.warning, italic = not config.disableItalics }, NeotestMarked = { fg = theme.diag.warning, italic = config.italics },
NeotestNamespace = { fg = theme.syn.fun }, NeotestNamespace = { fg = theme.syn.fun },
NeotestPassed = { fg = theme.diag.ok }, NeotestPassed = { fg = theme.diag.ok },
NeotestRunning = { fg = theme.vcs.changed }, NeotestRunning = { fg = theme.vcs.changed },
+3 -11
View File
@@ -9,11 +9,7 @@ function M.setup(colors, config)
return { return {
-- *Comment any comment -- *Comment any comment
Comment = vim.tbl_extend( Comment = vim.tbl_extend("force", { fg = theme.syn.comment }, not config.italics and {} or config.commentStyle),
"force",
{ fg = theme.syn.comment },
config.disableItalics and {} or config.commentStyle
),
-- *Constant any constant -- *Constant any constant
Constant = { fg = theme.syn.constant }, Constant = { fg = theme.syn.constant },
@@ -41,11 +37,7 @@ function M.setup(colors, config)
-- Operator "sizeof", "+", "*", etc. -- Operator "sizeof", "+", "*", etc.
Operator = { fg = theme.syn.operator }, Operator = { fg = theme.syn.operator },
-- Keyword any other keyword -- Keyword any other keyword
Keyword = vim.tbl_extend( Keyword = vim.tbl_extend("force", { fg = theme.syn.keyword }, not config.italics and {} or config.keywordStyle),
"force",
{ fg = theme.syn.keyword },
config.disableItalics and {} or config.keywordStyle
),
-- Exception try, catch, throw -- Exception try, catch, throw
Exception = { fg = theme.syn.special2 }, Exception = { fg = theme.syn.special2 },
@@ -74,7 +66,7 @@ function M.setup(colors, config)
-- *Underlined text that stands out, HTML links -- *Underlined text that stands out, HTML links
Underlined = { fg = theme.syn.special1, underline = true }, Underlined = { fg = theme.syn.special1, underline = true },
Bold = { bold = config.bold }, Bold = { bold = config.bold },
Italic = { italic = not config.disableItalics }, Italic = { italic = config.italics },
-- *Ignore left blank, hidden |hl-Ignore| -- *Ignore left blank, hidden |hl-Ignore|
Ignore = { link = "NonText" }, Ignore = { link = "NonText" },
+2 -2
View File
@@ -9,7 +9,7 @@ function M.setup(colors, config)
-- @variable various variable names -- @variable various variable names
["@variable"] = { fg = theme.ui.fg }, ["@variable"] = { fg = theme.ui.fg },
-- @variable.builtin (Special) built-in variable names (e.g. `this`, `self`) -- @variable.builtin (Special) built-in variable names (e.g. `this`, `self`)
["@variable.builtin"] = { fg = theme.syn.special2, italic = not config.disableItalics }, ["@variable.builtin"] = { fg = theme.syn.special2, italic = config.italics },
-- @variable.parameter parameters of a function -- @variable.parameter parameters of a function
["@variable.parameter"] = { fg = theme.syn.parameter }, ["@variable.parameter"] = { fg = theme.syn.parameter },
-- @variable.parameter.builtin special parameters (e.g. `_`, `it`) -- @variable.parameter.builtin special parameters (e.g. `_`, `it`)
@@ -80,7 +80,7 @@ function M.setup(colors, config)
["@keyword.return"] = vim.tbl_extend( ["@keyword.return"] = vim.tbl_extend(
"force", "force",
{ fg = theme.syn.special3 }, { fg = theme.syn.special3 },
config.disableItalics and {} or config.keywordStyle not config.italics and {} or config.keywordStyle
), ),
-- @keyword.debug keywords related to debugging -- @keyword.debug keywords related to debugging
-- @keyword.exception keywords related to exceptions (e.g. `throw`, `catch`) -- @keyword.exception keywords related to exceptions (e.g. `throw`, `catch`)
+1 -1
View File
@@ -9,6 +9,7 @@ local M = {}
---@class KansoConfig ---@class KansoConfig
M.config = { M.config = {
bold = true, bold = true,
italics = true,
undercurl = true, undercurl = true,
commentStyle = { italic = true }, commentStyle = { italic = true },
functionStyle = {}, functionStyle = {},
@@ -18,7 +19,6 @@ M.config = {
transparent = false, transparent = false,
dimInactive = false, dimInactive = false,
terminalColors = true, terminalColors = true,
disableItalics = false,
colors = { theme = { zen = {}, pearl = {}, ink = {}, all = {} }, palette = {} }, colors = { theme = { zen = {}, pearl = {}, ink = {}, all = {} }, palette = {} },
---@type fun(colors: KansoColorsSpec): table<string, table> ---@type fun(colors: KansoColorsSpec): table<string, table>
overrides = function() overrides = function()