fix!: add treesitter default groups to theme

This commit is contained in:
Folke Lemaitre 2024-01-20 11:38:46 +01:00
parent 66cfdc12b0
commit bddedb17bd
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
3 changed files with 51 additions and 303 deletions

View File

@ -208,7 +208,57 @@ function M.setup()
DapStoppedLine = { bg = util.darken(c.warning, 0.1) }, -- Used for "Warning" diagnostic virtual text DapStoppedLine = { bg = util.darken(c.warning, 0.1) }, -- Used for "Warning" diagnostic virtual text
-- These groups are for the Neovim tree-sitter highlights. -- These groups are for the Neovim tree-sitter highlights.
-- As of writing, tree-sitter support is a WIP, group names may change. ["@annotation"] = { link = "PreProc" },
["@attribute"] = { link = "PreProc" },
["@boolean"] = { link = "Boolean" },
["@character"] = { link = "Character" },
["@character.special"] = { link = "SpecialChar" },
["@comment"] = { link = "Comment" },
["@conditional"] = { link = "Conditional" },
["@constant"] = { link = "Constant" },
["@constant.builtin"] = { link = "Special" },
["@constant.macro"] = { link = "Define" },
["@debug"] = { link = "Debug" },
["@define"] = { link = "Define" },
["@exception"] = { link = "Exception" },
["@float"] = { link = "Float" },
["@function"] = { link = "Function" },
["@function.builtin"] = { link = "Special" },
["@function.call"] = { link = "@function" },
["@function.macro"] = { link = "Macro" },
["@include"] = { link = "Include" },
["@keyword.coroutine"] = { link = "@keyword" },
["@keyword.operator"] = { link = "@operator" },
["@keyword.return"] = { link = "@keyword" },
["@method"] = { link = "Function" },
["@method.call"] = { link = "@method" },
["@none"] = {},
["@number"] = { link = "Number" },
["@preproc"] = { link = "PreProc" },
["@repeat"] = { link = "Repeat" },
["@storageclass"] = { link = "StorageClass" },
["@string"] = { link = "String" },
["@string.special"] = { link = "SpecialChar" },
["@symbol"] = { link = "Identifier" },
["@tag"] = { link = "Label" },
["@tag.attribute"] = { link = "@property" },
["@tag.delimiter"] = { link = "Delimiter" },
["@text"] = { link = "@none" },
["@text.emphasis"] = { italic = true },
["@text.environment"] = { link = "Macro" },
["@text.environment.name"] = { link = "Type" },
["@text.literal"] = { link = "String" },
["@text.math"] = { link = "Special" },
["@text.note"] = { link = "SpecialComment" },
["@text.strike"] = { strikethrough = true },
["@text.strong"] = { bold = true },
["@text.title"] = { link = "Title" },
["@text.todo"] = { link = "Todo" },
["@text.underline"] = { underline = true },
["@text.uri"] = { link = "Underlined" },
["@type"] = { link = "Type" },
["@type.definition"] = { link = "Typedef" },
["@type.qualifier"] = { link = "@keyword" },
--- Misc --- Misc
-- TODO: -- TODO:

View File

@ -1,288 +0,0 @@
local M = {}
function M.new_style()
---@diagnostic disable-next-line: undefined-field
return vim.treesitter.highlighter.hl_map == nil
end
M.defaults = {
["@annotation"] = {
default = true,
link = "PreProc",
},
["@attribute"] = {
default = true,
link = "PreProc",
},
["@boolean"] = {
default = true,
link = "Boolean",
},
["@character"] = {
default = true,
link = "Character",
},
["@character.special"] = {
default = true,
link = "SpecialChar",
},
["@comment"] = {
default = true,
link = "Comment",
},
["@conditional"] = {
default = true,
link = "Conditional",
},
["@constant"] = {
default = true,
link = "Constant",
},
["@constant.builtin"] = {
default = true,
link = "Special",
},
["@constant.macro"] = {
default = true,
link = "Define",
},
["@constructor"] = {
default = true,
link = "Special",
},
["@debug"] = {
default = true,
link = "Debug",
},
["@define"] = {
default = true,
link = "Define",
},
["@exception"] = {
default = true,
link = "Exception",
},
["@field"] = {
default = true,
link = "Identifier",
},
["@float"] = {
default = true,
link = "Float",
},
["@function"] = {
default = true,
link = "Function",
},
["@function.builtin"] = {
default = true,
link = "Special",
},
["@function.call"] = {
default = true,
link = "@function",
},
["@function.macro"] = {
default = true,
link = "Macro",
},
["@include"] = {
default = true,
link = "Include",
},
["@keyword"] = {
default = true,
link = "Keyword",
},
["@keyword.coroutine"] = {
default = true,
link = "@keyword",
},
["@keyword.function"] = {
default = true,
link = "Keyword",
},
["@keyword.operator"] = {
default = true,
link = "@operator",
},
["@keyword.return"] = {
default = true,
link = "@keyword",
},
["@label"] = {
default = true,
link = "Label",
},
["@method"] = {
default = true,
link = "Function",
},
["@method.call"] = {
default = true,
link = "@method",
},
["@namespace"] = {
default = true,
link = "Include",
},
["@none"] = {
default = true,
},
["@number"] = {
default = true,
link = "Number",
},
["@operator"] = {
default = true,
link = "Operator",
},
["@parameter"] = {
default = true,
link = "Identifier",
},
["@preproc"] = {
default = true,
link = "PreProc",
},
["@property"] = {
default = true,
link = "Identifier",
},
["@punctuation.bracket"] = {
default = true,
link = "Delimiter",
},
["@punctuation.delimiter"] = {
default = true,
link = "Delimiter",
},
["@punctuation.special"] = {
default = true,
link = "Delimiter",
},
["@repeat"] = {
default = true,
link = "Repeat",
},
["@storageclass"] = {
default = true,
link = "StorageClass",
},
["@string"] = {
default = true,
link = "String",
},
["@string.escape"] = {
default = true,
link = "SpecialChar",
},
["@string.regex"] = {
default = true,
link = "String",
},
["@string.special"] = {
default = true,
link = "SpecialChar",
},
["@symbol"] = {
default = true,
link = "Identifier",
},
["@tag"] = {
default = true,
link = "Label",
},
["@tag.attribute"] = {
default = true,
link = "@property",
},
["@tag.delimiter"] = {
default = true,
link = "Delimiter",
},
["@text"] = {
default = true,
link = "@none",
},
["@text.danger"] = {
default = true,
link = "WarningMsg",
},
["@text.emphasis"] = {
default = true,
italic = true,
},
["@text.environment"] = {
default = true,
link = "Macro",
},
["@text.environment.name"] = {
default = true,
link = "Type",
},
["@text.literal"] = {
default = true,
link = "String",
},
["@text.math"] = {
default = true,
link = "Special",
},
["@text.note"] = {
default = true,
link = "SpecialComment",
},
["@text.reference"] = {
default = true,
link = "Constant",
},
["@text.strike"] = {
strikethrough = true,
},
["@text.strong"] = {
bold = true,
default = true,
},
["@text.title"] = {
default = true,
link = "Title",
},
["@text.underline"] = {
underline = true,
},
["@text.uri"] = {
default = true,
link = "Underlined",
},
["@text.warning"] = {
default = true,
link = "Todo",
},
["@text.todo"] = {
default = true,
link = "Todo",
},
["@type"] = {
default = true,
link = "Type",
},
["@type.builtin"] = {
default = true,
link = "Type",
},
["@type.definition"] = {
default = true,
link = "Typedef",
},
["@type.qualifier"] = {
default = true,
link = "@keyword",
},
["@variable.builtin"] = {
default = true,
link = "Special",
},
}
return M

View File

@ -1,5 +1,3 @@
local ts = require("tokyonight.treesitter")
local M = {} local M = {}
M.bg = "#000000" M.bg = "#000000"
@ -51,10 +49,6 @@ end
---@param group string ---@param group string
function M.highlight(group, hl) function M.highlight(group, hl)
group = ts.get(group)
if not group then
return
end
if hl.style then if hl.style then
if type(hl.style) == "table" then if type(hl.style) == "table" then
hl = vim.tbl_extend("force", hl, hl.style) hl = vim.tbl_extend("force", hl, hl.style)
@ -189,14 +183,6 @@ function M.load(theme)
vim.o.termguicolors = true vim.o.termguicolors = true
vim.g.colors_name = "tokyonight" vim.g.colors_name = "tokyonight"
if ts.new_style() then
for group, colors in pairs(ts.defaults) do
if not theme.highlights[group] then
M.highlight(group, colors)
end
end
end
M.syntax(theme.highlights) M.syntax(theme.highlights)
-- vim.api.nvim_set_hl_ns(M.ns) -- vim.api.nvim_set_hl_ns(M.ns)