feat(syntax)!: add additional syntax styles.

Introduce new styles options in order to be able to customize a
bit more the rose pine colorscheme syntax and not depend exclusively on
italic and bold style options. A new utility function was added in order
to add a custom hl property style for custom syntax styles.
This commit is contained in:
Johan Restrepo 2024-03-16 14:22:28 -05:00
commit 4db28ae644
3 changed files with 23 additions and 9 deletions

View file

@ -179,7 +179,7 @@ local function set_highlights()
Boolean = { fg = palette.rose },
Character = { fg = palette.gold },
Comment = { fg = palette.subtle, italic = styles.italic },
Comment = { fg = palette.subtle, style = styles.comments },
Conditional = { fg = palette.pine },
Constant = { fg = palette.gold },
Debug = { fg = palette.rose },
@ -188,10 +188,10 @@ local function set_highlights()
Error = { fg = palette.love },
Exception = { fg = palette.pine },
Float = { fg = palette.gold },
Function = { fg = palette.rose },
Identifier = { fg = palette.text },
Function = { fg = palette.rose, style = styles.functions },
Identifier = { fg = palette.text, style = styles.variables },
Include = { fg = palette.pine },
Keyword = { fg = palette.pine },
Keyword = { fg = palette.pine, style = styles.keywords },
Label = { fg = palette.foam },
LspCodeLens = { fg = palette.subtle },
LspCodeLensSeparator = { fg = palette.muted },
@ -266,9 +266,9 @@ local function set_highlights()
mkdURL = { link = "markdownUrl" },
--- Identifiers
["@variable"] = { fg = palette.text, italic = styles.italic },
["@variable.builtin"] = { fg = palette.love, bold = styles.bold },
["@variable.parameter"] = { fg = palette.iris, italic = styles.italic },
["@variable"] = { fg = palette.text, style = styles.variables },
["@variable.builtin"] = { fg = palette.love },
["@variable.parameter"] = { fg = palette.iris },
["@variable.member"] = { fg = palette.foam },
["@constant"] = { fg = palette.gold },
@ -303,7 +303,7 @@ local function set_highlights()
-- ["@type.qualifier"] = {},
-- ["@attribute"] = {},
["@property"] = { fg = palette.foam, italic = styles.italic },
["@property"] = { fg = palette.foam, style = styles.variables },
--- Functions
["@function"] = { fg = palette.rose },
@ -857,7 +857,7 @@ local function set_highlights()
if highlight.blend ~= nil and (highlight.blend >= 0 and highlight.blend <= 100) and highlight.bg ~= nil then
highlight.bg = utilities.blend(highlight.bg, highlight.blend_on or palette.base, highlight.blend / 100)
end
vim.api.nvim_set_hl(0, group, highlight)
utilities.highlight(group, highlight)
end
--- Terminal

View file

@ -30,6 +30,10 @@ config.options = {
},
styles = {
comments = { italic = true },
functions = {},
keywords = { italic = true },
variables = {},
bold = true,
italic = true,
transparency = false,

View file

@ -44,4 +44,14 @@ function utilities.blend(fg, bg, alpha)
return string.format("#%02X%02X%02X", blend_channel(1), blend_channel(2), blend_channel(3))
end
---@param group string
---@param hl table<string, boolean>
function utilities.highlight(group, hl)
if hl.style then
hl = vim.tbl_extend("force", hl, hl.style)
hl.style = nil
end
vim.api.nvim_set_hl(0, group, hl)
end
return utilities