From 078a9d67323f4aa6cb8a0e1ce2d5985189716fdb Mon Sep 17 00:00:00 2001 From: Tyler Miller Date: Fri, 26 May 2023 13:23:43 -0700 Subject: [PATCH] fix: fix incorrect syntax highlighting Syntax highlighting is still not 100% accurate (due mostly to highlighting differences between different languages which require particular consideration), however, the accuracy of the highlights have been improved, both overall, and in terms of common languages such as: rust, ruby, ecma, c, c#, go, html, css, make, python, and lua. Fixes #252 --- lua/github-theme/group/modules/treesitter.lua | 242 ++++++++++-------- lua/github-theme/group/syntax.lua | 28 ++ lua/github-theme/palette/github_dark.lua | 20 +- .../palette/github_dark_colorblind.lua | 20 +- .../palette/github_dark_dimmed.lua | 22 +- .../palette/github_dark_high_contrast.lua | 20 +- .../palette/github_dark_tritanopia.lua | 20 +- lua/github-theme/palette/github_light.lua | 22 +- .../palette/github_light_colorblind.lua | 20 +- .../palette/github_light_high_contrast.lua | 44 ++-- .../palette/github_light_tritanopia.lua | 44 ++-- 11 files changed, 331 insertions(+), 171 deletions(-) diff --git a/lua/github-theme/group/modules/treesitter.lua b/lua/github-theme/group/modules/treesitter.lua index 1852f2ee..65e46382 100644 --- a/lua/github-theme/group/modules/treesitter.lua +++ b/lua/github-theme/group/modules/treesitter.lua @@ -1,12 +1,48 @@ local M = {} function M.get(spec, config, opts) + -- TODO: Consider refactoring this out once the primitives are finished + -- being integrated. + local primitives = require( + 'github-theme.palette.primitives.' + .. require('github-theme.config').theme:gsub('^github%W*', '', 1) + ) + + local pl = primitives.prettylights local syn = spec.syntax local stl = config.styles local P = spec.palette + ---Clears nvim's default highlighting for a highlight-group and allows + ---falling-back to another hl-group when multiple highlights/groups are + ---assigned/stacked at a particular screen position. This is just an empty + ---table. + --- + ---NOTE: assigning this to a group is different from explicitly setting a + ---group's foreground color to the global/default foreground color. When + ---multiple highlights are stacked/assigned to the same screen position, this + ---will allow the other highlights/groups to take effect, whereas explicitly + ---setting a hl-group's `fg` will not. In some cases, this effect is desirable + ---(e.g. `['@constructor.ecma'] = NONE` which allows the `constructor` in + ---`constructor() {}` to fallback to the `@method` hl-group), while in other + ---cases, it may not be. + --- + ---| Setting | Fallback | + ---| ------------------------------------------------------------ | -------- | + ---| `GROUP = FALLBACK_OR_NONE` (i.e. set to this variable) (Lua) | true | + ---| Link to `@none`, `Fg`, or `NONE` | true | + ---| `GROUP = { fg = DEFAULT_FG }` (Lua) | false | + ---| `hi! clear GROUP` (Vim command) | false | + ---| `hi! GROUP NONE` (Vim command) | false | + local FALLBACK_OR_NONE = setmetatable({}, { + __newindex = function() + error('attempt to set index of readonly table', 2) + end, + }) + if vim.treesitter.highlighter.hl_map then - require('github-theme.lib.log').warn([[nvim-treesitter integration requires neovim 0.8 + require('github-theme.lib.log').warn([[ +nvim-treesitter integration requires neovim 0.8 If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch. ]]) return {} @@ -15,104 +51,103 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch -- stylua: ignore return { -- Misc - -- ['@comment'] = { link = 'Comment' }, - ['@error'] = { link = 'Error' }, - ['@preproc'] = { link = 'PreProc' }, -- various preprocessor directives & shebangs - -- ['@define'] = { link = 'Define' }, -- preprocessor definition directives - -- ['@operator'] = { link = 'Operator' }, -- For any operator: +, but also -> and * in C. + -- ['@comment'] = { link = 'Comment' }, + ['@error'] = { link = 'Error' }, + ['@preproc'] = { link = 'PreProc' }, -- Various preprocessor directives & shebangs + -- ['@define'] = { link = 'Define' }, -- Preprocessor definition directives + -- ['@operator'] = { link = 'Operator' }, -- For any operator: +, but also -> and * in C -- Punctuation - ['@punctuation.delimiter'] = { fg = syn.bracket }, -- For delimiters ie: . - ['@punctuation.bracket'] = { fg = syn.bracket }, -- For brackets and parenthesis. - ['@punctuation.special'] = { fg = syn.builtin2, style = stl.operators }, -- For special punctutation that does not fall in the catagories before. + -- ['@punctuation.delimiter'] = { fg = syn.bracket }, -- For delimiters (e.g. `.`) + ['@punctuation.bracket'] = { fg = syn.bracket }, -- For brackets and parenthesis + ['@punctuation.special'] = { fg = syn.builtin2, style = stl.operators }, -- For special punctutation that does not fall in the catagories before -- Literals - -- ['@string'] = { link = 'String' }, -- For strings. - ['@string.regex'] = { fg = syn.regex, style = stl.strings }, -- Regular expression literals. - ['@string.escape'] = { fg = syn.regex, style = 'bold' }, -- Escape characters within a string: `\n`, `\t`, etc. - ['@string.special'] = { link = 'Special' }, -- other special strings (e.g. dates) + -- ['@string'] = { link = 'String' }, -- For strings + ['@string.regex'] = { fg = syn.regex, style = stl.strings }, -- Regular expression literals + ['@string.escape'] = { fg = syn.regex, style = 'bold' }, -- Escape characters within a string: `\n`, `\t`, etc. + ['@string.special'] = { link = 'Special' }, -- Other special strings (e.g. dates) - -- ['@character'] = { link = 'Character' }, -- character literals - -- ['@character.special'] = { link = 'SpecialChar' }, -- special characters (e.g. wildcards) + -- ['@character'] = { link = 'Character' }, -- character literals + -- ['@character.special'] = { link = 'SpecialChar' }, -- special characters (e.g. wildcards) - -- ['@boolean'] = { link = 'Boolean' }, -- For booleans. - -- ['@number'] = { link = 'Number' }, -- For all numbers - -- ['@float'] = { link = 'Float' }, -- For floats. + -- ['@boolean'] = { link = 'Boolean' }, -- For booleans + -- ['@number'] = { link = 'Number' }, -- For all numbers + -- ['@float'] = { link = 'Float' }, -- For floats -- Functions - -- ['@function'] = { link = 'Function' }, -- For function (calls and definitions). - ['@function.builtin'] = { fg = syn.builtin2, style = stl.functions }, -- For builtin functions: table.insert in Lua. - -- ['@function.call'] = { link = '@function' }, -- function calls - ['@function.macro'] = { fg = syn.builtin0, style = stl.functions }, -- For macro defined functions (calls and definitions): each macro_rules in RusC. - -- ['@method'] = { link = '@function'}, -- For method definitions/declarations. - - -- ['@method.call'] = { link = '@method' }, -- method calls + -- ['@function'] = { link = 'Function' }, -- For function (calls and definitions) + ['@function.builtin'] = FALLBACK_OR_NONE, -- For builtin functions: table.insert in Lua + -- ['@function.call'] = { link = '@function' }, -- Function calls + ['@function.macro'] = { fg = syn.builtin0, style = stl.functions }, -- Macro defined functions (calls & definitions): each macro_rules in RusC + -- ['@method'] = { link = '@function'}, -- For method definitions/declarations + -- ['@method.call'] = { link = '@method' }, -- Method calls - ['@constructor'] = { fg = syn.ident }, -- For constructor calls and definitions: = { } in Lua, and Java constructors. - ['@parameter'] = { fg = syn.param, stl.variables }, -- For parameters of a function. + ['@constructor'] = FALLBACK_OR_NONE, -- For constructor calls and definitions: = {} in Lua, Java constructors + ['@parameter'] = { fg = syn.param, stl.variables }, -- For parameters of a function -- Keywords - -- ['@keyword'] = { link = 'Keyword' }, -- For keywords that don't fall in previous categories. - ['@keyword.function'] = { fg = syn.keyword, style = stl.functions }, -- Keywords used to define a function: `function` in Lua, `def` and `lambda` in Python. - ['@keyword.operator'] = { fg = syn.operator, style = stl.operators }, -- For new keyword operator - ['@keyword.return'] = { fg = syn.builtin0, style = stl.keywords }, + -- ['@keyword'] = { link = 'Keyword' }, -- For keywords that don't fall in previous categories + ['@keyword.function'] = { fg = syn.keyword, style = stl.functions }, -- Keywords used to def a fn: `function` in Lua, `def` & `lambda` in Python + ['@keyword.operator'] = { fg = syn.keyword, style = stl.operators }, -- For `new` keyword operator, `sizeof`, etc. + -- ['@keyword.return'] = { fg = syn.keyword, style = stl.keywords }, - -- ['@conditional'] = { link = 'Conditional' }, -- For keywords related to conditionals. - -- ['@repeat'] = { link = 'Repeat' }, -- For keywords related to loops. - -- ['@label'] = { link = 'Label' }, -- For labels: label: in C and :label: in Lua. - -- ['@include'] = { link = 'Include' }, -- For includes: #include in C, use or extern crate in Rust, or require in Lua. - ['@exception'] = { fg = syn.builtin0, style = stl.keywords }, -- Exception related keywords: `try`, `except`, `finally` in Python. + -- ['@conditional'] = { link = 'Conditional' }, -- For keywords related to conditionals. + -- ['@repeat'] = { link = 'Repeat' }, -- For keywords related to loops. + -- ['@label'] = { link = 'Label' }, -- For labels: label: in C and :label: in Lua. + -- ['@include'] = { link = 'Include' }, -- For includes: #include in C, use or extern crate in Rust, Lua require + ['@exception'] = { fg = syn.builtin0, style = stl.keywords }, -- Exception related keywords: `try`, `except`, `finally` in Python -- Types - -- ['@type'] = { link = 'Type' }, -- For types. - ['@type.builtin'] = { fg = syn.builtin1, style = stl.types }, -- For builtin types. - -- ['@type.definition'] = { link = '@type' }, -- type definitions (e.g. `typedef` in C) - -- ['@type.qualifier'] = { link = '@type' }, -- type qualifiers (e.g. `const`) + ['@type'] = { fg = syn.type }, -- For custom/user/non-builtin types + ['@type.builtin'] = { fg = syn.builtin1, style = stl.types }, -- For builtin types + -- ['@type.definition'] = { link = '@type' }, -- type definitions (e.g. `typedef` in C) + ['@type.qualifier'] = { fg = syn.keyword }, -- type qualifiers (e.g. `const`, css's `!important`) - ['@storageclass'] = { link = 'StorageClass' }, -- visibility/life-time/etc. modifiers (e.g. `static`) - ['@attribute'] = { link = 'Constant' }, -- attribute annotations (e.g. Python decorators) - ['@field'] = { fg = syn.field }, -- For fields. - ['@property'] = { link = '@field' }, -- Same as @field. + -- ['@storageclass'] = { link = 'StorageClass' }, -- Visibility/life-time/etc. modifiers (e.g. `static`) + ['@attribute'] = { link = 'Constant' }, -- Attribute annotations (e.g. Python decorators) + ['@field'] = { fg = syn.field }, -- For fields + ['@property'] = { link = '@field' }, -- Same as @field -- Identifiers - ['@variable'] = { fg = syn.variable, style = stl.variables }, -- Any variable name that does not have another highlighC. - ['@variable.builtin'] = { fg = syn.builtin0, style = stl.variables }, -- Variable names that are defined by the languages, like this or self. + ['@variable'] = { fg = syn.variable, style = stl.variables }, -- Any variable name that does not have another highlighC. + ['@variable.builtin'] = { fg = syn.builtin0, style = stl.variables }, -- Variable names that are defined by the languages, like this or self - -- ['@constant'] = { link = 'Constant' }, -- For constants - ['@constant.builtin'] = { fg = syn.builtin2, style = stl.keywords }, -- For constant that are built in the language: nil in Lua. - ['@constant.macro'] = { link = 'Macro' }, -- For constants that are defined by macros: NULL in C. + -- ['@constant'] = { link = 'Constant' }, -- For constants + ['@constant.builtin'] = { fg = syn.builtin2, style = stl.keywords }, -- For constant that are built in the language: nil in Lua + ['@constant.macro'] = { link = 'Macro' }, -- For constants that are defined by macros: NULL in C - ['@namespace'] = { fg = syn.builtin1 }, -- For identifiers referring to modules and namespaces. - ['@symbol'] = { fg = syn.preproc }, + ['@namespace'] = { fg = syn.builtin1 }, -- For identifiers referring to modules and namespaces + ['@symbol'] = { fg = syn.preproc }, -- Text - ['@text'] = { fg = spec.fg1 }, -- For strings considerated text in a markup language. - ['@text.strong'] = { fg = spec.fg1, style = 'bold' }, -- bold - ['@text.emphasis'] = { fg = spec.fg1, style = 'italic' }, -- italic - -- ['@text.underline'] = { link = 'Underlined' }, -- underlined text - ['@text.strike'] = { fg = spec.fg1, style = 'strikethrough' }, -- strikethrough text - -- ['@text.title'] = { link = 'Title'}, -- titles like: # Example - ['@text.literal'] = { fg = syn.ident, style = 'italic' }, -- used for inline code in markdown and for doc in python (''') - ['@text.uri'] = { fg = syn.const, style = 'italic,underline' }, -- urls, links and emails - ['@text.math'] = { fg = syn.func }, -- math environments (e.g. `$ ... $` in LaTeX) - ['@text.environment'] = { fg = syn.preproc }, -- text environments of markup languages - ['@text.environment.name'] = { fg = syn.func }, -- text indicating the type of an environment - ['@text.reference'] = { fg = spec.fg1, style = 'underline' }, -- references - - ['@text.todo'] = { fg = spec.bg1, bg = spec.diag.hint }, -- todo notes - ['@text.note'] = { fg = spec.bg1, bg = spec.diag.info }, - ['@text.warning'] = { fg = spec.bg1, bg = spec.diag.warn }, - ['@text.danger'] = { fg = spec.bg1, bg = spec.diag.error }, - ['@text.todo.unchecked'] = { fg = spec.fg3 }, -- For brackets and parens. - ['@text.todo.checked'] = { fg = P.green.base }, -- For brackets and parens. - - ['@text.diff.add'] = { link = 'diffAdded' }, -- added text (for diff files) - ['@text.diff.delete'] = { link = 'diffRemoved' }, -- deleted text (for diff files) + ['@text'] = { fg = spec.fg1 }, -- For strings considerated text in a markup language + ['@text.strong'] = { fg = spec.fg1, style = 'bold' }, -- Bold + ['@text.emphasis'] = { fg = spec.fg1, style = 'italic' }, -- Italic + -- ['@text.underline'] = { link = 'Underlined' }, -- Underlined text + ['@text.strike'] = { fg = spec.fg1, style = 'strikethrough' }, -- Strikethrough text + -- ['@text.title'] = { link = 'Title'}, -- Titles like: # Example + ['@text.literal'] = { fg = syn.ident, style = 'italic' }, -- Used for inline code in markdown and for doc in python (''') + ['@text.uri'] = { fg = syn.const, style = 'italic,underline' }, -- Urls, links and emails + ['@text.math'] = { fg = syn.func }, -- Math environments (e.g. `$ ... $` in LaTeX) + ['@text.environment'] = { fg = syn.preproc }, -- Text environments of markup languages + ['@text.environment.name'] = { fg = syn.func }, -- Text indicating the type of an environment + ['@text.reference'] = { fg = spec.fg1, style = 'underline' }, -- References + + ['@text.todo'] = { fg = spec.bg1, bg = spec.diag.hint }, -- Todo notes + ['@text.note'] = { fg = spec.bg1, bg = spec.diag.info }, + ['@text.warning'] = { fg = spec.bg1, bg = spec.diag.warn }, + ['@text.danger'] = { fg = spec.bg1, bg = spec.diag.error }, + ['@text.todo.unchecked'] = { fg = spec.fg3 }, -- For brackets and parens + ['@text.todo.checked'] = { fg = P.green.base }, -- For brackets and parens + + ['@text.diff.add'] = { link = 'diffAdded' }, -- Added text (for diff files) + ['@text.diff.delete'] = { link = 'diffRemoved' }, -- Deleted text (for diff files) -- Tags - ['@tag'] = { fg = syn.tag }, -- Tags like html tag names. - ['@tag.attribute'] = { fg = syn.func, style = 'italic' }, -- Tags like html tag names. - ['@tag.delimiter'] = { fg = syn.tag }, -- Tag delimiter like < > / + ['@tag'] = { fg = syn.tag }, -- Tags like html tag names + -- ['@tag.attribute'] = { fg = syn.func, style = 'italic' }, -- Tags like html tag names + ['@tag.delimiter'] = FALLBACK_OR_NONE, -- Tag delimiter like `<`, `>`, `/`, etc. -- Language specific ------------------------------------------------------- @@ -121,17 +156,18 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch ['@label.c'] = { fg = spec.variable }, -- CSS - ['@property.css'] = { link = '@constant' }, + -- ['@property.css'] = { link = '@constant' }, ['@type.css'] = { link = 'htmlTag' }, -- C_sharp - ['@type.c_sharp'] = { link = '@function' }, + -- ['@type.c_sharp'] = { link = '@function' }, + ['@namespace.c_sharp'] = { fg = pl.syntax.variable }, -- Go - ['@function.call.go'] = { link = '@constant' }, - ['@function.go'] = { link = '@field' }, - ['@method.call.go'] = { link = '@constant' }, - ['@namespace.go'] = { link = '@field' }, + -- ['@function.call.go'] = { link = '@constant' }, + -- ['@function.go'] = { link = '@field' }, + -- ['@method.call.go'] = { link = '@constant' }, + ['@namespace.go'] = FALLBACK_OR_NONE, -- Html ['@text.title.html'] = { fg = spec.fg1 }, @@ -141,20 +177,28 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch ['@type.java'] = { link = '@function' }, -- JavaScript - ['@property.javascript'] = { link = '@variable' }, - ['@type.javascript'] = { link = '@variable' }, - ['@variable.builtin.javascript'] = { link = '@constant' }, - ['@variable.javascript'] = { link = '@constant' }, + -- ['@constructor.ecma'] = { link = '@method' }, + -- ['@property.javascript'] = { link = '@variable' }, + -- ['@type.ecma'] = { fg = pl.syntax.variable }, + -- ['@variable.builtin.javascript'] = { link = '@constant' }, + -- ['@operator.ecma'] = { fg = spec.const, style = stl.operators }, + -- ['@variable.javascript'] = { link = '@constant' }, -- Json ['@label.json'] = { link = '@constant' }, -- Lua ['@lsp.type.variable.lua'] = { fg = spec.variable }, + -- ['@constructor.lua'] = NONE, + ['@operator.lua'] = { fg = syn.keyword, style = stl.operators }, + ['@field.lua'] = { fg = syn.variable }, + ['@function.call.lua'] = { fg = syn.const }, + ['@method.call.lua'] = { link = '@function.call.lua' }, -- Make - ['@operator.make'] = { link = '@constant' }, + -- ['@operator.make'] = { link = '@constant' }, ['@symbol.make'] = { link = '@function' }, + ['@function.builtin.make'] = { link = '@constant' }, -- Markdown ['@punctuation.delimiter.markdown'] = { fg = spec.fg1 }, @@ -166,21 +210,19 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch -- Python ['@field.python'] = { fg = syn.fg1 }, - ['@function.call.python'] = { fg = syn.fg1 }, - ['@keyword.python'] = { link = '@constant' }, - ['@method.call.python'] = { fg = syn.fg1 }, + -- ['@keyword.python'] = { link = '@constant' }, ['@type.builtin.python'] = { link = '@constant' }, - ['@type.python'] = { link = '@function' }, + -- ['@type.python'] = { link = '@function' }, ['@variable.builtin.python'] = { link = '@constant' }, -- Ruby - ['@function.call.ruby'] = { link = '@constant' }, - ['@label.ruby'] = { link = '@variable' }, + ['@label.ruby'] = { fg = syn.const }, ['@symbol.ruby'] = { link = '@constant' }, - ['@type.ruby'] = { link = '@function' }, -- Rust - ['@field.rust'] = { fg = spec.fg2 }, + -- ['@field.rust'] = { fg = spec.fg2 }, + ['@constant.builtin.rust'] = { fg = pl.syntax.variable }, + -- TODO: rust types should have higher priority than calls (needs query) -- SCSS ['@property.scss'] = { link = '@constant' }, @@ -192,11 +234,11 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch ['@variable.sql'] = { link = '@constant' }, -- TypeScript - ['@constructor.typescript'] = { link = '@function' }, - ['@property.typescript'] = { link = '@variable' }, - ['@type.typescript'] = { link = '@function' }, - ['@variable.builtin.typescript'] = { link = '@constant' }, - ['@variable.typescript'] = { link = '@constant' }, + -- ['@constructor.typescript'] = { link = '@function' }, + -- ['@property.typescript'] = { link = '@variable' }, + -- ['@type.typescript'] = { link = '@function' }, + -- ['@variable.builtin.typescript'] = { link = '@constant' }, + -- ['@variable.typescript'] = { link = '@constant' }, -- Yaml ['@field.yaml'] = { link = '@tag' }, diff --git a/lua/github-theme/group/syntax.lua b/lua/github-theme/group/syntax.lua index 0d4d44bc..73629ead 100644 --- a/lua/github-theme/group/syntax.lua +++ b/lua/github-theme/group/syntax.lua @@ -4,6 +4,33 @@ function M.get(spec, config) local syn = spec.syntax local stl = config.styles + ---Clears nvim's default highlighting for a highlight-group and allows + ---falling-back to another hl-group when multiple highlights/groups are + ---assigned/stacked at a particular screen position. This is just an empty + ---table. + --- + ---NOTE: assigning this to a group is different from explicitly setting a + ---group's foreground color to the global/default foreground color. When + ---multiple highlights are stacked/assigned to the same screen position, this + ---will allow the other highlights/groups to take effect, whereas explicitly + ---setting a hl-group's `fg` will not. In some cases, this effect is desirable + ---(e.g. `['@constructor.ecma'] = NONE` which allows the `constructor` in + ---`constructor() {}` to fallback to the `@method` hl-group), while in other + ---cases, it may not be. + --- + ---| Setting | Fallback | + ---| ------------------------------------------------------------ | -------- | + ---| `GROUP = FALLBACK_OR_NONE` (i.e. set to this variable) (Lua) | true | + ---| Link to `@none`, `Fg`, or `NONE` | true | + ---| `GROUP = { fg = DEFAULT_FG }` (Lua) | false | + ---| `hi! clear GROUP` (Vim command) | false | + ---| `hi! GROUP NONE` (Vim command) | false | + local FALLBACK_OR_NONE = setmetatable({}, { + __newindex = function() + error('attempt to set index of readonly table', 2) + end, + }) + -- TODO: -- (1) add Commented style settings in config module -- stylua: ignore @@ -39,6 +66,7 @@ function M.get(spec, config) -- Structure = { link = 'Type' }, -- struct, union, enum, etc. -- Typedef = { link = 'Type' }, -- A typedef + Special = { fg = spec.fg1 }, -- (preferred) any special symbol -- Special = { fg = syn.ident }, -- (preferred) any special symbol -- SpecialChar = { link = 'Special' }, -- special character in a constant -- Tag = { link = 'Special' }, -- you can use CTRL-] on this diff --git a/lua/github-theme/palette/github_dark.lua b/lua/github-theme/palette/github_dark.lua index 80697c94..1028ac56 100755 --- a/lua/github-theme/palette/github_dark.lua +++ b/lua/github-theme/palette/github_dark.lua @@ -5,6 +5,11 @@ local meta = { light = false, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Dark scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/dark.ts -- stylua: ignore @@ -192,18 +197,18 @@ local function generate_spec(pal) conditional = pal.scale.red[4], -- Conditional and loop const = pal.scale.blue[3], -- Constants, imports and booleans dep = pal.scale.red[3], -- Deprecated - field = pal.scale.purple[3], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[2], -- Functions and Titles ident = pal.scale.blue[3], -- Identifiers keyword = pal.scale.red[4], -- Keywords number = pal.scale.blue[3], -- Numbers - operator = pal.scale.red[4], -- Operators - param = pal.scale.green[2], -- Parameters + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[4], -- PreProc regex = pal.scale.blue[3], -- Regex statement = pal.scale.red[4], -- Statements string = pal.scale.blue[2], -- Strings - type = pal.scale.red[4], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[2], -- Tags variable = spec.fg1, -- Variables } @@ -241,4 +246,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_dark_colorblind.lua b/lua/github-theme/palette/github_dark_colorblind.lua index 5578a870..2b12fa25 100644 --- a/lua/github-theme/palette/github_dark_colorblind.lua +++ b/lua/github-theme/palette/github_dark_colorblind.lua @@ -5,6 +5,11 @@ local meta = { light = false, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Dark Colorblind scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/dark_colorblind.ts -- stylua: ignore @@ -192,18 +197,18 @@ local function generate_spec(pal) conditional = pal.scale.red[4], -- Conditional and loop const = pal.scale.blue[3], -- Constants, imports and booleans dep = pal.scale.red[3], -- Deprecated - field = pal.scale.orange[3], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[3], -- Functions and Titles ident = pal.scale.blue[3], -- Identifiers keyword = pal.scale.red[4], -- Keywords number = pal.scale.blue[3], -- Numbers - operator = pal.scale.red[4], -- Operators - param = pal.scale.orange[2], -- Parameters + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[4], -- PreProc regex = pal.scale.blue[3], -- Regex statement = pal.scale.red[4], -- Statements string = pal.scale.blue[2], -- Strings - type = pal.scale.orange[3], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.blue[3], -- Tags variable = spec.fg1, -- Variables } @@ -241,4 +246,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_dark_dimmed.lua b/lua/github-theme/palette/github_dark_dimmed.lua index 84ffd46e..efb42bd5 100644 --- a/lua/github-theme/palette/github_dark_dimmed.lua +++ b/lua/github-theme/palette/github_dark_dimmed.lua @@ -5,6 +5,11 @@ local meta = { light = false, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Dark Dimmed scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/dark_dimmed.ts -- stylua: ignore @@ -184,7 +189,7 @@ local function generate_spec(pal) } spec.syntax = { - bracket = pal.scale.green[4], -- Brackets and Punctuation + bracket = spec.fg1, -- Brackets and Punctuation builtin0 = pal.scale.red[4], -- Builtin variable (Return Keywords, Regex, etc.) builtin1 = pal.scale.red[4], -- Builtin type builtin2 = pal.scale.blue[3], -- Builtin const @@ -192,18 +197,18 @@ local function generate_spec(pal) conditional = pal.scale.red[4], -- Conditional and loop const = pal.scale.blue[3], -- Constants, imports and booleans dep = pal.scale.red[3], -- Deprecated - field = pal.scale.purple[3], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[2], -- Functions and Titles ident = pal.scale.blue[3], -- Identifiers keyword = pal.scale.red[4], -- Keywords number = pal.scale.blue[3], -- Numbers - operator = pal.scale.red[4], -- Operators - param = pal.scale.orange[3], -- Parameters + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[4], -- PreProc regex = pal.scale.blue[3], -- Regex statement = pal.scale.red[4], -- Statements string = pal.scale.blue[2], -- Strings - type = pal.scale.red[4], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[2], -- Tags variable = spec.fg1, -- Variables } @@ -241,4 +246,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_dark_high_contrast.lua b/lua/github-theme/palette/github_dark_high_contrast.lua index acad0ef2..4924f9de 100644 --- a/lua/github-theme/palette/github_dark_high_contrast.lua +++ b/lua/github-theme/palette/github_dark_high_contrast.lua @@ -5,6 +5,11 @@ local meta = { light = false, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Dark High Contrast scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/dark_high_contrast.ts -- stylua: ignore @@ -192,18 +197,18 @@ local function generate_spec(pal) conditional = pal.scale.red[4], -- Conditional and loop const = pal.scale.blue[3], -- Constants, imports and booleans dep = pal.scale.red[3], -- Deprecated - field = pal.scale.purple[3], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[2], -- Functions and Titles ident = pal.scale.blue[3], -- Identifiers keyword = pal.scale.red[4], -- Keywords number = pal.scale.blue[3], -- Numbers - operator = pal.scale.red[4], -- Operators - param = pal.scale.orange[3], -- Parameters + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[4], -- PreProc regex = pal.scale.blue[3], -- Regex statement = pal.scale.red[4], -- Statements string = pal.scale.blue[2], -- Strings - type = pal.scale.red[4], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[2], -- Tags variable = spec.fg1, -- Variables } @@ -241,4 +246,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_dark_tritanopia.lua b/lua/github-theme/palette/github_dark_tritanopia.lua index 3598e654..54d83cef 100644 --- a/lua/github-theme/palette/github_dark_tritanopia.lua +++ b/lua/github-theme/palette/github_dark_tritanopia.lua @@ -5,6 +5,11 @@ local meta = { light = false, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Dark Tritanopia scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/dark_tritanopia.ts -- stylua: ignore @@ -192,18 +197,18 @@ local function generate_spec(pal) conditional = pal.scale.red[4], -- Conditional and loop const = pal.scale.blue[3], -- Constants, imports and booleans dep = pal.scale.red[3], -- Deprecated - field = pal.scale.orange[3], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[3], -- Functions and Titles ident = pal.scale.blue[3], -- Identifiers keyword = pal.scale.red[4], -- Keywords number = pal.scale.blue[3], -- Numbers - operator = pal.scale.red[4], -- Operators - param = pal.scale.orange[2], -- Parameters + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[4], -- PreProc regex = pal.scale.blue[3], -- Regex statement = pal.scale.red[4], -- Statements string = pal.scale.blue[2], -- Strings - type = pal.scale.orange[3], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.blue[3], -- Tags variable = spec.fg1, -- Variables } @@ -241,4 +246,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_light.lua b/lua/github-theme/palette/github_light.lua index 151518ff..3275dd15 100644 --- a/lua/github-theme/palette/github_light.lua +++ b/lua/github-theme/palette/github_light.lua @@ -5,6 +5,11 @@ local meta = { light = true, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Light scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/light.ts -- stylua: ignore @@ -185,7 +190,7 @@ local function generate_spec(pal) } spec.syntax = { - bracket = pal.scale.orange[5], -- Brackets and Punctuation + bracket = spec.fg1, -- Brackets and Punctuation builtin0 = pal.scale.red[6], -- Builtin variable builtin1 = pal.scale.red[6], -- Builtin type builtin2 = pal.scale.blue[7], -- Builtin const @@ -193,18 +198,18 @@ local function generate_spec(pal) conditional = pal.scale.red[6], -- Conditional and loop const = pal.scale.blue[6], -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[6], -- Functions and Titles ident = pal.scale.blue[9], -- Identifiers keyword = pal.scale.red[6], -- Keywords number = pal.scale.blue[7], -- Numbers - operator = pal.scale.red[6], -- Operators - param = pal.scale.orange[5], -- PreProc + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[6], -- PreProc regex = pal.scale.blue[9], -- Regex statement = pal.scale.red[6], -- Statements string = pal.scale.blue[8], -- Strings - type = pal.scale.red[6], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[6], -- Tags variable = spec.fg1, -- Variables } @@ -242,4 +247,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_light_colorblind.lua b/lua/github-theme/palette/github_light_colorblind.lua index fb533393..6f4fb530 100644 --- a/lua/github-theme/palette/github_light_colorblind.lua +++ b/lua/github-theme/palette/github_light_colorblind.lua @@ -5,6 +5,11 @@ local meta = { light = true, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Light scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/light_colorblind.ts -- stylua: ignore @@ -193,18 +198,18 @@ local function generate_spec(pal) conditional = pal.scale.red[6], -- Conditional and loop const = pal.scale.blue[6], -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = pal.scale.orange[8], -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[6], -- Functions and Titles ident = pal.scale.blue[9], -- Identifiers keyword = pal.scale.red[6], -- Keywords number = pal.scale.blue[7], -- Numbers - operator = pal.scale.red[6], -- Operators - param = pal.scale.orange[5], -- PreProc + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[6], -- PreProc regex = pal.scale.blue[9], -- Regex statement = pal.scale.red[6], -- Statements string = pal.scale.blue[8], -- Strings - type = pal.scale.orange[5], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[6], -- Tags variable = spec.fg1, -- Variables } @@ -242,4 +247,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_light_high_contrast.lua b/lua/github-theme/palette/github_light_high_contrast.lua index 6d4ffac6..2c94ea1a 100644 --- a/lua/github-theme/palette/github_light_high_contrast.lua +++ b/lua/github-theme/palette/github_light_high_contrast.lua @@ -5,6 +5,11 @@ local meta = { light = true, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Light High Contrast scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/light_high_contrast.ts -- stylua: ignore @@ -168,20 +173,20 @@ local palette = { local function generate_spec(pal) -- stylua: ignore start local spec = { - bg0 = pal.canvas.inset, -- Dark bg (status line, popup and float) - bg1 = pal.canvas.default, -- Default bg - bg2 = alpha(C(pal.neutral.emphasis), 0.1), -- Lighter bg (colorcolumn Folds) - bg3 = pal.scale.gray[2], -- Lighter bg (cursor line) - bg4 = pal.border.default, -- Conceal - - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg + bg0 = pal.canvas.inset, -- Dark bg (status line, popup and float) + bg1 = pal.canvas.default, -- Default bg + bg2 = alpha(C(pal.neutral.emphasis), 0.1), -- Lighter bg (colorcolumn Folds) + bg3 = pal.scale.gray[2], -- Lighter bg (cursor line) + bg4 = pal.border.default, -- Conceal + + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg fg2 = pal.scale.gray[9], -- Darker fg (status line) - fg3 = pal.scale.gray[7], -- Darker fg (line numbers, fold columns) + fg3 = pal.scale.gray[7], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.2), -- Visual selection bg - sel1 = alpha(C(pal.accent.fg), 0.3), -- Popup sel bg - sel2 = alpha(C(pal.attention.emphasis), 0.3) -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.2), -- Visual selection bg + sel1 = alpha(C(pal.accent.fg), 0.3), -- Popup sel bg + sel2 = alpha(C(pal.attention.emphasis), 0.3) -- Search bg } spec.syntax = { @@ -193,18 +198,18 @@ local function generate_spec(pal) conditional = pal.scale.red[6], -- Conditional and loop const = pal.scale.blue[6], -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[6], -- Functions and Titles ident = pal.scale.blue[9], -- Identifiers keyword = pal.scale.red[6], -- Keywords number = pal.scale.blue[7], -- Numbers - operator = pal.scale.red[6], -- Operators - param = pal.scale.orange[5], -- PreProc + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[6], -- PreProc regex = pal.scale.blue[9], -- Regex statement = pal.scale.red[6], -- Statements string = pal.scale.blue[8], -- Strings - type = pal.scale.red[6], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[6], -- Tags variable = spec.fg1, -- Variables } @@ -242,4 +247,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +} diff --git a/lua/github-theme/palette/github_light_tritanopia.lua b/lua/github-theme/palette/github_light_tritanopia.lua index 187faac3..209538c7 100644 --- a/lua/github-theme/palette/github_light_tritanopia.lua +++ b/lua/github-theme/palette/github_light_tritanopia.lua @@ -5,6 +5,11 @@ local meta = { light = true, } +local primitives = + require('github-theme.palette.primitives.' .. meta.name:gsub('^github%W*', '', 1)) + +local pl = primitives.prettylights + ---Github Light scale variables ---source: https://github.com/primer/primitives/blob/main/data/colors/themes/light_tritanopia.ts -- stylua: ignore @@ -168,20 +173,20 @@ local palette = { local function generate_spec(pal) -- stylua: ignore start local spec = { - bg0 = pal.canvas.inset, -- Dark bg (status line, popup and float) - bg1 = pal.canvas.default, -- Default bg - bg2 = alpha(C(pal.neutral.emphasis), 0.1), -- Lighter bg (colorcolumn Folds) - bg3 = pal.scale.gray[2], -- Lighter bg (cursor line) - bg4 = pal.scale.gray[6], -- Conceal - - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg + bg0 = pal.canvas.inset, -- Dark bg (status line, popup and float) + bg1 = pal.canvas.default, -- Default bg + bg2 = alpha(C(pal.neutral.emphasis), 0.1), -- Lighter bg (colorcolumn Folds) + bg3 = pal.scale.gray[2], -- Lighter bg (cursor line) + bg4 = pal.scale.gray[6], -- Conceal + + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg fg2 = pal.scale.gray[9], -- Darker fg (status line) - fg3 = pal.scale.gray[7], -- Darker fg (line numbers, fold columns) + fg3 = pal.scale.gray[7], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.2), -- Visual selection bg - sel1 = alpha(C(pal.accent.fg), 0.3), -- Popup sel bg - sel2 = alpha(C(pal.attention.emphasis), 0.3) -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.2), -- Visual selection bg + sel1 = alpha(C(pal.accent.fg), 0.3), -- Popup sel bg + sel2 = alpha(C(pal.attention.emphasis), 0.3) -- Search bg } spec.syntax = { @@ -193,18 +198,18 @@ local function generate_spec(pal) conditional = pal.scale.red[6], -- Conditional and loop const = pal.scale.blue[6], -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- Field + field = pl.syntax.constant, -- Field func = pal.scale.purple[6], -- Functions and Titles ident = pal.scale.blue[9], -- Identifiers keyword = pal.scale.red[6], -- Keywords number = pal.scale.blue[7], -- Numbers - operator = pal.scale.red[6], -- Operators - param = pal.scale.orange[5], -- PreProc + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters preproc = pal.scale.red[6], -- PreProc regex = pal.scale.blue[9], -- Regex statement = pal.scale.red[6], -- Statements string = pal.scale.blue[8], -- Strings - type = pal.scale.red[6], -- Types + type = pl.syntax.variable, -- Types tag = pal.scale.green[6], -- Tags variable = spec.fg1, -- Variables } @@ -242,4 +247,9 @@ local function generate_spec(pal) return spec end -return { meta = meta, palette = palette, generate_spec = generate_spec } +return { + meta = meta, + primitives = primitives, + palette = palette, + generate_spec = generate_spec, +}