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