From 1c8ecee21a85bf7423c9100d80372296d92eed6f Mon Sep 17 00:00:00 2001 From: Tommaso Negri Date: Fri, 5 Dec 2025 17:48:26 +0100 Subject: [PATCH] Define syntax highlighting --- lua/mycolortheme/highlights/syntax.lua | 43 +++++++++++++ lua/mycolortheme/highlights/treesitter.lua | 73 ++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 lua/mycolortheme/highlights/syntax.lua create mode 100644 lua/mycolortheme/highlights/treesitter.lua diff --git a/lua/mycolortheme/highlights/syntax.lua b/lua/mycolortheme/highlights/syntax.lua new file mode 100644 index 0000000..1110521 --- /dev/null +++ b/lua/mycolortheme/highlights/syntax.lua @@ -0,0 +1,43 @@ +local M = {} + +function M.setup(colors, config) + return { + Comment = { fg = colors.yellow.regular, italic = true }, + + Constant = { fg = colors.purple.regular }, + Boolean = { link = "Constant" }, + String = { fg = colors.green.regular }, + Character = { link = "String" }, + Number = { link = "Constant" }, + Float = { link = "Number" }, + Operator = { fg = colors.dimmed }, + + Identifier = { link = "Normal" }, + Function = { fg = colors.blue.regular }, + Statement = { link = "Normal" }, + Conditional = { link = "Statement" }, + Repeat = { link = "Statement" }, + Label = { link = "Statement" }, + Keyword = { link = "Statement" }, + Exception = { link = "Statement" }, + PreProc = { link = "Statement" }, + Include = { link = "Statement" }, + Define = { link = "Statement" }, + Macro = { link = "Statement" }, + PreCondit = { link = "Statement" }, + Type = { link = "Statement" }, + StorageClass = { link = "Statement" }, + Structure = { link = "Statement" }, + Typedef = { link = "Statement" }, + + Delimiter = { fg = colors.dimmed }, + + Special = { fg = colors.dimmed }, + SpecialComment = { link = "Special" }, + + Underlined = { underline = true }, + Italic = { italic = true }, + } +end + +return M diff --git a/lua/mycolortheme/highlights/treesitter.lua b/lua/mycolortheme/highlights/treesitter.lua new file mode 100644 index 0000000..491b2f2 --- /dev/null +++ b/lua/mycolortheme/highlights/treesitter.lua @@ -0,0 +1,73 @@ +local M = {} + +function M.setup(colors, config) + return { + ["@comment"] = { fg = colors.yellow.regular }, + + ["@constant"] = { fg = colors.purple.regular }, + ["@constant.builtin"] = { link = "@constant" }, + ["@string"] = { fg = colors.green.regular }, + ["@string.regex"] = { link = "@string" }, -- TODO: Differentiate regex + ["@string.escape"] = { link = "@string" }, + ["@number"] = { link = "@constant" }, + ["@boolean"] = { link = "@constant" }, + + ["@operator"] = { fg = colors.dimmed }, + + ["@function"] = { fg = colors.blue.regular }, + ["@function.call"] = { fg = colors.fg }, + ["@function.method.call"] = { link = "@function.call" }, + ["@function.builtin"] = { link = "@function" }, + ["@function.macro"] = { link = "@function" }, + ["@method"] = { link = "@function.call" }, + ["@method.call"] = { link = "@method" }, + + ["@keyword"] = { fg = colors.fg }, + ["@keyword.function"] = { link = "@keyword" }, + ["@keyword.operator"] = { link = "@keyword" }, + ["@keyword.return"] = { link = "@keyword" }, + + ["@punctuation"] = { fg = colors.dimmed }, + ["@punctuation.delimiter"] = { link = "@punctuation" }, + ["@punctuation.bracket"] = { link = "@punctuation" }, + ["@punctuation.special"] = { link = "@punctuation" }, + + ["@variable"] = { fg = colors.fg }, + ["@variable.builtin"] = { link = "@variable" }, + ["@variable.parameter"] = { link = "@variable" }, + ["@variable.member"] = { link = "@variable" }, + + ["@type"] = { fg = colors.fg }, + ["@type.builtin"] = { link = "@type" }, + ["@type.definition"] = { link = "@type" }, + ["@type.qualifier"] = { link = "@type" }, + ["@tag"] = { fg = colors.yellow.regular }, + ["@tag.attribute"] = { fg = colors.fg }, + ["@tag.delimiter"] = { link = "@punctuation" }, + + ["@symbol"] = { fg = colors.blue.regular }, + + ["@string.special"] = { fg = colors.dimmed }, + + -- ["@attribute"] = { link = "Normal" }, + -- ["@constructor"] = { link = "Normal" }, + -- ["@conditional"] = { link = "Normal" }, + -- ["@error"] = { link = "Normal" }, -- TODO: Add proper error color + -- ["@exception"] = { link = "Normal" }, + -- ["@field"] = { link = "Normal" }, + -- ["@label"] = { link = "Normal" }, + -- ["@module"] = { link = "Normal" }, + -- ["@namespace"] = { link = "Normal" }, + -- -- ["@none"] = { fg = colors.purple.regular }, + -- ["@parameter"] = { link = "Normal" }, + -- ["@parameter.reference"] = { link = "Normal" }, + -- ["@property"] = { link = "Normal" }, + -- ["@repeat"] = { link = "Normal" }, + -- ["@symbol"] = { link = "String" }, + -- ["@text"] = { link = "Normal" }, + -- ["@text.note"] = { fg = colors.blue.regular }, + -- ["@text.warning"] = { link = "Normal" }, -- TODO: Add proper error color + } +end + +return M