fix: added new @.. default links. Fixes #250

This commit is contained in:
Folke Lemaitre
2022-10-18 15:11:16 +02:00
parent 9fba0cdd05
commit 95cf1151e4
2 changed files with 290 additions and 1 deletions

View File

@@ -1,7 +1,12 @@
local M = {}
function M.new_style()
---@diagnostic disable-next-line: undefined-field
return vim.treesitter.highlighter.hl_map == nil
end
function M.get(group)
if group:sub(1, 1) ~= "@" or not vim.treesitter.highlighter.hl_map then
if group:sub(1, 1) ~= "@" or M.new_style() then
return group
end
@@ -125,4 +130,284 @@ M.fallbacks = {
["variable.builtin"] = "TSVariableBuiltin",
}
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 = "TSFunction",
},
["@function.macro"] = {
default = true,
link = "Macro",
},
["@include"] = {
default = true,
link = "Include",
},
["@keyword"] = {
default = true,
link = "Keyword",
},
["@keyword.function"] = {
default = true,
link = "Keyword",
},
["@keyword.operator"] = {
default = true,
link = "TSOperator",
},
["@keyword.return"] = {
default = true,
link = "TSKeyword",
},
["@label"] = {
default = true,
link = "Label",
},
["@method"] = {
default = true,
link = "Function",
},
["@method.call"] = {
default = true,
link = "TSMethod",
},
["@namespace"] = {
default = true,
link = "Include",
},
["@none"] = {
default = true,
},
["@number"] = {
default = true,
link = "Number",
},
["@operator"] = {
default = true,
link = "Operator",
},
["@parameter"] = {
default = true,
link = "Identifier",
},
["@parameter.reference"] = {
default = true,
link = "TSParameter",
},
["@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 = "TSProperty",
},
["@tag.delimiter"] = {
default = true,
link = "Delimiter",
},
["@text"] = {
default = true,
link = "TSNone",
},
["@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",
},
["@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 = "Type",
},
["@variable.builtin"] = {
default = true,
link = "Special",
},
}
return M

View File

@@ -178,6 +178,10 @@ function M.load(theme)
vim.o.termguicolors = true
vim.g.colors_name = "tokyonight"
if ts.new_style() then
M.syntax(ts.defaults)
end
M.syntax(theme.highlights)
-- vim.api.nvim_set_hl_ns(M.ns)