More robust workaround for symantic highlights

Uses new experimental API
This commit is contained in:
ViViDboarder 2024-05-30 15:44:47 -07:00
parent 002915c21f
commit ea2ca3916a
2 changed files with 222 additions and 218 deletions

View File

@ -17,6 +17,3 @@ lua package.loaded['lush_theme.lush_template'] = nil
" include our theme file and pass it to lush to apply
lua require('lush')(require('lush_theme.wombat_lush'))
" Workaround for not being able to link from semantic groups to highlight groups in lush
lua vim.api.nvim_set_hl(0, "@variable", { link = "TSVariable" })

View File

@ -42,7 +42,7 @@
--
-- `:lua require('lush').ify()`
local lush = require('lush')
local lush = require("lush")
local hsl = lush.hsl
local c = require("lush_theme.wombat_lush_colors").colors
@ -50,9 +50,11 @@ local italic = require("lush_theme.wombat_lush_colors").italic
local classic = require("lush_theme.wombat_classic")
-- LSP/Linters mistakenly show `undefined global` errors in the spec, they may
-- support an annotation like the following. Consult your server documentation.
-- -@diagnostic disable: undefined-global
local theme = lush.extends({classic}).with(function()
-- support an annotation li
-- luacheck: ignore
-- @diagnostic disable: undefined-global
local theme = lush.extends({ classic }).with(function(injected_functions)
local sym = injected_functions.sym
return {
-- The following are all the Neovim default highlight groups from the docs
-- as of 0.5.0-nightly-446, to aid your theme creation. Your themes should
@ -75,10 +77,10 @@ local theme = lush.extends({classic}).with(function()
-- CursorColumn { Cursor }, -- Screen-column at the cursor, when 'cursorcolumn' is set.
-- CursorLine { bg = c.grey_6}, -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set.
-- Directory { }, -- directory names (and other special names in listings)
DiffAdd { fg = c.darkgreen.readable(), bg = c.darkgreen }, -- diff mode: Added line |diff.txt|
DiffChange { bg = c.violet }, -- diff mode: Changed line |diff.txt|
DiffDelete { fg = c.darkred.readable(), bg = c.darkred }, -- diff mode: Deleted line |diff.txt|
DiffText { fg = c.magenta.readable(), bg = c.magenta }, -- diff mode: Changed text within a changed line |diff.txt|
DiffAdd({ fg = c.darkgreen.readable(), bg = c.darkgreen }), -- diff mode: Added line |diff.txt|
DiffChange({ bg = c.violet }), -- diff mode: Changed line |diff.txt|
DiffDelete({ fg = c.darkred.readable(), bg = c.darkred }), -- diff mode: Deleted line |diff.txt|
DiffText({ fg = c.magenta.readable(), bg = c.magenta }), -- diff mode: Changed text within a changed line |diff.txt|
-- EndOfBuffer { }, -- filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|.
-- TermCursor { }, -- cursor in a focused terminal
-- TermCursorNC { }, -- cursor in an unfocused terminal
@ -97,9 +99,9 @@ local theme = lush.extends({classic}).with(function()
-- MsgSeparator { }, -- Separator for scrolled messages, `msgsep` flag of 'display'
-- MoreMsg { }, -- |more-prompt|
-- NonText { LineNr }, -- '@' at the end of the window, characters from 'showbreak' and other characters that do not really exist in the text (e.g., ">" displayed when a double-wide character doesn't fit at the end of the line). See also |hl-EndOfBuffer|.
Normal {bg = c.dark_bg, fg = c.dark_fg}, -- normal text
NormalFloat {bg = Normal.bg.lighten(10), fg = classic.Special.fg }, -- Normal text in floating windows.
FloatBorder {bg = NormalFloat.bg, fg = classic.Pmenu.fg}, -- float border
Normal({ bg = c.dark_bg, fg = c.dark_fg }), -- normal text
NormalFloat({ bg = Normal.bg.lighten(10), fg = classic.Special.fg }), -- Normal text in floating windows.
FloatBorder({ bg = NormalFloat.bg, fg = classic.Pmenu.fg }), -- float border
-- NormalNC { }, -- normal text in non-current windows
-- Pmenu { fg = c.light_yellow, bg = c.grey_5 }, -- Popup menu: normal item.
-- PmenuSel { fg = c.green.readable(), bg = c.green }, -- Popup menu: selected item.
@ -135,19 +137,19 @@ local theme = lush.extends({classic}).with(function()
-- String { fg = c.bright_green, gui = italic }, -- a string constant: "this is a string"
-- Character { }, -- a character constant: 'c', '\n'
-- Number { fg = c.orange }, -- a number constant: 234, 0xff
Boolean { fg = c.red }, -- a boolean constant: TRUE, false
Float { classic.Number }, -- a floating point constant: 2.3e10
Boolean({ fg = c.red }), -- a boolean constant: TRUE, false
Float({ classic.Number }), -- a floating point constant: 2.3e10
-- Identifier { classic.Identifier }, -- (preferred) any variable name
-- Function { classic.Function }, -- function name (also: methods for classes)
-- Statement { fg = c.purple }, -- (preferred) any statement
Conditional { classic.Statement }, -- if, then, else, endif, switch, etc.
Repeat { classic.Statement }, -- for, do, while, etc.
Label { fg = c.magenta }, -- case, default, etc.
Operator { fg = c.magenta }, -- "sizeof", "+", "*", etc.
Conditional({ classic.Statement }), -- if, then, else, endif, switch, etc.
Repeat({ classic.Statement }), -- for, do, while, etc.
Label({ fg = c.magenta }), -- case, default, etc.
Operator({ fg = c.magenta }), -- "sizeof", "+", "*", etc.
-- Keyword { classic.Keyword }, -- any other keyword
Exception { fg = c.orange }, -- try, catch, throw
Exception({ fg = c.orange }), -- try, catch, throw
-- PreProc { fg = c.orange }, -- (preferred) generic Preprocessor
-- Include { }, -- preprocessor #include
@ -163,7 +165,7 @@ local theme = lush.extends({classic}).with(function()
-- Special { classic.Special }, -- (preferred) any special symbol
-- SpecialChar { }, -- special character in a constant
-- Tag { }, -- you can use CTRL-] on this
Delimiter { fg = c.purple }, -- character that needs attention
Delimiter({ fg = c.purple }), -- character that needs attention
-- SpecialComment { }, -- special things inside a comment
-- Debug { }, -- debugging statements
@ -233,21 +235,21 @@ local theme = lush.extends({classic}).with(function()
-- TSException { }, -- For exception related keywords.
-- TSField { }, -- For fields.
-- TSFloat { }, -- For floats.
TSFunction { classic.Function }, -- For function (calls and definitions).
TSFunction({ classic.Function }), -- For function (calls and definitions).
-- TSFuncBuiltin { }, -- For builtin functions: `table.insert` in Lua.
-- TSFuncMacro { }, -- For macro defined fuctions (calls and definitions): each `macro_rules` in Rust.
-- TSInclude { }, -- For includes: `#include` in C, `use` or `extern crate` in Rust, or `require` in Lua.
TSKeyword { classic.Keyword }, -- For keywords that don't fall in previous categories.
TSKeyword({ classic.Keyword }), -- For keywords that don't fall in previous categories.
-- TSKeywordFunction { }, -- For keywords used to define a fuction.
-- TSLabel { }, -- For labels: `label:` in C and `:label:` in Lua.
TSMethod { classic.Function }, -- For method calls and definitions.
TSMethod({ classic.Function }), -- For method calls and definitions.
-- TSNamespace { }, -- For identifiers referring to modules and namespaces.
-- TSNone { }, -- TODO: docs
-- TSNumber { }, -- For all numbers
-- TSOperator { }, -- For any operator: `+`, but also `->` and `*` in C.
-- TSParameter { }, -- For parameters of a function.
-- TSParameterReference { }, -- For references to parameters of a function.
TSProperty { classic.Identifier }, -- Same as `TSField`.
TSProperty({ classic.Identifier }), -- Same as `TSField`.
-- TSPunctDelimiter { }, -- For delimiters ie: `.`
-- TSPunctBracket { }, -- For brackets and parens.
-- TSPunctSpecial { }, -- For special punctutation that does not fall in the catagories before.
@ -256,14 +258,14 @@ local theme = lush.extends({classic}).with(function()
-- TSStringRegex { }, -- For regexes.
-- TSStringEscape { }, -- For escape characters within a string.
-- TSSymbol { }, -- For identifiers referring to symbols or atoms.
TSType { classic.Type }, -- For types.
TSType({ classic.Type }), -- For types.
-- TSTypeBuiltin { }, -- For builtin types.
TSVariable { classic.Special }, -- Any variable name that does not have another highlight.
TSVariable({ classic.Special }), -- Any variable name that does not have another highlight.
-- TSVariableBuiltin { }, -- Variable names that are defined by the languages, like `this` or `self`.
-- TSTag { }, -- Tags like html tag names.
-- TSTagDelimiter { }, -- Tag delimiter like `<` `>` `/`
TSText { fg = Normal.fg }, -- For strings considered text in a markup language.
TSText({ fg = Normal.fg }), -- For strings considered text in a markup language.
-- TSEmphasis { }, -- For text to be represented with emphasis.
-- TSUnderline { }, -- For text to be represented with an underline.
-- TSStrike { }, -- For strikethrough text.
@ -271,21 +273,26 @@ local theme = lush.extends({classic}).with(function()
-- TSLiteral { }, -- Literal text.
-- TSURI { }, -- Any URI like a link or email.
-- gray
CmpItemAbbrDeprecated { fg = c.grey, gui = "strikethrough" },
-- blue
CmpItemAbbrMatch { fg = c.green },
CmpItemAbbrMatchFuzzy { CmpItemAbbrMatch },
-- light blue
CmpItemKindVariable { TSVariable },
CmpItemKindInterface { TSType },
CmpItemKindText { TSText },
-- pink
CmpItemKindFunction { TSFunction },
CmpItemKindMethod { TSMethod },
-- front
CmpItemKindKeyword { TSKeyword },
CmpItemKindProperty { TSProperty },
-- Link all uncommented TS values to their semantic equivalents
sym("@function")({ TSFunction }),
sym("@keyword")({ TSKeyword }),
sym("@method")({ TSMethod }),
sym("@property")({ TSProperty }),
sym("@type")({ TSType }),
sym("@variable")({ TSVariable }),
sym("@text")({ TSText }),
-- cmp highlights
CmpItemAbbrDeprecated({ fg = c.green, gui = "strikethrough" }),
CmpItemAbbrMatch({ fg = c.green }),
CmpItemAbbrMatchFuzzy({ CmpItemAbbrMatch }),
CmpItemKindVariable({ TSVariable }),
CmpItemKindInterface({ TSType }),
CmpItemKindText({ TSText }),
CmpItemKindFunction({ TSFunction }),
CmpItemKindMethod({ TSMethod }),
CmpItemKindKeyword({ TSKeyword }),
CmpItemKindProperty({ TSProperty }),
-- CmpItemKindUnit { Normal },
}
end)