Skip to content

Commit

Permalink
use new treesitter highlight groups
Browse files Browse the repository at this point in the history
  • Loading branch information
danielefongo committed Oct 18, 2022
1 parent cc2b7e2 commit 4304a1c
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
55 changes: 55 additions & 0 deletions lua/themer/modules/core/mapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,60 +322,115 @@ local function get_base(cp)
},

treesitter = {
-- ["@annotation"] = {},
-- TSAnnotation = {},
-- ["@attribute"] = {},
-- TSAttribute = {},
-- ["@boolean"] = { fg = cp.orange },
-- TSBoolean = { fg = cp.orange },
-- ["@character"] = {},
-- TSCharacter = {},
-- ["@comment"] = groups.styles.comment,
-- TSComment = groups.styles.comment,
["@note"] = { link = "DiagnosticInfo" },
TSNote = { link = "DiagnosticInfo" },
["@warning"] = { link = "DiagnosticWarn" },
TSWarning = { link = "DiagnosticWarn" },
["@danger"] = { link = "DiagnosticError" },
TSDanger = { link = "DiagnosticError" },
["@conditional"] = { link = "ThemerConditional" },
TSConditional = { link = "ThemerConditional" },
["@constant.builtin"] = { link = "ThemerConstantBuiltIn" },
TSConstBuiltin = { link = "ThemerConstantBuiltIn" },
-- ["@constant.macro"] = {},
-- TSConstMacro = {},
["@constant"] = { link = "ThemerConstant" },
TSConstant = { link = "ThemerConstant" },
["@constructor"] = { link = "ThemerConstructor" },
TSConstructor = { link = "ThemerConstructor" },
-- ["@text.emphasis"] = {},
-- TSEmphasis = {},
-- ["@error"] = {},
-- TSError = {},
-- ["@exception"] = {},
-- TSException = {},
["@field"] = { link = "ThemerField" },
TSField = { link = "ThemerField" },
-- ["@float"] = {},
-- TSFloat = {},
["@function.builtin"] = { link = "ThemerFunctionBuiltIn" },
TSFuncBuiltin = { link = "ThemerFunctionBuiltIn" },
-- ["@function.macro"] = {},
-- TSFuncMacro = {},
["@function"] = { link = "ThemerFunction" },
TSFunction = { link = "ThemerFunction" },
["@include"] = { link = "ThemerInclude" },
TSInclude = { link = "ThemerInclude" },
["@keyword"] = { link = "ThemerKeyword" },
TSKeyword = { link = "ThemerKeyword" },
["@keyword.function"] = { link = "ThemerKeywordBuiltIn" },
TSKeywordFunction = { link = "ThemerKeywordBuiltIn" },
["@keyword.return"] = { link = "ThemerKeywordBuiltIn" },
TSKeywordReturn = { link = "ThemerKeywordBuiltIn" },
["@keyword.operator"] = { link = "ThemerOperator" },
TSKeywordOperator = { link = "ThemerOperator" },
-- ["@label"] = {},
-- TSLabel = {},
-- ["@text.literal"] = {},
-- TSLiteral = {},
-- ["@method"] = {},
-- TSMethod = {},
-- ["@namespace"] = {},
-- TSNamespace = {},
-- ["@none"] = {},
-- TSNone = {},
-- ["@number"] = {},
-- TSNumber = {},
["@operator"] = { link = "ThemerOperator" },
TSOperator = { link = "ThemerOperator" },
["@parameter"] = { link = "ThemerParameter" },
TSParameter = { link = "ThemerParameter" },
-- ["@parameter.reference"] = {},
-- TSParameterReference = {},
["@property"] = { link = "ThemerProperty" },
TSProperty = { link = "ThemerProperty" },
["@punctuation.bracket"] = { link = "ThemerPunctuation" },
TSPunctBracket = { link = "ThemerPunctuation" },
["@punctuation.delimiter"] = { link = "ThemerPunctuation" },
TSPunctDelimiter = { link = "ThemerPunctuation" },
["@punctuation.special"] = { link = "ThemerPunctuation" },
TSPunctSpecial = { link = "ThemerPunctuation" },
-- ["@repeat"] = {},
-- TSRepeat = {},
-- ["@text.strike"] = {},
-- TSStrike = {},
["@string"] = { link = "ThemerString" },
TSString = { link = "ThemerString" },
-- ["@string.escape"] = { fg = cp.blue },
-- TSStringEscape = { fg = cp.blue },
-- ["@string.regex"] = {},
-- TSStringRegex = {},
-- ["@symbol"] = {},
-- TSSymbol = {},
["@tag"] = { fg = cp.syntax.tag or cp.statement },
TSTag = { fg = cp.syntax.tag or cp.statement },
["@tag.delimiter"] = { link = "ThemerSubtle" },
TSTagDelimiter = { link = "ThemerSubtle" },
["@text"] = { link = "ThemerText" },
TSText = { link = "ThemerText" },
["@text.title"] = { link = "ThemerHeadingH1" },
TSTitle = { link = "ThemerHeadingH1" },
["@type"] = { link = "ThemerType" },
TSType = { link = "ThemerType" },
["@type.builtin"] = { link = "ThemerTypeBuiltIn" },
TSTypeBuiltin = { link = "ThemerTypeBuiltIn" },
["@text.uri"] = { link = "ThemerURI" },
TSURI = { link = "ThemerURI" },
-- ["@text.underline"] = {},
-- TSUnderline = {},
["@variable"] = { link = "ThemerVariable" },
TSVariable = { link = "ThemerVariable" },
["@variable.builtin"] = { link = "ThemerVariableBuiltIn" },
TSVariableBuiltin = { link = "ThemerVariableBuiltIn" },
commentTSDanger = { link = "DiagnosticError" },
commentTSNote = { link = "ThemerTodo" },
Expand Down
4 changes: 4 additions & 0 deletions lua/themer/modules/core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ local exec = vim.api.nvim_command
--- @param group string
--- @param color table
utils.highlight_legacy = function(group, color)
if vim.fn.has("nvim-0.8") == 0 and group:find("@", 1, true) == 1 then
return
end

local parts = { group }
parts[#parts + 1] = color.fg and "guifg=" .. color.fg or nil
parts[#parts + 1] = color.bg and "guibg=" .. color.bg or nil
Expand Down
4 changes: 4 additions & 0 deletions lua/themer/modules/export/nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ local nv = {}
--- @param group string
--- @param color table
local function highlight(group, color)
if vim.fn.has("nvim-0.8") == 0 and group:find("@", 1, true) == 1 then
return
end

local parts = { group }
parts[#parts + 1] = color.fg and "guifg=" .. color.fg or nil
parts[#parts + 1] = color.bg and "guibg=" .. color.bg or nil
Expand Down
25 changes: 25 additions & 0 deletions lua/themer/modules/themes/papa_dark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,30 +141,55 @@ color_palette.remaps = {
},
plugins = {
treesitter = {
["@boolean"] = { link = "Boolean" },
TSBoolean = { link = "Boolean" },
["@character"] = { link = "Character" },
TSCharacter = { link = "Character" },
["@constant"] = { link = "Constant" },
TSConstant = { link = "Constant" },
["@error"] = { link = "Error" },
TSError = { link = "Error" },
["@field"] = { fg = colors.light_blue },
TSField = { fg = colors.light_blue },
["@function"] = { link = "Function" },
TSFunction = { link = "Function" },
["@function.builtin"] = { link = "Function" },
TSFuncBuiltin = { link = "Function" },
["@function.macro"] = { link = "Function" },
TSFuncMacro = { link = "Function" },
["@namespace"] = { fg = colors.cyan },
TSNamespace = { fg = colors.cyan },
["@type"] = { fg = colors.cyan },
TSType = { fg = colors.cyan },
["@type.builtin"] = { fg = colors.blue },
TSTypeBuiltin = { fg = colors.blue },
["@variable"] = { link = "TSField" },
TSVariable = { link = "TSField" },
["@property"] = { link = "TSField" },
TSProperty = { link = "TSField" },
["@keyword"] = { fg = colors.blue },
TSKeyword = { fg = colors.blue },
["@punctuation.bracket"] = { fg = colors.blue },
TSPunctBracket = { fg = colors.blue },
["@constructor"] = { fg = colors.blue },
TSConstructor = { fg = colors.blue },
["@method"] = { link = "Function" },
TSMethod = { link = "Function" },
["@keyword.function"] = { link = "Keyword" },
TSKeywordFunction = { link = "Keyword" },
["@conditional"] = { link = "Keyword" },
TSConditional = { link = "Keyword" },
["@constant.builtin"] = { link = "Keyword" },
TSConstBuiltin = { link = "Keyword" },
["@include"] = { link = "Keyword" },
TSInclude = { link = "Keyword" },
["@variable.builtin"] = { link = "Keyword" },
TSVariableBuiltin = { link = "Keyword" },
["@tag"] = { link = "Keyword" },
TSTag = { link = "Keyword" },
["@text.title"] = { link = "String" },
TSTitle = { link = "String" },
["@label"] = { link = "String" },
TSLabel = { link = "String" },
},

Expand Down

0 comments on commit 4304a1c

Please sign in to comment.