diff --git a/.github/workflows/update-color-primitives.yml b/.github/workflows/update-color-primitives.yml index 1bd310bd..78ae24ec 100644 --- a/.github/workflows/update-color-primitives.yml +++ b/.github/workflows/update-color-primitives.yml @@ -22,7 +22,7 @@ jobs: packages: read pull-requests: write statuses: write - + steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index b63b6959..e8a5e669 100644 --- a/README.md +++ b/README.md @@ -227,9 +227,9 @@ require('github-theme').setup({ dim_inactive = false, -- Non focused panes set to alternative background module_default = true, -- Default enable value for modules styles = { -- Style to be applied to different syntax groups - comments = 'italic', -- Value is any valid attr-list value `:help attr-list` + comments = 'NONE', -- Value is any valid attr-list value `:help attr-list` functions = 'NONE', - keywords = 'italic', + keywords = 'NONE', variables = 'NONE', conditionals = 'NONE', constants = 'NONE', @@ -263,15 +263,13 @@ require('github-theme').setup({ vim.cmd('colorscheme github_dark') ``` -If you would like to change any of the default options above you only have to define the options that change. If an -option is not present in your options table the default option will be used. For example if changing the styles of -certain syntax is the only desired change then your options table would look like: +If you would like to change any of the default options above, simply specify the options that you'd like to change. Unspecified options will use their default value. For example, if you only wanted to change the styles of certain syntax items: ```lua require('github-theme').setup({ options = { styles = { - comments = 'NONE', + comments = 'italic', keywords = 'bold', types = 'italic,bold', } @@ -303,14 +301,11 @@ local palettes = { all = { -- Each palette defines these colors: -- black, gray, blue, green, magenta, pink, red, white, yellow, cyan - -- -- These colors have 2 shades: base, and bright - -- - -- Defining just a color defines it's base color - red = { - base = '#ff0000' - }, + + -- Passing a string sets the base + red = '#ff0000', }, github_dark = { -- Defining multiple shades is done by passing a table @@ -371,7 +366,7 @@ local specs = { } -- Groups are the highlight group definitions. The keys of this table are the name of the highlight --- groups that will be overridden. The value is a table with the following values: +-- groups that will be overridden. The value is a table with the following keys: -- - fg, bg, style, sp, link, -- -- Just like `spec` groups support templates. This time the template is based on a spec object. @@ -601,8 +596,10 @@ Set your airline colorscheme with `:AirlineThemes` vim command. ## Syntax highlight groups -This section will help you determine what highlight group is being applied to a piece of syntax. These sections will -output the highlight group for the value under the cursor. +This section will help you determine what highlight group is being applied to a piece of syntax. These methods +show which highlight group(s) is in use at the current screen position of the cursor (under the cursor). + +> **Note** On Neovim v0.9.0 and later, you can use the command `:Inspect`, or the Lua function `vim.show_pos()`. #### Treesitter highlighting diff --git a/Usage.md b/Usage.md index 234fb31c..a99996b9 100644 --- a/Usage.md +++ b/Usage.md @@ -410,7 +410,7 @@ Current list of modules are: ### Neovim specific modules The following modules are enabled by default only when on neovim, `diagnostic`, `native_lsp`, `treesitter`. These modules are part of the core neovim experience and -are liked to by other modules. This also means that they will still be enabled when setting `module_default` to `false`. +are linked to by other modules. This also means that they will still be enabled when setting `module_default` to `false`. ### Extended modules diff --git a/doc/github-nvim-theme.txt b/doc/github-nvim-theme.txt index bea97900..d19068bc 100644 --- a/doc/github-nvim-theme.txt +++ b/doc/github-nvim-theme.txt @@ -509,7 +509,7 @@ NEOVIM SPECIFIC MODULES ~ The following modules are enabled by default only when on neovim, `diagnostic`, `native_lsp`, `treesitter`. These modules are part of the core neovim -experience and are liked to by other modules. This also means that they will +experience and are linked to by other modules. This also means that they will still be enabled when setting `module_default` to `false`. diff --git a/lua/github-theme/config.lua b/lua/github-theme/config.lua index 9463e929..cbcf666d 100644 --- a/lua/github-theme/config.lua +++ b/lua/github-theme/config.lua @@ -13,9 +13,9 @@ local defaults = { dim_inactive = false, module_default = true, styles = { - comments = 'italic', + comments = 'NONE', functions = 'NONE', - keywords = 'italic', + keywords = 'NONE', variables = 'NONE', conditionals = 'NONE', constants = 'NONE', diff --git a/lua/github-theme/group/modules/treesitter.lua b/lua/github-theme/group/modules/treesitter.lua index 7ebe1c08..5e4a0c64 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 {} @@ -15,146 +48,174 @@ 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 = 'Number' }, -- 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 calls and definitions. - - ['@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 conditionnals. - ['@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 ------------------------------------------------------- + -- Bash + ['@operator.bash'] = { fg = syn.keyword, style = stl.operators }, + ['@function.builtin.bash'] = { fg = syn.keyword }, -- Invocations of builtin commands/functions + ['@function.call.bash'] = { fg = syn.const }, + ['@number.bash'] = FALLBACK_OR_NONE, + -- ['@punctuation.bracket.bash'] = { fg = syn.string }, -- $(, (, ), [, ], ((, )) + ['@punctuation.delimiter.bash'] = { fg = syn.keyword }, -- ; and ;; + ['@punctuation.special.bash'] = { link = "@punctuation.bash" }, -- $ + -- C ['@type.c'] = { fg = spec.variable }, ['@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` + ['@field.luadoc'] = { link = '@field.lua' }, + ['@operator.luadoc'] = { fg = spec.fg1 }, -- The `|` in `string|number` + ['@punctuation.special.luadoc'] = { fg = spec.fg1 }, -- The `?` in `string?` -- 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 +223,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 }, + ['@field.python'] = { fg = spec.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 +253,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 dbbcdc61..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 @@ -35,16 +59,17 @@ function M.get(spec, config) PreCondit = { link = 'PreProc' }, -- preprocessor #if, #else, #endif, etc. Type = { fg = syn.type, style = stl.types }, -- (preferred) int, long, char, etc. - StorageClass = { link = 'Type' }, -- static, register, volatile, etc. - Structure = { link = 'Type' }, -- struct, union, enum, etc. - Typedef = { link = 'Type' }, -- A typedef - - 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 - Delimiter = { link = 'Special' }, -- character that needs attention - SpecialComment = { link = 'Special' }, -- special things inside a comment - Debug = { link = 'Special' }, -- debugging statements + -- StorageClass = { link = 'Type' }, -- static, register, volatile, etc. + -- 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 + -- Delimiter = { link = 'Special' }, -- character that needs attention + -- SpecialComment = { link = 'Special' }, -- special things inside a comment + -- Debug = { link = 'Special' }, -- debugging statements Underlined = { style = 'underline' }, -- (preferred) text that stands out, HTML links Bold = { style = 'bold' }, diff --git a/lua/github-theme/palette/github_dark.lua b/lua/github-theme/palette/github_dark.lua index 35ac2499..c3b4361e 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 @@ -173,39 +178,39 @@ local function generate_spec(pal) bg3 = pal.scale.gray[6], -- Lighter bg (cursor line) bg4 = pal.scale.gray[4], -- Conceal - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg - fg2 = pal.fg.muted, -- Darker fg (status line) - fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg + fg2 = pal.fg.muted, -- Darker fg (status line) + fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg - sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg - sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg + sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg + sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg } spec.syntax = { - bracket = pal.scale.orange[3], -- 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 - comment = pal.scale.gray[5], -- Comment - 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 - 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 - 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 - tag = pal.scale.green[2], -- Tags - variable = spec.fg1, -- Variables + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans + dep = pal.scale.red[3], -- Deprecated + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- Tags + variable = spec.fg1, -- Variables } spec.diag = { @@ -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..c4a39300 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 @@ -173,39 +178,39 @@ local function generate_spec(pal) bg3 = pal.scale.gray[9], -- Lighter bg (cursor line) bg4 = pal.scale.gray[4], -- Conceal - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg - fg2 = pal.fg.muted, -- Darker fg (status line) - fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg + fg2 = pal.fg.muted, -- Darker fg (status line) + fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.45), -- Visual selection bg - sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg - sel2 = alpha(C(pal.scale.yellow[3]), 0.60), -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.45), -- Visual selection bg + sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg + sel2 = alpha(C(pal.scale.yellow[3]), 0.60), -- Search bg } spec.syntax = { - bracket = pal.scale.orange[3], -- 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 - comment = pal.scale.gray[5], -- Comment - 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 - 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 - 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 - tag = pal.scale.blue[3], -- Tags - variable = spec.fg1, -- Variables + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans + dep = pal.scale.red[3], -- Deprecated + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- Tags + variable = spec.fg1, -- Variables } spec.diag = { @@ -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..4feefce7 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 @@ -173,39 +178,39 @@ local function generate_spec(pal) bg3 = alpha(C(pal.fg.default), 0.1), -- Lighter bg (cursor line) bg4 = pal.scale.gray[4], -- Conceal - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg - fg2 = pal.fg.muted, -- Darker fg (status line) - fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg + fg2 = pal.fg.muted, -- Darker fg (status line) + fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.40), -- Visual selection bg - sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg - sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.40), -- Visual selection bg + sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg + sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg } spec.syntax = { - bracket = pal.scale.green[4], -- 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 - comment = pal.scale.gray[5], -- Comment - 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 - 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 - 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 - tag = pal.scale.green[2], -- Tags - variable = spec.fg1, -- Variables + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans + dep = pal.scale.red[3], -- Deprecated + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- Tags + variable = spec.fg1, -- Variables } spec.diag = { @@ -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..7db9dbd7 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 @@ -173,39 +178,39 @@ local function generate_spec(pal) bg3 = alpha(C(pal.fg.default), 0.1), -- Lighter bg (cursor line) bg4 = pal.scale.gray[4], -- Conceal - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg - fg2 = pal.fg.muted, -- Darker fg (status line) - fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg + fg2 = pal.fg.muted, -- Darker fg (status line) + fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg - sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg - sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg + sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg + sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg } spec.syntax = { - bracket = pal.scale.orange[3], -- 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 - comment = pal.scale.gray[5], -- Comment - 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 - 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 - 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 - tag = pal.scale.green[2], -- Tags - variable = spec.fg1, -- Variables + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans + dep = pal.scale.red[3], -- Deprecated + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- Tags + variable = spec.fg1, -- Variables } spec.diag = { @@ -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..1e0ab4bb 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 @@ -173,39 +178,39 @@ local function generate_spec(pal) bg3 = pal.scale.gray[6], -- Lighter bg (cursor line) bg4 = pal.scale.gray[4], -- Conceal - fg0 = pal.fg.subtle, -- Lighter fg - fg1 = pal.fg.default, -- Default fg - fg2 = pal.fg.muted, -- Darker fg (status line) - fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) + fg0 = pal.fg.subtle, -- Lighter fg + fg1 = pal.fg.default, -- Default fg + fg2 = pal.fg.muted, -- Darker fg (status line) + fg3 = pal.scale.gray[5], -- Darker fg (line numbers, fold columns) - sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg - sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg - sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg + sel0 = alpha(C(pal.accent.fg), 0.30), -- Visual selection bg + sel1 = alpha(C(pal.accent.muted), 0.90), -- Popup sel bg + sel2 = alpha(C(pal.scale.yellow[1]), 0.20), -- Search bg } spec.syntax = { - bracket = pal.scale.orange[3], -- 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 - comment = pal.scale.gray[5], -- Comment - 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 - 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 - 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 - tag = pal.scale.blue[3], -- Tags - variable = spec.fg1, -- Variables + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans + dep = pal.scale.red[3], -- Deprecated + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- Tags + variable = spec.fg1, -- Variables } spec.diag = { @@ -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..371040cc 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,27 +190,27 @@ local function generate_spec(pal) } spec.syntax = { - bracket = pal.scale.orange[5], -- Brackets and Punctuation - builtin0 = pal.scale.red[6], -- Builtin variable - builtin1 = pal.scale.red[6], -- Builtin type - builtin2 = pal.scale.blue[7], -- Builtin const - comment = pal.scale.gray[6], -- Comment - conditional = pal.scale.red[6], -- Conditional and loop - const = pal.scale.blue[6], -- Constants, imports and booleans + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- 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 - 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 - tag = pal.scale.green[6], -- Tags + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- 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..80e0d0e2 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 @@ -185,27 +190,27 @@ local function generate_spec(pal) } spec.syntax = { - bracket = pal.scale.blue[5], -- Brackets and Punctuation - builtin0 = pal.scale.red[6], -- Builtin variable - builtin1 = pal.scale.red[6], -- Builtin type - builtin2 = pal.scale.blue[7], -- Builtin const - comment = pal.scale.gray[6], -- Comment - conditional = pal.scale.red[6], -- Conditional and loop - const = pal.scale.blue[6], -- Constants, imports and booleans + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = pal.scale.orange[8], -- 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 - 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 - tag = pal.scale.green[6], -- Tags + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- 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..7508c12a 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,44 +173,44 @@ 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 = { - bracket = pal.scale.orange[5], -- Brackets and Punctuation - builtin0 = pal.scale.red[6], -- Builtin variable - builtin1 = pal.scale.red[6], -- Builtin type - builtin2 = pal.scale.blue[7], -- Builtin const - comment = pal.scale.gray[6], -- Comment - conditional = pal.scale.red[6], -- Conditional and loop - const = pal.scale.blue[6], -- Constants, imports and booleans + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- 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 - 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 - tag = pal.scale.green[6], -- Tags + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- 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..cf50c7d4 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,44 +173,44 @@ 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 = { - bracket = pal.scale.orange[5], -- Brackets and Punctuation - builtin0 = pal.scale.red[6], -- Builtin variable - builtin1 = pal.scale.red[6], -- Builtin type - builtin2 = pal.scale.blue[7], -- Builtin const - comment = pal.scale.gray[6], -- Comment - conditional = pal.scale.red[6], -- Conditional and loop - const = pal.scale.blue[6], -- Constants, imports and booleans + bracket = spec.fg1, -- Brackets and Punctuation + builtin0 = pl.syntax.constant, -- Builtin variable + builtin1 = pl.syntax.keyword, -- Builtin type + builtin2 = pl.syntax.constant, -- Builtin const + comment = pl.syntax.comment, -- Comment + conditional = pl.syntax.keyword, -- Conditional and loop + const = pl.syntax.constant, -- Constants, imports and booleans dep = pal.scale.red[8], -- Deprecated - field = spec.fg1, -- 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 - 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 - tag = pal.scale.green[6], -- Tags + field = pl.syntax.constant, -- Field + func = pl.syntax.entity, -- Functions and Titles + ident = spec.fg1, -- Identifiers + keyword = pl.syntax.keyword, -- Keywords + number = pl.syntax.constant, -- Numbers + operator = pl.syntax.constant, -- Operators + param = spec.fg1, -- Parameters + preproc = pl.syntax.keyword, -- PreProc + regex = pl.syntax.string, -- Regex + statement = pl.syntax.keyword, -- Statements + string = pl.syntax.string, -- Strings + type = pl.syntax.variable, -- Types + tag = pl.syntax.entityTag, -- 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/bash/highlights.scm b/queries/bash/highlights.scm new file mode 100644 index 00000000..5ab2ab17 --- /dev/null +++ b/queries/bash/highlights.scm @@ -0,0 +1,20 @@ +;; extends + +; This should probably have its own unique/custom capture, but this works for +; now. +(command_substitution + [ "$(" ")" ] @string) + +; This should probably have its own unique/custom capture, but this works for +; now. +(process_substitution + [ "<(" ")" ] @string) + +(expansion + "#" @operator) + +(simple_expansion + "$" @variable) + +(subscript + index: (word) @punctuation.special (#any-of? @punctuation.special "@" "*")) 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