diff --git a/lua/github-theme/group/modules/treesitter.lua b/lua/github-theme/group/modules/treesitter.lua index 4801bcd4..eead6aad 100644 --- a/lua/github-theme/group/modules/treesitter.lua +++ b/lua/github-theme/group/modules/treesitter.lua @@ -1,12 +1,45 @@ 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. + --- + ---| 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 {} @@ -22,97 +55,96 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch -- ['@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 functions (calls & defs): macro_rules!, println!() + -- ['@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'] = { fg = pl.syntax.variable}, -- Constructor calls & defs: {} in Lua, new Type() (js/php), constructor() {} + ['@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 }, -- Var names defined by the language: this, self, super - -- ['@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'] = { link = '@field' }, -- Tag attributes (e.g. HTML element attributes) + ['@tag.delimiter'] = FALLBACK_OR_NONE, -- Tag delimiter like `<`, `>`, `/`, etc. -- Language specific ------------------------------------------------------- @@ -121,40 +153,57 @@ 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 }, ['@constant.html'] = { link = '@tag' }, -- Java - ['@type.java'] = { link = '@function' }, + -- ['@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' }, + + -- JSX/TSX + ['@tag.javascript'] = FALLBACK_OR_NONE, + ['@tag.tsx'] = FALLBACK_OR_NONE, + ['@tag.delimiter.javascript'] = { link = '@tag.attribute.javascript' }, + ['@tag.delimiter.tsx'] = { link = '@tag.attribute.tsx' }, -- Json - ['@label.json'] = { link = '@constant' }, + ['@label.json'] = { link = '@tag' }, -- Lua ['@lsp.type.variable.lua'] = { fg = spec.variable }, + ['@constructor.lua'] = FALLBACK_OR_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' }, + ['@namespace.builtin.lua'] = { fg = syn.const }, -- `table`, `io`, `_G` + ['@label.lua'] = { fg = syn.const }, -- the `LABEL` in `::LABEL::` and `goto LABEL` -- 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 }, @@ -162,25 +211,25 @@ If you want to stay on nvim 0.7, disable the module, or track on 'v0.0.x' branch ['@text.quote.markdown'] = { fg = syn.tag }, -- PHP - ['@type.php'] = { link = '@function' }, + -- ['@type.php'] = { link = '@function' }, + ['@namespace.php'] = { link = '@constructor.php' }, -- 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 }, + ['@namespace.rust'] = FALLBACK_OR_NONE, + ['@preproc.rust'] = { fg = syn.const }, -- SCSS ['@property.scss'] = { link = '@constant' }, @@ -192,11 +241,14 @@ 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' }, + + -- VimDoc + ['@parameter.vimdoc'] = { fg = pl.syntax.variable }, -- Yaml ['@field.yaml'] = { link = '@tag' }, diff --git a/lua/github-theme/group/syntax.lua b/lua/github-theme/group/syntax.lua index 0d4d44bc..89a96f39 100644 --- a/lua/github-theme/group/syntax.lua +++ b/lua/github-theme/group/syntax.lua @@ -4,6 +4,30 @@ 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. + --- + ---| 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 +63,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 35ac2499..cf5e9eef 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 27fd562b..5865d1fb 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 9e4f26e8..6c12095f 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 740dd6c0..de851eb7 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 fb31ca2c..5dbc9f2b 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 17f56841..193f83ac 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 d796c941..1b949890 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 e29cb70f..b02feaf5 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 (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 (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.muted), 0.90), -- 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.muted), 0.90), -- 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 59707e1a..fb1d34be 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 (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 (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.muted), 0.90), -- 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.muted), 0.90), -- 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/queries/php/highlights.scm b/queries/php/highlights.scm new file mode 100644 index 00000000..e608eef1 --- /dev/null +++ b/queries/php/highlights.scm @@ -0,0 +1,6 @@ +;; extends + +((php_tag) @tag) + +(variable_name + "$" @operator) diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm new file mode 100644 index 00000000..cf3afecf --- /dev/null +++ b/queries/rust/highlights.scm @@ -0,0 +1,23 @@ +;; extends + +; Make types have higher priority (otherwise enum constructions will be +; function color) +((identifier) @type + (#lua-match? @type "^%u[%u%d_]*%l") (#set! "priority" 101)) + +; Rust attributes (#[] and #![]) +([ + (attribute_item) + (inner_attribute_item) + ] @preproc (#set! "priority" 101)) + +(attribute_item + (attribute + (string_literal) @string (#set! "priority" 101))) + +(inner_attribute_item + (attribute + (string_literal) @string (#set! "priority" 101))) + +; Make crate/self/super the @keyword color +[(crate) (self) (super)] @keyword