feat: create highlights abstraction

This commit is contained in:
Daniel Hill 2023-03-25 20:10:26 -04:00
parent 2cb4af8a62
commit 7dcce2ff17
7 changed files with 431 additions and 273 deletions

View File

@ -1,4 +1,5 @@
local config = require("gruber-darker.config") local config = require("gruber-darker.config")
local highlights = require("gruber-darker.highlights")
local M = {} local M = {}
@ -19,9 +20,6 @@ function M.load()
vim.opt.termguicolors = true vim.opt.termguicolors = true
vim.g.colors_name = "GruberDarker" vim.g.colors_name = "GruberDarker"
-- set highlights here...
local highlights = require("gruber-darker.hl")
highlights.setup() highlights.setup()
local gruber_darker_group = vim.api.nvim_create_augroup("GruberDarker", { clear = true }) local gruber_darker_group = vim.api.nvim_create_augroup("GruberDarker", { clear = true })

View File

@ -0,0 +1,65 @@
---@class HighlightOpts
---@field fg Color foreground
---@field bg Color background
---@field sp Color special
---@field blend integer value between 0 and 100
---@field bold boolean
---@field standout boolean
---@field underline boolean
---@field undercurl boolean
---@field underdouble boolean
---@field underdotted boolean
---@field underdashed boolean
---@field strikethrough boolean
---@field italic boolean
---@field reverse boolean
---@field nocombine boolean
---@field link Highlight
---@field default any Don't override existing definition
---@field ctermfg any
---@field ctermbg any
---@field cterm any
---Get highlight definition map accepted by `nvim_set_hl`
---@param opts HighlightOpts
---@return table<string, any>
local function get_hl_definition_map(opts)
local hl = {}
for key, value in pairs(opts) do
if key == "fg" or key == "bg" or key == "sp" then
hl[key] = value:to_string()
elseif key == "link" then
hl[key] = value.group
else
hl[key] = value
end
end
return hl
end
---@class Highlight
---@field private group string
---@field private opts HighlightOpts
local Highlight = {}
Highlight.__index = Highlight
---Create a new highlight
---@param group string
---@param opts HighlightOpts
---@return Highlight
function Highlight.new(group, opts)
local highlight = setmetatable({
group = group,
opts = opts,
}, Highlight)
return highlight
end
---Set global highlight for the group this is associated with
function Highlight:setup()
vim.api.nvim_set_hl(0, self.group, get_hl_definition_map(self.opts))
end
return Highlight

View File

@ -0,0 +1,14 @@
local terminal_hl = require("gruber-darker.highlights.terminal")
local vim_hl = require("gruber-darker.highlights.vim")
local treesitter_hl = require("gruber-darker.highlights.treesitter")
local M = {}
---Set highlights for configured groups
function M.setup()
terminal_hl.setup()
vim_hl.setup()
treesitter_hl.setup()
end
return M

View File

@ -0,0 +1,37 @@
local c = require("gruber-darker.palette")
local M = {}
---Set Neovim terminal colors
function M.setup()
-- terminal colors adapted from
-- https://github.com/drsooch/gruber-darker-vim/blob/master/colors/GruberDarker.vim#L202
vim.g.terminal_color_0 = c.default["bg+1"]:to_string()
vim.g.terminal_color_8 = c.default["bg+1"]:to_string()
vim.g.terminal_color_1 = c.default["red+1"]:to_string()
vim.g.terminal_color_9 = c.default["red+1"]:to_string()
vim.g.terminal_color_2 = c.default.green:to_string()
vim.g.terminal_color_10 = c.default.green:to_string()
vim.g.terminal_color_3 = c.default.yellow:to_string()
vim.g.terminal_color_11 = c.default.yellow:to_string()
vim.g.terminal_color_4 = c.default.niagara:to_string()
vim.g.terminal_color_12 = c.default.niagara:to_string()
vim.g.terminal_color_5 = c.default.wisteria:to_string()
vim.g.terminal_color_13 = c.default.wisteria:to_string()
vim.g.terminal_color_6 = c.default.niagara:to_string()
vim.g.terminal_color_14 = c.default.niagara:to_string()
vim.g.terminal_color_7 = c.default.fg:to_string()
vim.g.terminal_color_15 = c.default.fg:to_string()
vim.g.terminal_color_background = c.default["bg+1"]:to_string()
vim.g.terminal_color_foreground = c.default.white:to_string()
end
return M

View File

@ -0,0 +1,91 @@
local c = require("gruber-darker.palette")
local config = require("gruber-darker.config").get_resolved_opts()
local vim_hl = require("gruber-darker.highlights.vim")
local Highlight = require("gruber-darker.highlight")
local M = {
---@type table<string, Highlight>
highlights = {},
}
---Set `nvim-treesitter` plugin highlights
function M.setup()
for _, value in pairs(M.highlights) do
value:setup()
end
end
-- These groups are for the neovim tree-sitter highlights.
-- As of writing, tree-sitter support is a WIP, group names may change.
-- By default, most of these groups link to an appropriate Vim group,
-- TSError -> Error for example, so you do not have to define these unless
-- you explicitly want to support Treesitter's improved syntax awareness.
-- TSAnnotation = Highlight.new("", { }) -- For C++/Dart attributes, annotations that can be attached to the code to denote some kind of meta information.
-- TSAttribute = Highlight.new("", { }) -- (unstable) TODO: docs
M.highlights.boolean = Highlight.new("TSBoolean", { fg = c.default.quartz }) -- For booleans.
M.highlights.character = Highlight.new("TSCharacter", { fg = c.default.green }) -- For characters.
M.highlights.comment = Highlight.new("TSComment", { fg = c.default.brown }) -- For comment blocks.
-- TSNote = Highlight.new("TSNote", { fg = c.bg, bg = c.info })
M.highlights.text_warning = Highlight.new("@text.warning", { fg = c.default.red })
M.highlights.text_danger = Highlight.new("@text.danger", { fg = c.default.white, bg = c.default.red })
-- ["@constructor"] = Highlight.new("", { fg = c.magenta }, -- For constructor calls and definitions: `= { })` in Lua, and Java constructors.
M.highlights.conditional = Highlight.new("TSConditional", { fg = c.default.yellow }) -- For keywords related to conditionnals.
M.highlights.constant = Highlight.new("TSConstant", { fg = c.default.quartz }) -- For constants
-- TSConstBuiltin = Highlight.new("", { }) -- For constant that are built in the language: `nil` in Lua.
-- TSConstMacro = Highlight.new("", { }) -- For constants that are defined by macros: `NULL` in C.
-- TSError = Highlight.new("", { }) -- For syntax/parser errors.
-- TSException = Highlight.new("", { }) -- For exception related keywords.
-- ["@field"] = Highlight.new("", { fg = c.green1 }) -- For fields.
-- TSFloat = Highlight.new("", { }) -- For floats.
-- TSFunction = Highlight.new("", { }) -- For function (calls and definitions).
-- TSFuncBuiltin = Highlight.new("", { }) -- For builtin functions: `table.insert` in Lua.
-- TSFuncMacro = Highlight.new("", { }) -- For macro defined fuctions (calls and definitions): each `macro_rules` in Rust.
-- TSInclude = Highlight.new("", { }) -- For includes: `#include` in C, `use` or `extern crate` in Rust, or `require` in Lua.
-- ["@keyword"] = Highlight.new("", { fg = c.purple, style = options.styles.keywords }) -- For keywords that don't fall in previous categories.
-- ["@keyword.function"] = Highlight.new("", { fg = c.magenta, style = options.styles.functions }) -- For keywords used to define a fuction.
-- ["@label"] = Highlight.new("", { fg = c.blue }) -- For labels: `label:` in C and `:label:` in Lua.
-- TSMethod = Highlight.new("", { }) -- For method calls and definitions.
-- TSNamespace = Highlight.new("", { }) -- For identifiers referring to modules and namespaces.
-- TSNone = Highlight.new("", { }) -- TODO: docs
-- TSNumber = Highlight.new("", { }) -- For all numbers
-- ["@operator"] = Highlight.new("", { fg = c.blue5 }) -- For any operator: `+`, but also `->` and `*` in C.
-- ["@parameter"] = Highlight.new("", { fg = c.yellow }) -- For parameters of a function.
-- TSParameterReference= { }, -- For references to parameters of a function.
-- ["@property"] = Highlight.new("", { fg = c.green1 }) -- Same as `TSField`.
-- ["@punctuation.delimiter"] = Highlight.new("", { fg = c.blue5 }) -- For delimiters ie: `.`
-- ["@punctuation.bracket"] = Highlight.new("", { fg = c.fg_dark }) -- For brackets and parens.
-- ["@punctuation.special"] = Highlight.new("", { fg = c.blue5 }) -- For special punctutation that does not fall in the catagories before.
-- For keywords related to loops.
M.highlights.repeats = Highlight.new("TSRepeat", { fg = c.default.yellow })
-- For strings.
M.highlights.string = Highlight.new("TSString", { fg = c.default.green })
-- ["@string.regex"] = Highlight.new("", { fg = c.blue6 }) -- For regexes.
-- ["@string.escape"] = Highlight.new("", { fg = c.magenta }) -- For escape characters within a string.
-- TSSymbol = Highlight.new("", { }) -- For identifiers referring to symbols or atoms.
---For types.
M.highlights.type = Highlight.new("TSType", { fg = c.default.quartz })
-- TSTypeBuiltin = Highlight.new("", { }) -- For builtin types.
-- ["@variable"] = Highlight.new("", { style = options.styles.variables }) -- Any variable name that does not have another highlight.
-- ["@variable.builtin"] = Highlight.new("", { fg = c.red }) -- Variable names that are defined by the languages, like `this` or `self`.
-- TSTag = Highlight.new("", { }) -- Tags like html tag names.
-- TSTagDelimiter = Highlight.new("", { }) -- Tag delimiter like `<` `>` `/`
-- TSText = Highlight.new("", { }) -- For strings considered text in a markup language.
-- ["@text.reference"] = Highlight.new("", { fg = c.teal })
-- TSEmphasis = Highlight.new("", { }) -- For text to be represented with emphasis.
-- TSUnderline = Highlight.new("", { }) -- For text to be represented with an underline.
-- TSStrike = Highlight.new("", { }) -- For strikethrough text.
-- TSTitle = Highlight.new("", { }) -- Text that is part of a title.
-- TSLiteral = Highlight.new("", { }) -- Literal text.
---Any URI like a link or email.
M.highlights.uri = Highlight.new("TSURI", { fg = c.default.niagara, underline = config.underline })
M.highlights.text_diff_add = Highlight.new("@text.diff.add", { link = vim_hl.highlights.diff_add })
M.highlights.text_diff_delete = Highlight.new("@text.diff.delete", { link = vim_hl.highlights.diff_delete })
M.highlights.text_diff_change = Highlight.new("@text.diff.change", { link = vim_hl.highlights.diff_change })
return M

View File

@ -0,0 +1,223 @@
local c = require("gruber-darker.palette")
local config = require("gruber-darker.config").get_resolved_opts()
local Highlight = require("gruber-darker.highlight")
local M = {
---@type table<string, Highlight>
highlights = {},
}
---Set standard Vim highlights
function M.setup()
for _, value in pairs(M.highlights) do
value:setup()
end
end
---any comment
M.highlights.comment =
Highlight.new("Comment", { fg = c.default.brown, italic = config.comment_italics and config.italic })
---used for the columns set with 'colorcolumn'
M.highlights.color_column = Highlight.new("ColorColumn", { bg = c.default["bg+2"] })
---placeholder characters substituted for concealed text (see 'conceallevel')
M.highlights.conceal = Highlight.new("Conceal", { fg = c.default.fg, bg = c.default.bg })
---character under the cursor
M.highlights.cursor = Highlight.new("Cursor", { bg = c.default.yellow })
---the character under the cursor when |language-mapping| is used (see 'guicursor')
M.highlights.l_cursor = Highlight.new("lCursor", { fg = c.default.none, bg = c.default.yellow })
---like Cursor, but used when in IME mode |CursorIM|
M.highlights.cursor_im = Highlight.new("CursorIM", { fg = c.default.none, bg = c.default.yellow })
---Screen-column at the cursor, when 'cursorcolumn' is set.
M.highlights.cursor_column = Highlight.new("CursorColumn", { bg = c.default["bg+2"] })
---Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set.
M.highlights.cursor_line = Highlight.new("CursorLine", { bg = c.default["bg+1"] })
---Directory = Highlight.new("Directory", { fg = c.default.lightblue }) ---directory names (and other special names in listings)
---diff mode: Added line |diff.txt|
M.highlights.diff_add = Highlight.new("DiffAdd", { fg = c.default.green, bg = c.default.none })
---diff mode: Changed line |diff.txt|
M.highlights.diff_change = Highlight.new("DiffChange", { fg = c.default.yellow, bg = c.default.none })
---diff mode: Deleted line |diff.txt|
M.highlights.diff_delete = Highlight.new("DiffDelete", { fg = c.default["red+1"], bg = c.default.none })
---diff mode: Changed text within a changed line |diff.txt|
M.highlights.diff_text = Highlight.new("DiffText", { fg = c.default.yellow, bg = c.default.none })
---filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|.
M.highlights.end_of_buffer = Highlight.new("EndOfBuffer", { fg = c.default.fg, bg = c.default.bg })
---cursor in a focused terminal
M.highlights.term_cursor = Highlight.new("TermCursor", { bg = c.default.yellow })
---TermCursorNC= { }, ---cursor in an unfocused terminal
---error messages on the command line
M.highlights.error_msg = Highlight.new("ErrorMsg", { fg = c.default.white, bg = c.default.red })
---the column separating vertically split windows
M.highlights.vert_split = Highlight.new("VertSplit", { fg = c.default["fg+2"], bg = c.default["bg+1"] })
---the column separating vertically split windows
M.highlights.win_separator = Highlight.new("WinSeparator", { fg = c.default["bg+2"], bold = config.bold })
---line used for closed folds
M.highlights.folded = Highlight.new("Folded", { fg = c.default.brown, bg = c.default["fg+2"], italic = true })
---'foldcolumn'
M.highlights.fold_column = Highlight.new("FoldColumn", { fg = c.default.brown, bg = c.default["fg+2"] })
---column where |signs| are displayed
M.highlights.sign_column = Highlight.new("SignColumn", { fg = c.default["bg+2"], bg = c.default.none })
---SignColumnSB = Highlight.new("SignColumnSB", { bg = c.bg_sidebar, fg = c.fg_gutter }) ---column where |signs| are displayed
---Substitute = Highlight.new("Substitute", { bg = c.red, fg = c.black }) ---|:substitute| replacement text highlighting
---Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set.
M.highlights.line_number = Highlight.new("LineNr", { fg = c.default["bg+4"] })
---Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line.
M.highlights.cursor_line_number = Highlight.new("CursorLineNr", { fg = c.default.yellow })
---The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
M.highlights.match_paren = Highlight.new("MatchParen", { fg = c.default.fg, bg = c.default.wisteria })
---'showmode' message (e.g., "---INSERT ---")
M.highlights.mode_msg = Highlight.new("ModeMsg", { fg = c.default["fg+2"] })
---MsgArea = Highlight.new("MsgArea", { fg = c.fg_dark }) ---Area for messages and cmdline
---MsgSeparator= { }, ---Separator for scrolled messages, `msgsep` flag of 'display'
---|more-prompt|
M.highlights.more_msg = Highlight.new("MoreMsg", { fg = c.default["fg+2"] })
---'@' 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|.
M.highlights.non_text = Highlight.new("NonText", { fg = c.default["fg+2"] })
---normal text
M.highlights.normal = Highlight.new("Normal", { fg = c.default.fg, bg = c.default.bg })
---normal text in non-current windows
M.highlights.normal_non_current = Highlight.new("NormalNC", { fg = c.default.fg, bg = c.default.bg })
---normal text in sidebar
M.highlights.normal_sidebar = Highlight.new("NormalSB", { fg = c.default.fg, bg = c.default.bg })
---Normal text in floating windows.
M.highlights.normal_float = Highlight.new("NormalFloat", { fg = c.default.fg, bg = c.default.bg })
M.highlights.float_border = Highlight.new("FloatBorder", { fg = c.default["bg+2"], bg = c.default["bg-1"] })
---Popup menu: normal item.
M.highlights.popup_menu = Highlight.new("Pmenu", { fg = c.default.fg, bg = c.default["bg+1"] })
---Popup menu: selected item.
M.highlights.popup_menu = Highlight.new("PmenuSel", { fg = c.default.fg, bg = c.default["bg+2"] })
---Popup menu: scrollbar.
M.highlights.popup_menu_sidebar = Highlight.new("PmenuSbar", { bg = c.default.bg })
---Popup menu: Thumb of the scrollbar.
M.highlights.popup_menu_thumb = Highlight.new("PmenuThumb", { bg = c.default.bg })
---|hit-enter| prompt and yes/no questions
M.highlights.question = Highlight.new("Question", { fg = c.default.niagara })
---Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there.
M.highlights.quick_fix_line = Highlight.new("QuickFixLine", { bg = c.default["bg+2"], bold = config.bold })
---Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
M.highlights.search = Highlight.new("Search", { fg = c.default.black, bg = c.default.yellow })
---'incsearch' highlighting; also used for the text replaced with ":s///c"
M.highlights.incremental_search = Highlight.new("IncSearch", { fg = c.default.black, bg = c.default["fg+2"] })
M.highlights.current_search = Highlight.new("CurSearch", { link = M.highlights.incremental_search })
---Unprintable characters: text displayed differently from what it really is. But not 'listchars' whitespace. |hl-Whitespace|
M.highlights.special_key = Highlight.new("SpecialKey", { fg = c.default["fg+2"] })
---Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise.
M.highlights.spell_bad = Highlight.new("SpellBad", { undercurl = true })
---Word that should start with a capital. |spell| Combined with the highlighting used otherwise.
M.highlights.spell_cap = Highlight.new("SpellCap", { undercurl = true })
---Word that is recognized by the spellchecker as one that is used in another region. |spell| Combined with the highlighting used otherwise.
M.highlights.spell_local = Highlight.new("SpellLocal", { undercurl = true })
---Word that is recognized by the spellchecker as one that is hardly ever used. |spell| Combined with the highlighting used otherwise.
M.highlights.spell_rare = Highlight.new("SpellRare", { undercurl = true })
---status line of current window
M.highlights.status_line = Highlight.new("StatusLine", { fg = c.default.white, bg = c.default["bg+1"] })
---status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window.
M.highlights.status_line_non_current = Highlight.new("StatusLineNC", { fg = c.default.quartz, bg = c.default["bg+1"] })
---tab pages line, not active tab page label
M.highlights.tab_line = Highlight.new("TabLine", { bg = c.default.none })
---tab pages line, where there are no labels
M.highlights.tab_line_fill = Highlight.new("TabLineFill", { fg = c.default["bg+4"], bg = c.default["bg+1"] })
---tab pages line, active tab page label
M.highlights.tab_line_sel =
Highlight.new("TabLineSel", { fg = c.default.yellow, bg = c.default.none, bold = config.bold })
---titles for output from ":set all", ":autocmd" etc.
M.highlights.title = Highlight.new("Title", { fg = c.default.quartz })
---Visual mode selection
M.highlights.visual = Highlight.new("Visual", { bg = c.default["bg+2"] })
---Visual mode selection when vim is "Not Owning the Selection".
M.highlights.visual_nos = Highlight.new("VisualNOS", { fg = c.default.red })
---warning messages
M.highlights.warning_msg = Highlight.new("WarningMsg", { fg = c.default.red })
---"nbsp", "space", "tab" and "trail" in 'listchars'
M.highlights.whitespace = Highlight.new("Whitespace", { fg = c.default["bg+4"], bg = c.default.none })
---current match in 'wildmenu' completion
M.highlights.wild_menu = Highlight.new("WildMenu", { fg = c.default.black, bg = c.default.yellow })
---These groups are not listed as default vim groups,
---but they are defacto standard group names for syntax highlighting.
---commented out groups should chain up to their "preferred" group by
---default,
---Uncomment and edit if you want more specific syntax highlighting.
---(preferred) any constant
M.highlights.constant = Highlight.new("Constant", { fg = c.default.quartz })
--- a string constant: "this is a string"
M.highlights.string = Highlight.new("String", { fg = c.default.green })
--- a character constant: 'c', '\n'
M.highlights.character = Highlight.new("Character", { fg = c.default.green })
--- a number constant: 234, 0xff
M.highlights.number = Highlight.new("Number", { fg = c.default.fg })
--- a boolean constant: TRUE, false
M.highlights.boolean = Highlight.new("Boolean", { fg = c.default.yellow, bold = config.bold })
--- a floating point constant: 2.3e10
M.highlights.float = Highlight.new("Float", { fg = c.default.yellow, bold = config.bold })
---(preferred) any variable name
M.highlights.identifier = Highlight.new("Identifier", { fg = c.default["fg+1"] })
---function name (also: methods for classes)
M.highlights.func = Highlight.new("Function", { fg = c.default.niagara })
---(preferred) any statement
M.highlights.statement = Highlight.new("Statement", { fg = c.default.yellow })
---if, then, else, endif, switch, etc.
M.highlights.conditional = Highlight.new("Conditional", { fg = c.default.yellow, bold = config.bold })
---for, do, while, etc.
M.highlights.repeats = Highlight.new("Repeat", { fg = c.default.yellow, bold = config.bold })
---case, default, etc.
M.highlights.label = Highlight.new("Label", { fg = c.default.yellow, bold = config.bold })
---"sizeof", "+", "*", etc.
M.highlights.operator = Highlight.new("Operator", { fg = c.default.yellow })
---any other keyword
M.highlights.keyword = Highlight.new("Keyword", { fg = c.default.yellow, bold = config.bold })
---try, catch, throw
M.highlights.exception = Highlight.new("Exception", { fg = c.default.yellow, bold = config.bold })
---(preferred) generic Preprocessor
M.highlights.pre_proc = Highlight.new("PreProc", { fg = c.default.quartz })
---preprocessor #include
M.highlights.include = Highlight.new("Include", { fg = c.default.quartz })
---preprocessor #define
M.highlights.define = Highlight.new("Define", { fg = c.default.quartz })
---same as Define
M.highlights.macro = Highlight.new("Macro", { fg = c.default.quartz })
---preprocessor #if, #else, #endif, etc.
M.highlights.pre_condit = Highlight.new("PreCondit", { fg = c.default.quartz })
---(preferred) int, long, char, etc.
M.highlights.type = Highlight.new("Type", { fg = c.default.quartz })
---static, register, volatile, etc.
M.highlights.storage_class = Highlight.new("StorageClass", { fg = c.default.yellow, bold = config.bold })
---struct, union, enum, etc.
M.highlights.structure = Highlight.new("Structure", { fg = c.default.yellow, bold = config.bold })
---A typedef
M.highlights.typedef = Highlight.new("Typedef", { fg = c.default.yellow, bold = config.bold })
---(preferred) any special symbol
M.highlights.special = Highlight.new("Special", { fg = c.default.yellow })
---SpecialChar = Highlight.new("", { }) --- special character in a constant
---Tag = Highlight.new("", { }) --- you can use CTRL-] on this
---Delimiter = Highlight.new("", { }) --- character that needs attention
---SpecialComment= { }, ---special things inside a comment
---Debug = Highlight.new("Debug", { fg = c.default["fg+2"] }) --- debugging statements
---(preferred) text that stands out, HTML links
M.highlights.underlined = Highlight.new("Underlined", { underline = config.underline })
M.highlights.bold = Highlight.new("Bold", { bold = config.bold })
M.highlights.italic = Highlight.new("Italic", { italic = config.italic })
---("Ignore", below, may be invisible...)
---Ignore = Highlight.new("Ignore", { }) ---(preferred) left blank, hidden |hl-Ignore|
---Error = Highlight.new("Error", { fg = c.error }) ---(preferred) any erroneous construct
---(preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX
M.highlights.todo = Highlight.new("Todo", { fg = c.default.bg, bg = c.default.yellow })
M.highlights.md_heading_delim =
Highlight.new("markdownHeadingDelimiter", { fg = c.default.niagara, bold = config.bold })
M.highlights.md_code = Highlight.new("markdownCode", { fg = c.default.green })
M.highlights.md_code_block = Highlight.new("markdownCodeBlock", { fg = c.default.green })
---markdownH1 = Highlight.new("markdownH1", { fg = c.magenta, bold = true })
---markdownH2 = Highlight.new("markdownH2", { fg = c.blue, bold = true })
---markdownLinkText = Highlight.new("markdownLinkText", { fg = c.blue, underline = true })
M.highlights.md_italic = Highlight.new("markdownItalic", { fg = c.default.wisteria, italic = config.italic })
M.highlights.md_bold = Highlight.new("markdownBold", { fg = c.default.yellow, bold = config.bold })
M.highlights.md_code_delim =
Highlight.new("markdownCodeDelimiter", { fg = c.default.brown, italic = config.italic })
M.highlights.md_error = Highlight.new("markdownError", { fg = c.default.fg, bg = c.default["bg+1"] })
return M

View File

@ -1,270 +0,0 @@
local c = require("gruber-darker.palette")
local config = require("gruber-darker.config").get_resolved_opts()
local M = {}
local groups = {
Comment = { fg = c.default.brown:to_string(), italic = config.comment_italics and config.italic }, -- any comment
ColorColumn = { bg = c.default["bg+2"]:to_string() }, -- used for the columns set with 'colorcolumn'
Conceal = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- placeholder characters substituted for concealed text (see 'conceallevel')
Cursor = { bg = c.default.yellow:to_string() }, -- character under the cursor
lCursor = { fg = c.default.none:to_string(), bg = c.default.yellow:to_string() }, -- the character under the cursor when |language-mapping| is used (see 'guicursor')
CursorIM = { fg = c.default.none:to_string(), bg = c.default.yellow:to_string() }, -- like Cursor, but used when in IME mode |CursorIM|
CursorColumn = { bg = c.default["bg+2"]:to_string() }, -- Screen-column at the cursor, when 'cursorcolumn' is set.
CursorLine = { bg = c.default["bg+1"]:to_string() }, -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set.
-- Directory = { fg = c.default.lightblue:to_string() }, -- directory names (and other special names in listings)
DiffAdd = { fg = c.default.green:to_string(), bg = c.default.none:to_string() }, -- diff mode: Added line |diff.txt|
DiffChange = { fg = c.default.yellow:to_string(), bg = c.default.none:to_string() }, -- diff mode: Changed line |diff.txt|
DiffDelete = { fg = c.default["red+1"]:to_string(), bg = c.default.none:to_string() }, -- diff mode: Deleted line |diff.txt|
DiffText = { fg = c.default.yellow:to_string(), bg = c.default.none:to_string() }, -- diff mode: Changed text within a changed line |diff.txt|
EndOfBuffer = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|.
TermCursor = { bg = c.default.yellow:to_string() }, -- cursor in a focused terminal
-- TermCursorNC= { }, -- cursor in an unfocused terminal
ErrorMsg = { fg = c.default.white:to_string(), bg = c.default.red:to_string() }, -- error messages on the command line
VertSplit = { fg = c.default["fg+2"]:to_string(), bg = c.default["bg+1"]:to_string() }, -- the column separating vertically split windows
WinSeparator = { fg = c.default["bg+2"]:to_string(), bold = config.bold }, -- the column separating vertically split windows
Folded = { fg = c.default.brown:to_string(), bg = c.default["fg+2"]:to_string(), italic = true }, -- line used for closed folds
FoldColumn = { fg = c.default.brown:to_string(), bg = c.default["fg+2"]:to_string() }, -- 'foldcolumn'
SignColumn = { fg = c.default["bg+2"]:to_string(), bg = c.default.none:to_string() }, -- column where |signs| are displayed
-- SignColumnSB = { bg = c.bg_sidebar, fg = c.fg_gutter }, -- column where |signs| are displayed
-- Substitute = { bg = c.red, fg = c.black }, -- |:substitute| replacement text highlighting
LineNr = { fg = c.default["bg+4"]:to_string() }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set.
CursorLineNr = { fg = c.default.yellow:to_string() }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line.
MatchParen = { fg = c.default.fg:to_string(), bg = c.default.wisteria:to_string() }, -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
ModeMsg = { fg = c.default["fg+2"]:to_string() }, -- 'showmode' message (e.g., "-- INSERT -- ")
-- MsgArea = { fg = c.fg_dark }, -- Area for messages and cmdline
-- MsgSeparator= { }, -- Separator for scrolled messages, `msgsep` flag of 'display'
MoreMsg = { fg = c.default["fg+2"]:to_string() }, -- |more-prompt|
NonText = { fg = c.default["fg+2"]:to_string() }, -- '@' 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 = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- normal text
NormalNC = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- normal text in non-current windows
NormalSB = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- normal text in sidebar
NormalFloat = { fg = c.default.fg:to_string(), bg = c.default.bg:to_string() }, -- Normal text in floating windows.
FloatBorder = { fg = c.default["bg+2"]:to_string(), bg = c.default["bg-1"]:to_string() },
Pmenu = { fg = c.default.fg:to_string(), bg = c.default["bg+1"]:to_string() }, -- Popup menu: normal item.
PmenuSel = { fg = c.default.fg:to_string(), bg = c.default["bg+2"]:to_string() }, -- Popup menu: selected item.
PmenuSbar = { bg = c.default.bg:to_string() }, -- Popup menu: scrollbar.
PmenuThumb = { bg = c.default.bg:to_string() }, -- Popup menu: Thumb of the scrollbar.
Question = { fg = c.default.niagara:to_string() }, -- |hit-enter| prompt and yes/no questions
QuickFixLine = { bg = c.default["bg+2"]:to_string(), bold = config.bold }, -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there.
Search = { fg = c.default.black:to_string(), bg = c.default.yellow:to_string() }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
IncSearch = { fg = c.default.black:to_string(), bg = c.default["fg+2"]:to_string() }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
CurSearch = { link = "IncSearch" },
SpecialKey = { fg = c.default["fg+2"]:to_string() }, -- Unprintable characters: text displayed differently from what it really is. But not 'listchars' whitespace. |hl-Whitespace|
SpellBad = { undercurl = true }, -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise.
SpellCap = { undercurl = true }, -- Word that should start with a capital. |spell| Combined with the highlighting used otherwise.
SpellLocal = { undercurl = true }, -- Word that is recognized by the spellchecker as one that is used in another region. |spell| Combined with the highlighting used otherwise.
SpellRare = { undercurl = true }, -- Word that is recognized by the spellchecker as one that is hardly ever used. |spell| Combined with the highlighting used otherwise.
StatusLine = { fg = c.default.white:to_string(), bg = c.default["bg+1"]:to_string() }, -- status line of current window
StatusLineNC = { fg = c.default.quartz:to_string(), bg = c.default["bg+1"]:to_string() }, -- status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window.
TabLine = { bg = c.default.none:to_string() }, -- tab pages line, not active tab page label
TabLineFill = { fg = c.default["bg+4"]:to_string(), bg = c.default["bg+1"]:to_string() }, -- tab pages line, where there are no labels
TabLineSel = { fg = c.default.yellow:to_string(), bg = c.default.none:to_string(), bold = config.bold }, -- tab pages line, active tab page label
Title = { fg = c.default.quartz:to_string() }, -- titles for output from ":set all", ":autocmd" etc.
Visual = { bg = c.default["bg+2"]:to_string() }, -- Visual mode selection
VisualNOS = { fg = c.default.red:to_string() }, -- Visual mode selection when vim is "Not Owning the Selection".
WarningMsg = { fg = c.default.red:to_string() }, -- warning messages
Whitespace = { fg = c.default["bg+4"]:to_string(), bg = c.default.none:to_string() }, -- "nbsp", "space", "tab" and "trail" in 'listchars'
WildMenu = { fg = c.default.black:to_string(), bg = c.default.yellow:to_string() }, -- current match in 'wildmenu' completion
-- These groups are not listed as default vim groups,
-- but they are defacto standard group names for syntax highlighting.
-- commented out groups should chain up to their "preferred" group by
-- default,
-- Uncomment and edit if you want more specific syntax highlighting.
Constant = { fg = c.default.quartz:to_string() }, -- (preferred) any constant
String = { fg = c.default.green:to_string() }, -- a string constant: "this is a string"
Character = { fg = c.default.green:to_string() }, -- a character constant: 'c', '\n'
Number = { fg = c.default.fg:to_string() }, -- a number constant: 234, 0xff
Boolean = { fg = c.default.yellow:to_string(), bold = config.bold }, -- a boolean constant: TRUE, false
Float = { fg = c.default.yellow:to_string(), bold = config.bold }, -- a floating point constant: 2.3e10
Identifier = { fg = c.default["fg+1"]:to_string() }, -- (preferred) any variable name
Function = { fg = c.default.niagara:to_string() }, -- function name (also: methods for classes)
Statement = { fg = c.default.yellow:to_string() }, -- (preferred) any statement
Conditional = { fg = c.default.yellow:to_string(), bold = config.bold }, -- if, then, else, endif, switch, etc.
Repeat = { fg = c.default.yellow:to_string(), bold = config.bold }, -- for, do, while, etc.
Label = { fg = c.default.yellow:to_string(), bold = config.bold }, -- case, default, etc.
Operator = { fg = c.default.yellow:to_string() }, -- "sizeof", "+", "*", etc.
Keyword = { fg = c.default.yellow:to_string(), bold = config.bold }, -- any other keyword
Exception = { fg = c.default.yellow:to_string(), bold = config.bold }, -- try, catch, throw
PreProc = { fg = c.default.quartz:to_string() }, -- (preferred) generic Preprocessor
Include = { fg = c.default.quartz:to_string() }, -- preprocessor #include
Define = { fg = c.default.quartz:to_string() }, -- preprocessor #define
Macro = { fg = c.default.quartz:to_string() }, -- same as Define
PreCondit = { fg = c.default.quartz:to_string() }, -- preprocessor #if, #else, #endif, etc.
Type = { fg = c.default.quartz:to_string() }, -- (preferred) int, long, char, etc.
StorageClass = { fg = c.default.yellow:to_string(), bold = config.bold }, -- static, register, volatile, etc.
Structure = { fg = c.default.yellow:to_string(), bold = config.bold }, -- struct, union, enum, etc.
Typedef = { fg = c.default.yellow:to_string(), bold = config.bold }, -- A typedef
Special = { fg = c.default.yellow:to_string() }, -- (preferred) any special symbol
-- SpecialChar = { }, -- special character in a constant
-- Tag = { }, -- you can use CTRL-] on this
-- Delimiter = { }, -- character that needs attention
-- SpecialComment= { }, -- special things inside a comment
-- Debug = { fg = c.default["fg+2"]:to_string() }, -- debugging statements
Underlined = { underline = config.underline }, -- (preferred) text that stands out, HTML links
Bold = { bold = config.bold },
Italic = { italic = config.italic },
-- ("Ignore", below, may be invisible...)
-- Ignore = { }, -- (preferred) left blank, hidden |hl-Ignore|
-- Error = { fg = c.error }, -- (preferred) any erroneous construct
Todo = { fg = c.default.bg:to_string(), bg = c.default.yellow:to_string() }, -- (preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX
markdownHeadingDelimiter = { fg = c.default.niagara:to_string(), bold = config.bold },
markdownCode = { fg = c.default.green:to_string() },
markdownCodeBlock = { fg = c.default.green:to_string() },
-- markdownH1 = { fg = c.magenta, bold = true },
-- markdownH2 = { fg = c.blue, bold = true },
-- markdownLinkText = { fg = c.blue, underline = true },
markdownItalic = { fg = c.default.wisteria:to_string(), italic = config.italic },
markdownBold = { fg = c.default.yellow:to_string(), bold = config.bold },
markdownCodeDelimiter = { fg = c.default.brown:to_string(), italic = config.italic },
markdownError = { fg = c.default.fg:to_string(), bg = c.default["bg+1"]:to_string() },
-- These groups are for the neovim tree-sitter highlights.
-- As of writing, tree-sitter support is a WIP, group names may change.
-- By default, most of these groups link to an appropriate Vim group,
-- TSError -> Error for example, so you do not have to define these unless
-- you explicitly want to support Treesitter's improved syntax awareness.
-- TSAnnotation = { }, -- For C++/Dart attributes, annotations that can be attached to the code to denote some kind of meta information.
-- TSAttribute = { }, -- (unstable) TODO: docs
TSBoolean = { fg = c.default.quartz:to_string() }, -- For booleans.
TSCharacter = { fg = c.default.green:to_string() }, -- For characters.
TSComment = { fg = c.default.brown:to_string() }, -- For comment blocks.
-- TSNote = { fg = c.bg, bg = c.info },
["@text.warning"] = { fg = c.default.red:to_string() },
["@text.danger"] = { fg = c.default.white:to_string(), bg = c.default.red:to_string() },
-- ["@constructor"] = { fg = c.magenta }, -- For constructor calls and definitions: `= { }` in Lua, and Java constructors.
TSConditional = { fg = c.default.yellow:to_string() }, -- For keywords related to conditionnals.
TSConstant = { fg = c.default.quartz:to_string() }, -- For constants
-- TSConstBuiltin = { }, -- For constant that are built in the language: `nil` in Lua.
-- TSConstMacro = { }, -- For constants that are defined by macros: `NULL` in C.
-- TSError = { }, -- For syntax/parser errors.
-- TSException = { }, -- For exception related keywords.
-- ["@field"] = { fg = c.green1 }, -- For fields.
-- TSFloat = { }, -- For floats.
-- TSFunction = { }, -- 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.
-- ["@keyword"] = { fg = c.purple, style = options.styles.keywords }, -- For keywords that don't fall in previous categories.
-- ["@keyword.function"] = { fg = c.magenta, style = options.styles.functions }, -- For keywords used to define a fuction.
-- ["@label"] = { fg = c.blue }, -- For labels: `label:` in C and `:label:` in Lua.
-- TSMethod = { }, -- For method calls and definitions.
-- TSNamespace = { }, -- For identifiers referring to modules and namespaces.
-- TSNone = { }, -- TODO: docs
-- TSNumber = { }, -- For all numbers
-- ["@operator"] = { fg = c.blue5 }, -- For any operator: `+`, but also `->` and `*` in C.
-- ["@parameter"] = { fg = c.yellow }, -- For parameters of a function.
-- TSParameterReference= { }, -- For references to parameters of a function.
-- ["@property"] = { fg = c.green1 }, -- Same as `TSField`.
-- ["@punctuation.delimiter"] = { fg = c.blue5 }, -- For delimiters ie: `.`
-- ["@punctuation.bracket"] = { fg = c.fg_dark }, -- For brackets and parens.
-- ["@punctuation.special"] = { fg = c.blue5 }, -- For special punctutation that does not fall in the catagories before.
TSRepeat = { fg = c.default.yellow:to_string() }, -- For keywords related to loops.
TSString = { fg = c.default.green:to_string() }, -- For strings.
-- ["@string.regex"] = { fg = c.blue6 }, -- For regexes.
-- ["@string.escape"] = { fg = c.magenta }, -- For escape characters within a string.
-- TSSymbol = { }, -- For identifiers referring to symbols or atoms.
TSType = { fg = c.default.quartz:to_string() }, -- For types.
-- TSTypeBuiltin = { }, -- For builtin types.
-- ["@variable"] = { style = options.styles.variables }, -- Any variable name that does not have another highlight.
-- ["@variable.builtin"] = { fg = c.red }, -- Variable names that are defined by the languages, like `this` or `self`.
-- TSTag = { }, -- Tags like html tag names.
-- TSTagDelimiter = { }, -- Tag delimiter like `<` `>` `/`
-- TSText = { }, -- For strings considered text in a markup language.
-- ["@text.reference"] = { fg = c.teal },
-- TSEmphasis = { }, -- For text to be represented with emphasis.
-- TSUnderline = { }, -- For text to be represented with an underline.
-- TSStrike = { }, -- For strikethrough text.
-- TSTitle = { }, -- Text that is part of a title.
-- TSLiteral = { }, -- Literal text.
TSURI = { fg = c.default.niagara:to_string(), underline = config.underline }, -- Any URI like a link or email.
["@text.diff.add"] = { link = "DiffAdd" },
["@text.diff.delete"] = { link = "DiffDelete" },
["@text.diff.change"] = { link = "DiffChange" },
-- Cmp
-- CmpDocumentation = { link = "NormalFloat" },
-- CmpDocumentationBorder = { link = "FloatBorder" },
-- CmpItemAbbr = { fg = c.fg, bg = c.none },
-- CmpItemAbbrDeprecated = { fg = c.fg_gutter, bg = c.none, strikethrough = true },
-- CmpItemAbbrMatch = { fg = c.blue1, bg = c.none },
-- CmpItemAbbrMatchFuzzy = { fg = c.blue1, bg = c.none },
-- CmpItemMenu = { fg = c.default.white:to_string(), bg = c.default["bg+4"]:to_string() },
-- CmpItemKindDefault = { fg = c.default.white:to_string(), bg = c.default["bg+4"]:to_string() },
-- CmpItemKindKeyword = { fg = c.cyan, bg = c.none },
-- CmpItemKindVariable = { fg = c.magenta, bg = c.none },
-- CmpItemKindConstant = { fg = c.magenta, bg = c.none },
-- CmpItemKindReference = { fg = c.magenta, bg = c.none },
-- CmpItemKindValue = { fg = c.magenta, bg = c.none },
-- CmpItemKindFunction = { fg = c.blue, bg = c.none },
-- CmpItemKindMethod = { fg = c.blue, bg = c.none },
-- CmpItemKindConstructor = { fg = c.blue, bg = c.none },
-- CmpItemKindClass = { fg = c.orange, bg = c.none },
-- CmpItemKindInterface = { fg = c.orange, bg = c.none },
-- CmpItemKindStruct = { fg = c.orange, bg = c.none },
-- CmpItemKindEvent = { fg = c.orange, bg = c.none },
-- CmpItemKindEnum = { fg = c.orange, bg = c.none },
-- CmpItemKindUnit = { fg = c.orange, bg = c.none },
-- CmpItemKindModule = { fg = c.yellow, bg = c.none },
-- CmpItemKindProperty = { fg = c.green1, bg = c.none },
-- CmpItemKindField = { fg = c.green1, bg = c.none },
-- CmpItemKindTypeParameter = { fg = c.green1, bg = c.none },
-- CmpItemKindEnumMember = { fg = c.green1, bg = c.none },
-- CmpItemKindOperator = { fg = c.green1, bg = c.none },
-- CmpItemKindSnippet = { fg = c.dark5, bg = c.none },
}
---Set Neovim terminal colors
local function set_terminal_colors()
-- terminal colors adapted from
-- https://github.com/drsooch/gruber-darker-vim/blob/master/colors/GruberDarker.vim#L202
vim.g.terminal_color_0 = c.default["bg+1"]:to_string()
vim.g.terminal_color_8 = c.default["bg+1"]:to_string()
vim.g.terminal_color_1 = c.default["red+1"]:to_string()
vim.g.terminal_color_9 = c.default["red+1"]:to_string()
vim.g.terminal_color_2 = c.default.green:to_string()
vim.g.terminal_color_10 = c.default.green:to_string()
vim.g.terminal_color_3 = c.default.yellow:to_string()
vim.g.terminal_color_11 = c.default.yellow:to_string()
vim.g.terminal_color_4 = c.default.niagara:to_string()
vim.g.terminal_color_12 = c.default.niagara:to_string()
vim.g.terminal_color_5 = c.default.wisteria:to_string()
vim.g.terminal_color_13 = c.default.wisteria:to_string()
vim.g.terminal_color_6 = c.default.niagara:to_string()
vim.g.terminal_color_14 = c.default.niagara:to_string()
vim.g.terminal_color_7 = c.default.fg:to_string()
vim.g.terminal_color_15 = c.default.fg:to_string()
vim.g.terminal_color_background = c.default["bg+1"]:to_string()
vim.g.terminal_color_foreground = c.default.white:to_string()
end
---Highlights bootstrapper
function M.setup()
set_terminal_colors()
for group, hl in pairs(groups) do
vim.api.nvim_set_hl(0, group, hl)
end
end
return M