From ea493989980c07b2a24e905bc30f4be78142678c Mon Sep 17 00:00:00 2001 From: fiplox Date: Sat, 8 Apr 2023 21:33:19 +0200 Subject: [PATCH] feat!: rework plugin, ~10x load time reduce --- colors/neogruber.lua | 13 +- lua/neogruber/colors/init.lua | 16 - lua/neogruber/colors/neogruber.lua | 34 -- lua/neogruber/config.lua | 41 -- lua/neogruber/groups.lua | 534 +++++++++++++++++++++++ lua/neogruber/init.lua | 49 ++- lua/neogruber/palette.lua | 32 ++ lua/neogruber/theme.lua | 677 ----------------------------- lua/neogruber/util.lua | 53 --- 9 files changed, 601 insertions(+), 848 deletions(-) delete mode 100644 lua/neogruber/colors/init.lua delete mode 100644 lua/neogruber/colors/neogruber.lua delete mode 100644 lua/neogruber/config.lua create mode 100644 lua/neogruber/groups.lua create mode 100644 lua/neogruber/palette.lua delete mode 100644 lua/neogruber/theme.lua delete mode 100644 lua/neogruber/util.lua diff --git a/colors/neogruber.lua b/colors/neogruber.lua index 1c741c6..55dc6b4 100644 --- a/colors/neogruber.lua +++ b/colors/neogruber.lua @@ -1,12 +1 @@ --- Refresh cache for local debugging and development purposes -if vim.g.neogruber_debug == true then - package.loaded['neogruber'] = nil - package.loaded['neogruber.util'] = nil - package.loaded['neogruber.colors'] = nil - package.loaded['neogruber.colors.neogruber'] = nil - package.loaded['neogruber.theme'] = nil -end - -local neogruber = require 'neogruber' - -neogruber.load(false) +require("neogruber").load() diff --git a/lua/neogruber/colors/init.lua b/lua/neogruber/colors/init.lua deleted file mode 100644 index 2c5e996..0000000 --- a/lua/neogruber/colors/init.lua +++ /dev/null @@ -1,16 +0,0 @@ -local colors = require 'neogruber.colors.neogruber' - -local function load() - local theme = require('neogruber.config').options.theme - - -- if style is set, it takes priority - -- otherwise, use vim.o.background - if not theme then - theme = vim.o.background - end - - local base_colors = colors - return vim.tbl_deep_extend('force', base_colors, require('neogruber.config').options.custom_colors) -end - -return { load = load } diff --git a/lua/neogruber/colors/neogruber.lua b/lua/neogruber/colors/neogruber.lua deleted file mode 100644 index c51bb59..0000000 --- a/lua/neogruber/colors/neogruber.lua +++ /dev/null @@ -1,34 +0,0 @@ -local colors = { - fg_1 = '#d4dfdf', - fg = '#e4e4ef', - fg1 = '#f4f4ff', - fg2 = '#f5f5f5', - white = '#ffffff', - black = '#000000', - bg_1 = '#101010', - bg = '#181818', - bg1 = '#282828', - bg2 = '#453d41', - bg3 = '#484848', - bg4 = '#52494e', - bg5 = '#9998a8', - bg6 = '#c1c0d4', - red_1 = '#c73c3f', - red = '#f43841', - red1 = '#ff4f58', - green = '#73c936', - green1 = '#73da00', - yellow = '#ffdd11', - brown = '#cc8c3c', - quartz = '#95a99f', - niagara_2 = '#303540', - niagara_1 = '#565f73', - niagara = '#96a6c8', - wisteria = '#9e95c7', - wisteria1 = '#9f90f9', - light_blue = '#0087d7', - -- Special - none = 'NONE', -} - -return colors diff --git a/lua/neogruber/config.lua b/lua/neogruber/config.lua deleted file mode 100644 index 77830cf..0000000 --- a/lua/neogruber/config.lua +++ /dev/null @@ -1,41 +0,0 @@ -local config = {} - -local defaults = { - theme = nil, -- "dark" or "light". Alternatively, remove the option and set vim.o.background instead - borders = true, -- Split window borders - fade_nc = false, -- Fade non-current windows, making them more distinguishable - -- Style that is applied to various groups: see `highlight-args` for options - styles = { - comments = 'NONE', - strings = 'NONE', - keywords = 'NONE', - functions = 'NONE', - variables = 'NONE', - diagnostics = 'underline', - storage_class = 'NONE', - structure = 'NONE', - loop_cond = 'NONE', - builtin = 'NONE', - }, - disable = { - background = false, -- Disable setting the background color - cursorline = false, -- Disable the cursorline - eob_lines = true, -- Hide the end-of-buffer lines - }, - -- Inverse highlight for different groups - inverse = { - match_paren = false, - }, - custom_highlights = {}, -- Overwrite default highlight groups - custom_colors = {}, -- Overwrite default colors -} - -config.options = {} - -function config.set_options(opts) - config.options = vim.tbl_deep_extend('force', config.options, opts or {}) -end - -config.set_options(defaults) - -return config diff --git a/lua/neogruber/groups.lua b/lua/neogruber/groups.lua new file mode 100644 index 0000000..d402a48 --- /dev/null +++ b/lua/neogruber/groups.lua @@ -0,0 +1,534 @@ +local M = {} + +M.setup = function() + local config = require('neogruber').config + local c = require 'neogruber.palette' + + local groups = { + -- int, long, char, etc. + Type = { fg = c.yellow }, + -- static, register, volatile, etc. + StorageClass = { fg = c.yellow, bold = config.bold }, + -- struct, union, enum, etc. + Structure = { fg = c.yellow }, + -- any constant + Constant = { fg = c.wisteria1 }, + -- any character constant: 'c', '\n' + Character = { fg = c.green }, + -- a number constant: 5 + Number = { fg = c.quartz }, + -- a boolean constant: TRUE, false + Boolean = { fg = c.quartz }, + -- a floating point constant: 2.3e10 + Float = { fg = c.quartz }, + -- any statement + Statement = { fg = c.yellow }, + -- case, default, etc. + Label = { fg = c.yellow }, + -- sizeof", "+", "*", etc. + Operator = { fg = c.yellow }, + -- try, catch, throw + Exception = { fg = c.yellow }, + -- generic Preprocessor + PreProc = { fg = c.quartz }, + -- preprocessor #include + Include = { fg = c.quartz }, + -- preprocessor #define + Define = { fg = c.quartz }, + -- same as Define + Macro = { fg = c.quartz }, + -- A typedef + Typedef = { fg = c.yellow, bold = config.bold }, + -- preprocessor #if, #else, #endif, etc. + PreCondit = { fg = c.quartz }, + -- any special symbol + Special = { fg = c.niagara }, + -- special character in a constant + SpecialChar = { fg = c.niagara }, + -- you can use CTRL-] on this + Tag = { fg = c.brown }, + -- character that needs attention like , or . + Delimiter = { fg = c.wisteria }, + -- special things inside a comment + SpecialComment = { fg = c.brown }, + -- debugging statements + Debug = { fg = c.brown }, + -- text that stands out, HTML links + Underlined = { underline = config.underline }, + -- left blank, hidden + Ignore = {}, + -- any erroneous construct + Error = { fg = c.red, bold = config.bold, underline = config.underline }, + -- anything that needs extra attention; mostly the keywords TODO FIXME and XXX + Todo = { fg = c.brown, bold = config.bold, italic = config.italic }, + Comment = { fg = c.bg3, italic = config.italic }, -- normal comments + -- normal if, then, else, endif, switch, etc. + Conditional = { fg = c.yellow, bold = config.bold }, + -- normal for, do, while, etc. + Keyword = { fg = c.yellow, bold = config.bold }, + -- normal any other keyword + Repeat = { fg = c.yellow, bold = config.bold }, + -- normal function names + Function = { fg = c.niagara }, + zshFunction = { fg = c.niagara }, + -- any variable name + Identifier = { fg = c.bg6 }, + -- any string + String = { fg = c.green }, + + htmlLink = { fg = c.green, underline = config.underline }, + htmlArg = { fg = c.light_blue }, + htmlTag = { fg = c.bg6 }, + htmlEndTag = { fg = c.bg6 }, + htmlTagN = { fg = c.bg5 }, + htmlTagName = { fg = c.light_blue }, + htmlSpecialTagName = { fg = c.yellow }, + htmlH1 = { fg = c.light_blue, bold = config.bold }, + htmlH2 = { fg = c.wisteria1, bold = config.bold }, + htmlH3 = { fg = c.niagara, bold = config.bold }, + htmlH4 = { fg = c.wisteria, bold = config.bold }, + htmlH5 = { fg = c.quartz, bold = config.bold }, + + cssAttributeSelector = { fg = c.light_blue }, + cssSelectorOp = { fg = c.niagara1 }, + cssTagName = { fg = c.yellow }, + + markdownBlockquote = { fg = c.bg6 }, + markdownBold = { bold = config.bold }, + markdownCode = { fg = c.yellow }, + markdownCodeBlock = { fg = c.yellow }, + markdownCodeDelimiter = { fg = c.green }, + markdownH1 = { fg = c.light_blue, bold = config.bold }, + markdownH2 = { fg = c.wisteria1, bold = config.bold }, + markdownH3 = { fg = c.niagara, bold = config.bold }, + markdownH4 = { fg = c.wisteria, bold = config.bold }, + markdownH5 = { fg = c.quartz, bold = config.bold }, + markdownH6 = { fg = c.green, bold = config.bold }, + markdownH1Delimiter = { fg = c.bg5 }, + markdownH2Delimiter = { fg = c.bg5 }, + markdownH3Delimiter = { fg = c.bg5 }, + markdownH4Delimiter = { fg = c.bg5 }, + markdownH5Delimiter = { fg = c.bg5 }, + markdownH6Delimiter = { fg = c.bg5 }, + markdownId = { fg = c.yellow }, + markdownIdDeclaration = { fg = c.niagara }, + markdownIdDelimiter = { fg = c.light_blue }, + markdownLinkDelimiter = { fg = c.bg5 }, + markdownItalic = { italic = config.italic }, + markdownLinkText = { fg = c.niagara }, + markdownListMarker = { fg = c.red_1 }, + markdownOrderedListMarker = { fg = c.red }, + markdownRule = { fg = c.bg5 }, + markdownUrl = { fg = c.green, underline = config.underline }, + + -- normal text and background color for floating windows + NormalFloat = { fg = c.fg, bg = c.bg1 }, + -- floating window border + FloatBorder = { fg = c.yellow }, + -- used for the columns set with 'colorcolumn' + ColorColumn = { bg = c.bg2 }, + -- placeholder characters substituted for concealed text (see 'conceallevel') + Conceal = {}, + -- the character under the cursor + Cursor = { reverse = config.inverse }, + vCursor = { link = 'Cursor' }, + iCursor = { link = 'Cursor' }, + lCursor = { link = 'Cursor' }, + -- like Cursor, but used when in IME mode + CursorIM = { fg = c.none, bg = c.none }, + -- directory names (and other special names in listings) + Directory = { fg = c.light_blue, bg = c.none }, + -- diff mode: Added line + DiffAdd = { fg = c.green, bg = c.none }, + -- diff mode: Changed line + DiffChange = { fg = c.brown, bg = c.none }, + -- diff mode: Deleted line + DiffDelete = { fg = c.red_1, bg = c.none }, + -- diff mode: Changed text within a changed line + DiffText = { fg = c.none, bg = c.none }, + -- error messages + ErrorMsg = { fg = c.red_1 }, + -- line used for closed folds + Folded = { fg = c.brown, bg = c.none, italic = config.italic }, + -- 'foldcolumn' + FoldColumn = {}, + -- 'incsearch' highlighting; also used for the text replaced with ":s///c" + IncSearch = { fg = c.yellow, bg = c.bg3, bold = true, underline = config.underline }, + CurSearch = { link = 'IncSearch' }, + -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. + LineNr = { fg = c.bg3 }, + -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. + CursorLineNr = { fg = c.yellow }, + -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| + MatchParen = { fg = c.wisteria1, bg = c.none, bold = config.bold, underline = config.underline }, + -- 'showmode' message (e.g., "-- INSERT -- ") + ModeMsg = { fg = c.light_blue, bold = config.bold }, + -- |more-prompt| + MoreMsg = { fg = c.light_blue, bold = config.bold }, + -- '@' 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 = { fg = c.bg2 }, + -- normal item |hl-Pmenu| + Pmenu = { fg = c.fg, bg = c.bg1 }, + -- selected item |hl-PmenuSel| + PmenuSel = { bg = c.bg2 }, + -- scrollbar |hl-PmenuSbar| + PmenuSbar = { bg = c.bg }, + -- thumb of the scrollbar |hl-PmenuThumb| + PmenuThumb = { bg = c.fg }, + -- |hit-enter| prompt and yes/no questions + Question = { fg = c.green }, + -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there. + QuickFixLine = { bg = c.light_blue, bold = config.bold }, + -- Line numbers for quickfix lists + qfLineNr = { fg = c.yellow }, + -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. + Search = { fg = c.brown, bg = c.none, bold = config.bold }, + -- Unprintable characters: text displayed differently from what it really is. + -- But not 'listchars' whitespace. |hl-Whitespace| + SpecialKey = { fg = c.bg6 }, + -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise. + SpellBad = { italic = config.italic, undercurl = config.undercurl }, + -- Word that should start with a capital. |spell| Combined with the highlighting used otherwise. + SpellCap = { fg = c.bg6 }, + -- Word that is recognized by the spellchecker as one that is used in another region. + -- |spell| Combined with the highlighting used otherwise. + SpellLocal = { fg = c.brown }, + -- Word that is recognized by the spellchecker as one that is hardly ever used. + -- |spell| Combined with the highlighting used otherwise. + SpellRare = { fg = c.brown }, + -- status line of current window + StatusLine = { fg = c.white, bg = c.bg1 }, + -- status lines of not-current windows Note: if this is equal to "StatusLine" + -- Vim will use "^^^" in the status line of the current window. + StatusLineNC = { fg = c.bg5 }, + -- status line of current terminal window + StatusLineTerm = { fg = c.fg, bg = c.bg1 }, + -- status lines of not-current terminal windows Note: if this is equal to "StatusLine" + -- Vim will use "^^^" in the status line of the current window. + StatusLineTermNC = { fg = c.bg5 }, + -- tab pages line, where there are no labels + TabLineFill = {}, + -- tab pages line, active tab page label + TablineSel = { fg = c.white }, + Tabline = { fg = c.bg5 }, + -- titles for output from ":set all", ":autocmd" etc. + Title = { fg = c.green, bg = c.none, bold = config.bold }, + -- Visual mode selection + Visual = { fg = c.none, bg = c.bg1 }, + -- Visual mode selection when vim is "Not Owning the Selection". + VisualNOS = { link = 'Visual' }, + -- warning messages + WarningMsg = { fg = c.red_1 }, + -- "nbsp", "space", "tab" and "trail" in 'listchars' + Whitespace = { fg = c.bg3 }, + -- current match in 'wildmenu' completion + WildMenu = { fg = c.black, bg = c.niagara, bold = config.bold }, + -- window bar of current window + WinBar = { fg = c.white, bg = c.bg1 }, + -- window bar of not-current windows + WinBarNC = { fg = c.bg6, bg = c.bg_1 }, + -- Screen-column at the cursor, when 'cursorcolumn' is set. + CursorColumn = { link = 'CursorLine' }, + -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set. + CursorLine = { fg = c.none, bg = c.bg1 }, + -- Normal mode message in the cmdline + NormalMode = { fg = c.light_blue, bg = c.none, reverse = config.inverse }, + -- Insert mode message in the cmdline + InsertMode = { fg = c.green, bg = c.none, reverse = config.inverse }, + -- Replace mode message in the cmdline + ReplacelMode = { fg = c.red, bg = c.none, reverse = config.inverse }, + -- Visual mode message in the cmdline + VisualMode = { fg = c.wisteria1, bg = c.none, reverse = config.inverse }, + -- Command mode message in the cmdline + CommandMode = { fg = c.yellow, bg = c.none, reverse = config.inverse }, + Warnings = { fg = c.red1 }, + + healthError = { fg = c.red }, + healthSuccess = { fg = c.green }, + healthWarning = { fg = c.red_1 }, + + -- Dashboard + DashboardShortCut = { fg = c.light_blue }, + DashboardHeader = { fg = c.wisteria1 }, + DashboardCenter = { fg = c.niagara }, + DashboardFooter = { fg = c.green, italic = config.italic }, + + -- normal text and background color + Normal = { fg = c.fg, bg = c.bg }, + NormalNC = config.dim_inactive and { fg = c.fg_1, bg = c.bg_1 } or { link = 'Normal' }, + SignColumn = { fg = c.fg, bg = c.none }, + + -- the column separating vertically split windows + VertSplit = { fg = c.bg }, + + EndOfBuffer = { fg = c.bg6 }, + + ['@annotation'] = { link = 'Operator' }, + ['@comment'] = { link = 'Comment' }, + ['@none'] = { bg = 'NONE', fg = 'NONE' }, + ['@preproc'] = { link = 'PreProc' }, + ['@define'] = { link = 'Define' }, + ['@string'] = { link = 'String' }, + ['@string.special'] = { link = 'SpecialChar' }, + ['@character.special'] = { link = 'SpecialChar' }, + ['@method'] = { link = 'Function' }, + ['@method.call'] = { link = 'Function' }, + ['@keyword'] = { link = 'Keyword' }, + ['@keyword.function'] = { link = 'Keyword' }, + ['@keyword.operator'] = { fg = c.yellow }, + ['@keyword.return'] = { fg = c.yellow }, + ['@keyword.coroutine'] = { fg = c.yellow }, + ['@conditional'] = { link = 'Conditional' }, + ['@repeat'] = { link = 'Repeat' }, + ['@debug'] = { link = 'Debug' }, + ['@type'] = { link = 'Type' }, + ['@type.builtin'] = { fg = c.yellow, bold = config.bold }, + ['@type.qualifier'] = { fg = c.yellow, bold = config.bold }, + ['@type.definition'] = { link = 'Typedef' }, + ['@storageclass'] = { link = 'StorageClass' }, + ['@variable.builtin'] = { fg = c.wisteria }, + ['@variable'] = { fg = c.niagara1 }, + ['@text.title'] = { link = 'Title' }, + ['@text.uri'] = { link = 'Underlined' }, + ['@text.todo'] = { link = 'Todo' }, + ['@text.todo.unchecked'] = { link = 'Todo' }, + ['@text.todo.checked'] = { link = 'Done' }, + ['@text.note'] = { link = 'SpecialComment' }, + ['@text.warning'] = { link = 'WarningMsg' }, + ['@text.danger'] = { link = 'ErrorMsg' }, + ['@text.strong'] = { bold = config.bold }, + ['@text.emphasis'] = { italic = config.italic }, + ['@text.underline'] = { underline = config.underline }, + ['@note'] = { fg = c.yellow }, + ['@warning'] = { fg = c.red_1 }, + ['@danger'] = { fg = c.red1 }, + ['@parent'] = { fg = c.wisteria }, + ['@attribute'] = { fg = c.wisteria1 }, + ['@boolean'] = { fg = c.quartz }, + ['@character'] = { fg = c.green }, + ['@constant'] = { fg = c.wisteria1 }, + ['@constant.builtin'] = { fg = c.wisteria1 }, + ['@constant.macro'] = { fg = c.wisteria1 }, + ['@constructor'] = { fg = c.yellow }, + ['@error'] = { fg = c.red }, + ['@exception'] = { fg = c.yellow }, + ['@field'] = { fg = c.niagara }, + ['@float'] = { fg = c.quartz }, + ['@function'] = { link = 'Function' }, + ['@function.builtin'] = { fg = c.niagara1 }, + ['@function.macro'] = { fg = c.yellow }, + ['@include'] = { fg = c.quartz }, + ['@label'] = { fg = c.yellow }, + ['@namespace'] = { fg = c.niagara }, + ['@number'] = { fg = c.brown }, + ['@operator'] = { fg = c.niagara_1 }, + ['@parameter'] = { fg = c.wisteria }, -- TODO: see what it does + ['@parameter.reference'] = { fg = c.wisteria }, + ['@property'] = { fg = c.wisteria1 }, + ['@punctuation.delimiter'] = { fg = c.niagara }, + ['@punctuation.bracket'] = { fg = c.niagara_1 }, + ['@punctuation.special'] = { fg = c.niagara }, + ['@string.regex'] = { fg = c.brown }, + ['@string.escape'] = { fg = c.brown }, + ['@symbol'] = { fg = c.light_blue }, + ['@tag'] = { fg = c.yellow }, + ['@tag.attribute'] = { fg = c.bg6 }, + ['@tag.delimiter'] = { fg = c.fg2 }, + ['@text'] = { fg = c.fg }, + ['@text.literal'] = { fg = c.green }, + ['@text.diff.add'] = { fg = c.green }, + ['@text.diff.delete'] = { fg = c.red_1 }, + ['@text.math'] = { fg = c.fg }, + ['@text.reference'] = { fg = c.brown }, + ['@text.environment'] = { fg = c.fg }, + ['@text.environment.name'] = { fg = c.fg }, + + -- used for "Error" diagnostic virtual text + LspDiagnosticsDefaultError = { fg = c.red1 }, + -- used for "Error" diagnostic signs in sign column + LspDiagnosticsSignError = { fg = c.red1 }, + -- used for "Error" diagnostic messages in the diagnostics float + LspDiagnosticsFloatingError = { fg = c.red1 }, + -- Virtual text "Error" + LspDiagnosticsVirtualTextError = { fg = c.red1 }, + -- used to underline "Error" diagnostics. + LspDiagnosticsUnderlineError = {}, + -- used for "Warning" diagnostic signs in sign column + LspDiagnosticsDefaultWarning = { fg = c.red_1 }, + -- used for "Warning" diagnostic signs in sign column + LspDiagnosticsSignWarning = { fg = c.red_1 }, + -- used for "Warning" diagnostic messages in the diagnostics float + LspDiagnosticsFloatingWarning = { fg = c.red_1 }, + -- Virtual text "Warning" + LspDiagnosticsVirtualTextWarning = { fg = c.red_1 }, + -- used to underline "Warning" diagnostics. + LspDiagnosticsUnderlineWarning = {}, + -- used for "Information" diagnostic virtual text + LspDiagnosticsDefaultInformation = { fg = c.yellow }, + -- used for "Information" diagnostic signs in sign column + LspDiagnosticsSignInformation = { fg = c.yellow }, + -- used for "Information" diagnostic messages in the diagnostics float + LspDiagnosticsFloatingInformation = { fg = c.yellow }, + -- Virtual text "Information" + LspDiagnosticsVirtualTextInformation = { fg = c.yellow }, + -- used to underline "Information" diagnostics. + LspDiagnosticsUnderlineInformation = {}, + -- used for "Hint" diagnostic virtual text + LspDiagnosticsDefaultHint = { fg = c.wisteria }, + -- used for "Hint" diagnostic signs in sign column + LspDiagnosticsSignHint = { fg = c.wisteria }, + -- used for "Hint" diagnostic messages in the diagnostics float + LspDiagnosticsFloatingHint = { fg = c.wisteria }, + -- Virtual text "Hint" + LspDiagnosticsVirtualTextHint = { fg = c.wisteria }, + -- used to underline "Hint" diagnostics. + LspDiagnosticsUnderlineHint = {}, + -- used for highlighting "text" references + LspReferenceText = {}, + -- used for highlighting "read" references + LspReferenceRead = {}, + -- used for highlighting "write" references + LspReferenceWrite = {}, + + LspSignatureActiveParameter = { fg = c.none, bg = c.bg2 }, + LspCodeLens = { fg = c.bg5 }, + + DiagnosticError = { link = 'LspDiagnosticsDefaultError' }, + DiagnosticWarn = { link = 'LspDiagnosticsDefaultWarning' }, + DiagnosticInfo = { link = 'LspDiagnosticsDefaultInformation' }, + DiagnosticHint = { link = 'LspDiagnosticsDefaultHint' }, + DiagnosticVirtualTextWarn = { link = 'LspDiagnosticsVirtualTextWarning' }, + DiagnosticUnderlineWarn = { link = 'LspDiagnosticsUnderlineWarning' }, + DiagnosticFloatingWarn = { link = 'LspDiagnosticsFloatingWarning' }, + DiagnosticSignWarn = { link = 'LspDiagnosticsSignWarning' }, + DiagnosticVirtualTextError = { link = 'LspDiagnosticsVirtualTextError' }, + DiagnosticUnderlineError = { link = 'LspDiagnosticsUnderlineError' }, + DiagnosticFloatingError = { link = 'LspDiagnosticsFloatingError' }, + DiagnosticSignError = { link = 'LspDiagnosticsSignError' }, + DiagnosticVirtualTextInfo = { link = 'LspDiagnosticsVirtualTextInformation' }, + DiagnosticUnderlineInfo = { link = 'LspDiagnosticsUnderlineInformation' }, + DiagnosticFloatingInfo = { link = 'LspDiagnosticsFloatingInformation' }, + DiagnosticSignInfo = { link = 'LspDiagnosticsSignInformation' }, + DiagnosticVirtualTextHint = { link = 'LspDiagnosticsVirtualTextHint' }, + DiagnosticUnderlineHint = { link = 'LspDiagnosticsUnderlineHint' }, + DiagnosticFloatingHint = { link = 'LspDiagnosticsFloatingHint' }, + DiagnosticSignHint = { link = 'LspDiagnosticsSignHint' }, + + -- Cmp + CmpItemAbbr = { fg = c.fg }, + CmpItemAbbrDeprecated = { fg = c.fg }, + CmpItemAbbrMatch = { fg = c.wisteria }, + CmpItemAbbrMatchFuzzy = { fg = c.wisteria, underline = true }, + CmpItemMenu = { fg = c.bg5 }, + + CmpItemKindText = { fg = c.brown }, + CmpItemKindMethod = { fg = c.wisteria }, + CmpItemKindFunction = { fg = c.wisteria }, + CmpItemKindConstructor = { fg = c.yellow }, + CmpItemKindField = { fg = c.wisteria }, + CmpItemKindClass = { fg = c.yellow }, + CmpItemKindInterface = { fg = c.yellow }, + CmpItemKindModule = { fg = c.wisteria }, + CmpItemKindProperty = { fg = c.wisteria }, + CmpItemKindValue = { fg = c.brown }, + CmpItemKindEnum = { fg = c.yellow }, + CmpItemKindKeyword = { fg = c.wisteria1 }, + CmpItemKindSnippet = { fg = c.green }, + CmpItemKindFile = { fg = c.wisteria }, + CmpItemKindEnumMember = { fg = c.light_blue }, + CmpItemKindConstant = { fg = c.brown }, + CmpItemKindStruct = { fg = c.yellow }, + CmpItemKindTypeParameter = { fg = c.yellow }, + + -- Notify + NotifyERRORBorder = { fg = c.red1 }, + NotifyWARNBorder = { fg = c.red_1 }, + NotifyINFOBorder = { fg = c.yellow }, + NotifyDEBUGBorder = { fg = c.bg5 }, + NotifyTRACEBorder = { fg = c.wisteria }, + NotifyERRORIcon = { fg = c.red1 }, + NotifyWARNIcon = { fg = c.red_1 }, + NotifyINFOIcon = { fg = c.yellow }, + NotifyDEBUGIcon = { fg = c.bg5 }, + NotifyTRACEIcon = { fg = c.wisteria }, + NotifyERRORTitle = { fg = c.red1 }, + NotifyWARNTitle = { fg = c.red_1 }, + NotifyINFOTitle = { fg = c.yellow }, + NotifyDEBUGTitle = { fg = c.bg5 }, + NotifyTRACETitle = { fg = c.wisteria }, + + -- Trouble + TroubleCount = { fg = c.wisteria1 }, + TroubleNormal = { fg = c.fg }, + TroubleText = { fg = c.fg }, + + -- Diff + -- diffAdded = { fg = c.green, bg = c.bg1 }, + -- diffRemoved = { fg = c.red_1, bg = c.bg1 }, + -- diffChanged = { fg = c.yellow }, + -- diffOldFile = { fg = c.brown }, + -- diffNewFile = { fg = c.light_blue }, + -- diffFile = { fg = c.wisteria }, + -- diffLine = { fg = c.bg5 }, + -- diffIndexLine = { fg = c.wisteria1 }, + + -- Neogit + NeogitBranch = { fg = c.yellow }, + NeogitRemote = { fg = c.brown }, + NeogitHunkHeader = { fg = c.fg, bg = c.bg1 }, + NeogitHunkHeaderHighlight = { fg = c.yellow, bg = c.bg1 }, + NeogitDiffContextHighlight = { bg = c.none }, + NeogitDiffDeleteHighlight = { fg = c.red_1, bg = c.none }, + NeogitDiffDeleteRegion = { fg = c.red_1, bg = c.none }, + NeogitDiffAddHighlight = { fg = c.green, bg = c.none }, + NeogitDiffAddRegion = { fg = c.green, bg = c.none }, + NeogitDiffDelete = { fg = c.red }, + NeogitDiffAdd = { fg = c.green }, + NeogitCommitViewHeader = { fg = c.quartz }, + NeogitNotificationInfo = { fg = c.wisteria }, + NeogitNotificationWarning = { fg = c.brown }, + NeogitNotificationError = { fg = c.red_1 }, + + -- WhichKey + WhichKey = { fg = c.wisteria1 }, + WhichKeyGroup = { fg = c.light_blue }, + WhichKeyDesc = { fg = c.wisteria }, + WhichKeySeperator = { fg = c.green }, + WhichKeyFloat = { bg = c.bg1 }, + + -- nvim-treesitter-context + TreesitterContext = { fg = c.none, bg = c.bg1 }, + + -- Indent Blankline + IndentBlanklineChar = { fg = c.niagara_2 }, + IndentBlanklineSpaceChar = { fg = c.bg5 }, + IndentBlanklineSpaceCharBlankline = { fg = c.bg5 }, + IndentBlanklineContextChar = { fg = c.wisteria1 }, + IndentBlanklineContextStart = {}, + + -- Nvim dap + DapBreakpoint = { fg = c.red }, + DapStopped = { fg = c.green }, + + -- Hop + HopNextKey = { fg = c.red1 }, + HopNextKey1 = { fg = c.light_blue }, + HopNextKey2 = { fg = c.wisteria1 }, + HopUnmatched = { fg = c.bg5 }, + } + + --[[ for group, hl in pairs(config.overrides) do + if groups[group] then + -- "link" should not mix with other configs (:h hi-link) + groups[group].link = nil + end + + groups[group] = vim.tbl_extend('force', groups[group] or {}, hl) + end ]] + + return groups +end + +return M diff --git a/lua/neogruber/init.lua b/lua/neogruber/init.lua index e24e036..12f00dc 100644 --- a/lua/neogruber/init.lua +++ b/lua/neogruber/init.lua @@ -1,22 +1,41 @@ --- Colorscheme name: neogruber.nvim --- Description: A Neovim theme that combines the Nord and Atom One Dark color palettes. --- Author: Ryan Mehri --- Website: https://github.com/rmehri01/neogruber.nvim +local M = {} -local config = require 'neogruber.config' -local util = require 'neogruber.util' +-- default configs +M.config = { + undercurl = true, + underline = true, + bold = true, + italic = true, + inverse = true, -- invert background for search, diffs, statuslines and errors + -- overrides = {}, + dim_inactive = false, + transparent = true, +} -local neogruber = {} - -function neogruber.setup(options) - config.set_options(options) - neogruber.load(true) +function M.setup(config) + M.config = vim.tbl_deep_extend('force', M.config, config or {}) end -function neogruber.load(exec_autocmd) - local colors = require('neogruber.colors').load() +M.load = function() + if vim.version().minor < 8 then + vim.notify_once 'neogruber.nvim: you must use neovim 0.8 or higher' + return + end - util.load(colors, exec_autocmd) + -- reset colors + if vim.g.colors_name then + vim.cmd.hi 'clear' + end + + vim.g.colors_name = 'neogruber' + vim.o.termguicolors = true + + local groups = require('neogruber.groups').setup() + + -- add highlights + for group, settings in pairs(groups) do + vim.api.nvim_set_hl(0, group, settings) + end end -return neogruber +return M diff --git a/lua/neogruber/palette.lua b/lua/neogruber/palette.lua new file mode 100644 index 0000000..2968cb3 --- /dev/null +++ b/lua/neogruber/palette.lua @@ -0,0 +1,32 @@ +return { + fg_1 = '#d4dfdf', + fg = '#e4e4ef', + fg1 = '#f4f4ff', + fg2 = '#f5f5f5', + white = '#ffffff', + black = '#000000', + bg_1 = '#101010', + bg = '#181818', + bg1 = '#282828', + bg2 = '#453d41', + bg3 = '#484848', + bg4 = '#52494e', + bg5 = '#9998a8', + bg6 = '#c1c0d4', + red_1 = '#c73c3f', + red = '#f43841', + red1 = '#ff4f58', + green = '#73c936', + green1 = '#73da00', + yellow = '#ffdd11', + brown = '#cc8c3c', + quartz = '#95a99f', + niagara_2 = '#303540', + niagara_1 = '#565f73', + niagara = '#96a6c8', + wisteria = '#9e95c7', + wisteria1 = '#9f90f9', + light_blue = '#0087d7', + -- Special + none = 'NONE', +} diff --git a/lua/neogruber/theme.lua b/lua/neogruber/theme.lua deleted file mode 100644 index 2da5b9c..0000000 --- a/lua/neogruber/theme.lua +++ /dev/null @@ -1,677 +0,0 @@ -local theme = {} - -function theme.highlights(c, config) - local function remove_background(group) - group['bg'] = c.none - end - - local function load_syntax() - -- Syntax highlight groups - - local syntax = { - -- int, long, char, etc. - Type = { fg = c.yellow }, - -- static, register, volatile, etc. - StorageClass = { fg = c.yellow, style = config.styles.storage_class }, - -- struct, union, enum, etc. - Structure = { fg = c.yellow, style = config.styles.structure }, - -- any constant - Constant = { fg = c.wisteria1 }, - -- any character constant: 'c', '\n' - Character = { fg = c.green }, - -- a number constant: 5 - Number = { fg = c.quartz }, - -- a boolean constant: TRUE, false - Boolean = { fg = c.quartz }, - -- a floating point constant: 2.3e10 - Float = { fg = c.quartz }, - -- any statement - Statement = { fg = c.yellow }, - -- case, default, etc. - Label = { fg = c.yellow }, - -- sizeof", "+", "*", etc. - Operator = { fg = c.yellow }, - -- try, catch, throw - Exception = { fg = c.yellow }, - -- generic Preprocessor - PreProc = { fg = c.quartz }, - -- preprocessor #include - Include = { fg = c.quartz }, - -- preprocessor #define - Define = { fg = c.quartz }, - -- same as Define - Macro = { fg = c.quartz }, - -- A typedef - Typedef = { fg = c.yellow, style = config.styles.keywords }, - -- preprocessor #if, #else, #endif, etc. - PreCondit = { fg = c.quartz }, - -- any special symbol - Special = { fg = c.brown }, - -- special character in a constant - SpecialChar = { fg = c.brown }, - -- you can use CTRL-] on this - Tag = { fg = c.brown }, - -- character that needs attention like , or . - Delimiter = { fg = c.brown }, - -- special things inside a comment - SpecialComment = { fg = c.brown }, - -- debugging statements - Debug = { fg = c.brown }, - -- text that stands out, HTML links - Underlined = { style = 'underline' }, - -- left blank, hidden - Ignore = {}, - -- any erroneous construct - Error = { fg = c.red, style = 'bold,underline' }, - -- anything that needs extra attention; mostly the keywords TODO FIXME and XXX - Todo = { fg = c.brown, style = 'bold,italic' }, - Comment = { fg = c.bg3, style = config.styles.comments }, -- normal comments - -- normal if, then, else, endif, switch, etc. - Conditional = { fg = c.yellow, style = config.styles.loop_cond }, - -- normal for, do, while, etc. - Keyword = { fg = c.yellow, style = config.styles.keywords }, - -- normal any other keyword - Repeat = { fg = c.yellow, style = config.styles.loop_cond }, - -- normal function names - Function = { fg = c.niagara, style = config.styles.functions }, - -- any variable name - Identifier = { fg = c.niagara, style = config.styles.variables }, - -- any string - String = { fg = c.green, config.styles.strings }, - - htmlLink = { fg = c.green, style = 'underline' }, - htmlArg = { fg = c.light_blue }, - htmlTag = { fg = c.bg6 }, - htmlEndTag = { fg = c.bg6 }, - htmlTagN = { fg = c.bg5 }, - htmlTagName = { fg = c.light_blue }, - htmlSpecialTagName = { fg = c.yellow }, - htmlH1 = { fg = c.light_blue, style = 'bold' }, - htmlH2 = { fg = c.wisteria1, style = 'bold' }, - htmlH3 = { fg = c.niagara, style = 'bold' }, - htmlH4 = { fg = c.wisteria, style = 'bold' }, - htmlH5 = { fg = c.quartz, style = 'bold' }, - - cssAttributeSelector = { fg = c.light_blue }, - cssSelectorOp = { fg = c.niagara1 }, - cssTagName = { fg = c.yellow }, - - markdownBlockquote = { fg = c.bg6 }, - markdownBold = { style = 'bold' }, - markdownCode = { fg = c.yellow }, - markdownCodeBlock = { fg = c.yellow }, - markdownCodeDelimiter = { fg = c.green }, - markdownH1 = { fg = c.light_blue, style = 'bold' }, - markdownH2 = { fg = c.wisteria1, style = 'bold' }, - markdownH3 = { fg = c.niagara, style = 'bold' }, - markdownH4 = { fg = c.wisteria }, - markdownH5 = { fg = c.quartz }, - markdownH6 = { fg = c.green }, - markdownH1Delimiter = { fg = c.bg5 }, - markdownH2Delimiter = { fg = c.bg5 }, - markdownH3Delimiter = { fg = c.bg5 }, - markdownH4Delimiter = { fg = c.bg5 }, - markdownH5Delimiter = { fg = c.bg5 }, - markdownH6Delimiter = { fg = c.bg5 }, - markdownId = { fg = c.yellow }, - markdownIdDeclaration = { fg = c.niagara }, - markdownIdDelimiter = { fg = c.light_blue }, - markdownLinkDelimiter = { fg = c.bg5 }, - markdownItalic = { style = 'italic' }, - markdownLinkText = { fg = c.niagara }, - markdownListMarker = { fg = c.red_1 }, - markdownOrderedListMarker = { fg = c.red }, - markdownRule = { fg = c.bg5 }, - markdownUrl = { fg = c.green, style = 'underline' }, - } - - return syntax - end - - local function load_editor() - -- Editor highlight groups - - local editor = { - -- normal text and background color for floating windows - NormalFloat = { fg = c.fg, bg = c.bg1 }, - -- floating window border - FloatBorder = { fg = c.yellow }, - -- used for the columns set with 'colorcolumn' - ColorColumn = { bg = c.bg2 }, - -- placeholder characters substituted for concealed text (see 'conceallevel') - Conceal = {}, - -- the character under the cursor - Cursor = { bg = c.none, fg = c.none, style = 'reverse' }, - -- like Cursor, but used when in IME mode - CursorIM = { fg = c.none, bg = c.none, style = 'reverse' }, - -- directory names (and other special names in listings) - Directory = { fg = c.light_blue, bg = c.none }, - -- diff mode: Added line - DiffAdd = { fg = c.green, bg = c.none }, - -- diff mode: Changed line - DiffChange = { fg = c.brown, bg = c.none }, - -- diff mode: Deleted line - DiffDelete = { fg = c.red_1, bg = c.none }, - -- diff mode: Changed text within a changed line - DiffText = { fg = c.none, bg = c.none }, - -- error messages - ErrorMsg = { fg = c.red_1 }, - -- line used for closed folds - Folded = { fg = c.brown, bg = c.none, style = 'italic' }, - -- 'foldcolumn' - FoldColumn = {}, - -- 'incsearch' highlighting; also used for the text replaced with ":s///c" - IncSearch = { fg = c.yellow, bg = c.bg3, style = 'bold,underline' }, - -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. - LineNr = { fg = c.bg3 }, - -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. - CursorLineNr = { fg = c.yellow, style = config.styles.cursorlinenr }, - -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| - MatchParen = { fg = c.wisteria1, bg = c.none, style = 'bold,underline' }, - -- 'showmode' message (e.g., "-- INSERT -- ") - ModeMsg = { fg = c.light_blue, style = 'bold' }, - -- |more-prompt| - MoreMsg = { fg = c.light_blue, style = 'bold' }, - -- '@' 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 = { fg = c.bg2 }, - -- normal item |hl-Pmenu| - Pmenu = { fg = c.fg, bg = c.bg1 }, - -- selected item |hl-PmenuSel| - PmenuSel = { bg = c.bg2 }, - -- scrollbar |hl-PmenuSbar| - PmenuSbar = { bg = c.bg }, - -- thumb of the scrollbar |hl-PmenuThumb| - PmenuThumb = { bg = c.fg }, - -- |hit-enter| prompt and yes/no questions - Question = { fg = c.green }, - -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there. - QuickFixLine = { bg = c.light_blue, style = 'bold,italic' }, - -- Line numbers for quickfix lists - qfLineNr = { fg = c.yellow }, - -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. - Search = { fg = c.brown, bg = c.none, style = 'bold' }, - -- Unprintable characters: text displayed differently from what it really is. - -- But not 'listchars' whitespace. |hl-Whitespace| - SpecialKey = { fg = c.bg6 }, - -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise. - SpellBad = { style = 'italic,undercurl' }, - -- Word that should start with a capital. |spell| Combined with the highlighting used otherwise. - SpellCap = { fg = c.bg6 }, - -- Word that is recognized by the spellchecker as one that is used in another region. - -- |spell| Combined with the highlighting used otherwise. - SpellLocal = { fg = c.brown }, - -- Word that is recognized by the spellchecker as one that is hardly ever used. - -- |spell| Combined with the highlighting used otherwise. - SpellRare = { fg = c.brown }, - -- status line of current window - StatusLine = { fg = c.white, bg = c.bg1 }, - -- status lines of not-current windows Note: if this is equal to "StatusLine" - -- Vim will use "^^^" in the status line of the current window. - StatusLineNC = { fg = c.bg5 }, - -- status line of current terminal window - StatusLineTerm = { fg = c.fg, bg = c.bg1 }, - -- status lines of not-current terminal windows Note: if this is equal to "StatusLine" - -- Vim will use "^^^" in the status line of the current window. - StatusLineTermNC = { fg = c.bg5 }, - -- tab pages line, where there are no labels - TabLineFill = {}, - -- tab pages line, active tab page label - TablineSel = { fg = c.white }, - Tabline = { fg = c.bg5 }, - -- titles for output from ":set all", ":autocmd" etc. - Title = { fg = c.green, bg = c.none, style = 'bold' }, - -- Visual mode selection - Visual = { fg = c.none, bg = c.bg1 }, - -- Visual mode selection when vim is "Not Owning the Selection". - VisualNOS = { fg = c.none, bg = c.bg1 }, - -- warning messages - WarningMsg = { fg = c.red_1 }, - -- "nbsp", "space", "tab" and "trail" in 'listchars' - Whitespace = { fg = c.bg3 }, - -- current match in 'wildmenu' completion - WildMenu = { fg = c.black, bg = c.niagara, style = 'bold' }, - -- window bar of current window - WinBar = { fg = c.white, bg = c.bg1 }, - -- window bar of not-current windows - WinBarNC = { fg = c.bg6, bg = c.bg_1 }, - -- Screen-column at the cursor, when 'cursorcolumn' is set. - CursorColumn = { fg = c.none, bg = c.bg1 }, - -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set. - CursorLine = { fg = c.none, bg = c.bg1 }, - -- Normal mode message in the cmdline - NormalMode = { fg = c.light_blue, bg = c.none, style = 'reverse' }, - -- Insert mode message in the cmdline - InsertMode = { fg = c.green, bg = c.none, style = 'reverse' }, - -- Replace mode message in the cmdline - ReplacelMode = { fg = c.red, bg = c.none, style = 'reverse' }, - -- Visual mode message in the cmdline - VisualMode = { fg = c.wisteria1, bg = c.none, style = 'reverse' }, - -- Command mode message in the cmdline - CommandMode = { fg = c.yellow, bg = c.none, style = 'reverse' }, - Warnings = { fg = c.red1 }, - - healthError = { fg = c.red }, - healthSuccess = { fg = c.green }, - healthWarning = { fg = c.red_1 }, - - -- Dashboard - DashboardShortCut = { fg = c.light_blue }, - DashboardHeader = { fg = c.wisteria1 }, - DashboardCenter = { fg = c.niagara }, - DashboardFooter = { fg = c.green, style = 'italic' }, - - -- normal text and background color - Normal = { fg = c.fg, bg = c.bg }, - NormalNC = { bg = c.bg }, - SignColumn = { fg = c.fg, bg = c.none }, - - -- the column separating vertically split windows - VertSplit = { fg = c.bg }, - - EndOfBuffer = { fg = c.bg6 }, - } - - -- Options: - - -- Set non-current background - if config.fade_nc then - editor.NormalNC['bg'] = c.gb1 - editor.NormalFloat['bg'] = c.bg - editor.FloatBorder['bg'] = c.bg - end - - -- Set transparent background - if config.disable.background then - remove_background(editor.Normal) - remove_background(editor.NormalNC) - remove_background(editor.SignColumn) - end - - -- Set transparent cursorline - if config.disable.cursorline then - remove_background(editor.CursorLine) - end - - -- Set transparent eob lines - if config.disable.eob_lines then - editor.EndOfBuffer['fg'] = c.bg - end - - -- Inverse highlighting - if config.inverse.match_paren then - editor.MatchParen['style'] = 'reverse,bold' - end - - -- Add window split borders - if config.borders then - editor.VertSplit['fg'] = c.niagara_2 - end - - return editor - end - - local function load_treesitter() - -- TreeSitter highlight groups - - local treesitter = { - -- Annotations that can be attached to the code to denote some kind of meta information. e.g. C++/Dart attributes. - ['@attribute'] = { fg = c.wisteria1 }, - -- Boolean literals: `True` and `False` in Python. - ['@boolean'] = { fg = c.quartz }, - -- Character literals: `'a'` in C. - ['@character'] = { fg = c.green }, - -- Line comments and block comments. - ['@comment'] = { fg = c.bg3, style = config.styles.comments }, - -- Keywords related to conditionals: `if`, `when`, `cond`, etc. - ['@conditional'] = { fg = c.yellow, style = config.styles.loop_cond }, - -- Constants identifiers. These might not be semantically constant. E.g. uppercase variables in Python. - ['@constant'] = { fg = c.wisteria1 }, - -- Built-in constant values: `nil` in Lua. - ['@constant.builtin'] = { fg = c.wisteria1 }, - -- Constants defined by macros: `NULL` in C. - ['@constant.macro'] = { fg = c.wisteria1 }, - -- Constructor calls and definitions: `{}` in Lua, and Java constructors. - ['@constructor'] = { fg = c.yellow }, - -- Syntax/parser errors. This might highlight large sections of code while the user is typing - -- still incomplete code, use a sensible highlight. - ['@error'] = { fg = c.red }, - -- Exception related keywords: `try`, `except`, `finally` in Python. - ['@exception'] = { fg = c.yellow }, - -- Object and struct fields. - ['@field'] = { fg = c.niagara }, - -- Floating-point number literals. - ['@float'] = { fg = c.quartz }, - -- Function calls and definitions. - ['@function'] = { fg = c.fg_1, style = config.styles.functions }, - -- Built-in functions: `print` in Lua. - ['@function.builtin'] = { fg = c.light_blie, style = config.styles.functions }, - -- Macro defined functions (calls and definitions): each `macro_rules` in Rust. - ['@function.macro'] = { fg = c.yellow }, - -- File or module inclusion keywords: `#include` in C, `use` or `extern crate` in Rust. - ['@include'] = { fg = c.quartz }, - -- Keywords that don't fit into other categories. - ['@keyword'] = { fg = c.yellow, style = config.styles.keywords }, - -- Keywords used to define a function: `function` in Lua, `def` and `lambda` in Python. - ['@keyword.function'] = { fg = c.yellow, style = config.styles.keywords }, - -- Unary and binary operators that are English words: `and`, `or` in Python; `sizeof` in C. - ['@keyword.operator'] = { fg = c.yellow }, - -- Keywords like `return` and `yield`. - ['@keyword.return'] = { fg = c.yellow }, - -- keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) - ['@keyword.coroutine'] = { fg = c.yellow, style = 'bold' }, - -- GOTO labels: `label:` in C, and `::label::` in Lua. - ['@label'] = { fg = c.yellow }, - -- Method calls and definitions. - ['@method'] = { fg = c.quartz, style = config.styles.functions }, - -- Identifiers referring to modules and namespaces. - ['@namespace'] = { fg = c.niagara }, - -- Numeric literals that don't fit into other categories. - ['@number'] = { fg = c.brown }, - -- Binary or unary operators: `+`, and also `->` and `*` in C. - ['@operator'] = { fg = c.bg6 }, - -- Parameters of a function. - ['@parameter'] = { fg = c.wisteria }, -- TODO: see what it does - -- References to parameters of a function. - ['@parameter.reference'] = { fg = c.wisteria }, - -- Same as `@field`. - ['@property'] = { fg = c.wisteria1 }, - -- Punctuation delimiters: Periods, commas, semicolons, etc. - ['@punctuation.delimiter'] = { fg = c.niagara }, - -- Brackets, braces, parentheses, etc. - ['@punctuation.bracket'] = { fg = c.niagara_1 }, - -- Special punctuation that doesn't fit into the previous categories. - ['@punctuation.special'] = { fg = c.niagara }, - -- Keywords related to loops: `for`, `while`, etc. - ['@repeat'] = { fg = c.yellow, style = config.styles.loop_cond }, - -- String literals. - ['@string'] = { fg = c.green, style = config.styles.strings }, - -- Regular expression literals. - ['@string.regex'] = { fg = c.brown }, - -- Escape characters within a string: `\n`, `\t`, etc. - ['@string.escape'] = { fg = c.brown }, - -- Identifiers referring to symbols or atoms. - ['@symbol'] = { fg = c.light_blue }, - -- Tags like HTML tag names. - ['@tag'] = { fg = c.yellow }, - -- HTML tag attributes. - ['@tag.attribute'] = { fg = c.bg6 }, - -- Tag delimiters like `<` `>` `/`. - ['@tag.delimiter'] = { fg = c.fg2 }, - -- Non-structured text. Like text in a markup language. - ['@text'] = { fg = c.fg }, - -- Text to be represented in bold. - ['@text.strong'] = { style = 'bold' }, - -- Text to be represented with emphasis. - ['@text.emphasis'] = { style = 'italic' }, - -- Text to be represented with an underline. - ['@text.underline'] = { style = 'underline' }, - -- Text that is part of a title. - ['@text.title'] = { fg = c.wisteria1, style = 'bold' }, - -- Literal or verbatim text. - ['@text.literal'] = { fg = c.green }, - -- added text (for diff files) - ['@text.diff.add'] = { fg = c.green }, - -- deleted text (for diff files) - ['@text.diff.delete'] = { fg = c.red_1 }, - -- URIs like hyperlinks or email addresses. - ['@text.uri'] = { fg = c.green, style = 'underline' }, - -- Math environments like LaTeX's `$ ... $` - ['@text.math'] = { fg = c.fg }, - -- Footnotes, text references, citations, etc. - ['@text.reference'] = { fg = c.brown }, - -- Text environments of markup languages. - ['@text.environment'] = { fg = c.fg }, - -- Text/string indicating the type of text environment. Like the name of a `\begin` block in LaTeX. - ['@text.environment.name'] = { fg = c.fg }, - -- Text TODOS - ['@text.todo'] = { fg = c.brown, style = 'bold' }, - -- Text representation of an informational note. - ['@note'] = { fg = c.yellow, style = 'bold' }, - -- Text representation of a warning note. - ['@warning'] = { fg = c.red_1, style = 'bold' }, - -- Text representation of a danger note. - ['@danger'] = { fg = c.red1, style = 'bold' }, - -- Type (and class) definitions and annotations. - ['@type'] = { fg = c.yellow, style = config.styles.storage_class }, - -- Built-in types: `i32` in Rust. - ['@type.builtin'] = { fg = c.quartz, style = config.styles.builtin }, - -- type definitions (e.g. `typedef` in C) - ['@type.definition'] = { fg = c.quartz, style = config.styles.builtin }, - -- type qualifiers (e.g. `const`) - ['@type.qualifier'] = { fg = c.yellow, style = config.styles.storage_class }, - -- Variable names that don't fit into other categories. - ['@variable'] = { fg = c.fg, style = config.styles.variables }, - -- Variable names defined by the language: `this` or `self` in Javascript. - ['@variable.builtin'] = { fg = c.wisteria, style = config.styles.variables }, - - -- modifiers that affect storage in memory or life-time - ['@storageclass'] = { fg = c.yellow, style = config.styles.storage_class }, - } - - return treesitter - end - - local function load_lsp() - -- Lsp highlight groups - - local lsp = { - -- used for "Error" diagnostic virtual text - LspDiagnosticsDefaultError = { fg = c.red1 }, - -- used for "Error" diagnostic signs in sign column - LspDiagnosticsSignError = { fg = c.red1 }, - -- used for "Error" diagnostic messages in the diagnostics float - LspDiagnosticsFloatingError = { fg = c.red1 }, - -- Virtual text "Error" - LspDiagnosticsVirtualTextError = { fg = c.red1 }, - -- used to underline "Error" diagnostics. - LspDiagnosticsUnderlineError = { style = config.styles.diagnostics, sp = c.red1 }, - -- used for "Warning" diagnostic signs in sign column - LspDiagnosticsDefaultWarning = { fg = c.red_1 }, - -- used for "Warning" diagnostic signs in sign column - LspDiagnosticsSignWarning = { fg = c.red_1 }, - -- used for "Warning" diagnostic messages in the diagnostics float - LspDiagnosticsFloatingWarning = { fg = c.red_1 }, - -- Virtual text "Warning" - LspDiagnosticsVirtualTextWarning = { fg = c.red_1 }, - -- used to underline "Warning" diagnostics. - LspDiagnosticsUnderlineWarning = { style = config.styles.diagnostics, sp = c.red_1 }, - -- used for "Information" diagnostic virtual text - LspDiagnosticsDefaultInformation = { fg = c.yellow }, - -- used for "Information" diagnostic signs in sign column - LspDiagnosticsSignInformation = { fg = c.yellow }, - -- used for "Information" diagnostic messages in the diagnostics float - LspDiagnosticsFloatingInformation = { fg = c.yellow }, - -- Virtual text "Information" - LspDiagnosticsVirtualTextInformation = { fg = c.yellow }, - -- used to underline "Information" diagnostics. - LspDiagnosticsUnderlineInformation = { style = config.styles.diagnostics, sp = c.yellow }, - -- used for "Hint" diagnostic virtual text - LspDiagnosticsDefaultHint = { fg = c.wisteria }, - -- used for "Hint" diagnostic signs in sign column - LspDiagnosticsSignHint = { fg = c.wisteria }, - -- used for "Hint" diagnostic messages in the diagnostics float - LspDiagnosticsFloatingHint = { fg = c.wisteria }, - -- Virtual text "Hint" - LspDiagnosticsVirtualTextHint = { fg = c.wisteria }, - -- used to underline "Hint" diagnostics. - LspDiagnosticsUnderlineHint = { style = config.styles.diagnostics, sp = c.wisteria }, - -- used for highlighting "text" references - LspReferenceText = { style = 'underline', sp = c.yellow }, - -- used for highlighting "read" references - LspReferenceRead = { style = 'underline', sp = c.yellow }, - -- used for highlighting "write" references - LspReferenceWrite = { style = 'underline', sp = c.yellow }, - - LspSignatureActiveParameter = { fg = c.none, bg = c.bg2, style = 'bold' }, - LspCodeLens = { fg = c.bg5 }, - - DiagnosticError = { link = 'LspDiagnosticsDefaultError' }, - DiagnosticWarn = { link = 'LspDiagnosticsDefaultWarning' }, - DiagnosticInfo = { link = 'LspDiagnosticsDefaultInformation' }, - DiagnosticHint = { link = 'LspDiagnosticsDefaultHint' }, - DiagnosticVirtualTextWarn = { link = 'LspDiagnosticsVirtualTextWarning' }, - DiagnosticUnderlineWarn = { link = 'LspDiagnosticsUnderlineWarning' }, - DiagnosticFloatingWarn = { link = 'LspDiagnosticsFloatingWarning' }, - DiagnosticSignWarn = { link = 'LspDiagnosticsSignWarning' }, - DiagnosticVirtualTextError = { link = 'LspDiagnosticsVirtualTextError' }, - DiagnosticUnderlineError = { link = 'LspDiagnosticsUnderlineError' }, - DiagnosticFloatingError = { link = 'LspDiagnosticsFloatingError' }, - DiagnosticSignError = { link = 'LspDiagnosticsSignError' }, - DiagnosticVirtualTextInfo = { link = 'LspDiagnosticsVirtualTextInformation' }, - DiagnosticUnderlineInfo = { link = 'LspDiagnosticsUnderlineInformation' }, - DiagnosticFloatingInfo = { link = 'LspDiagnosticsFloatingInformation' }, - DiagnosticSignInfo = { link = 'LspDiagnosticsSignInformation' }, - DiagnosticVirtualTextHint = { link = 'LspDiagnosticsVirtualTextHint' }, - DiagnosticUnderlineHint = { link = 'LspDiagnosticsUnderlineHint' }, - DiagnosticFloatingHint = { link = 'LspDiagnosticsFloatingHint' }, - DiagnosticSignHint = { link = 'LspDiagnosticsSignHint' }, - } - - return lsp - end - - local function load_plugins() - -- Plugins highlight groups - - local plugins = { - -- Cmp - CmpItemAbbr = { fg = c.fg }, - CmpItemAbbrDeprecated = { fg = c.fg }, - CmpItemAbbrMatch = { fg = c.wisteria, style = 'bold' }, - CmpItemAbbrMatchFuzzy = { fg = c.wisteria, underline = true }, - CmpItemMenu = { fg = c.bg5 }, - - CmpItemKindText = { fg = c.brown }, - CmpItemKindMethod = { fg = c.wisteria }, - CmpItemKindFunction = { fg = c.wisteria }, - CmpItemKindConstructor = { fg = c.yellow }, - CmpItemKindField = { fg = c.wisteria }, - CmpItemKindClass = { fg = c.yellow }, - CmpItemKindInterface = { fg = c.yellow }, - CmpItemKindModule = { fg = c.wisteria }, - CmpItemKindProperty = { fg = c.wisteria }, - CmpItemKindValue = { fg = c.brown }, - CmpItemKindEnum = { fg = c.yellow }, - CmpItemKindKeyword = { fg = c.wisteria1 }, - CmpItemKindSnippet = { fg = c.green }, - CmpItemKindFile = { fg = c.wisteria }, - CmpItemKindEnumMember = { fg = c.light_blue }, - CmpItemKindConstant = { fg = c.brown }, - CmpItemKindStruct = { fg = c.yellow }, - CmpItemKindTypeParameter = { fg = c.yellow }, - - -- Notify - NotifyERRORBorder = { fg = c.red1 }, - NotifyWARNBorder = { fg = c.red_1 }, - NotifyINFOBorder = { fg = c.yellow }, - NotifyDEBUGBorder = { fg = c.bg5 }, - NotifyTRACEBorder = { fg = c.wisteria }, - NotifyERRORIcon = { fg = c.red1 }, - NotifyWARNIcon = { fg = c.red_1 }, - NotifyINFOIcon = { fg = c.yellow }, - NotifyDEBUGIcon = { fg = c.bg5 }, - NotifyTRACEIcon = { fg = c.wisteria }, - NotifyERRORTitle = { fg = c.red1 }, - NotifyWARNTitle = { fg = c.red_1 }, - NotifyINFOTitle = { fg = c.yellow }, - NotifyDEBUGTitle = { fg = c.bg5 }, - NotifyTRACETitle = { fg = c.wisteria }, - - -- Trouble - TroubleCount = { fg = c.wisteria1 }, - TroubleNormal = { fg = c.fg }, - TroubleText = { fg = c.fg }, - - -- Diff - -- diffAdded = { fg = c.green, bg = c.bg1 }, - -- diffRemoved = { fg = c.red_1, bg = c.bg1 }, - -- diffChanged = { fg = c.yellow }, - -- diffOldFile = { fg = c.brown }, - -- diffNewFile = { fg = c.light_blue }, - -- diffFile = { fg = c.wisteria }, - -- diffLine = { fg = c.bg5 }, - -- diffIndexLine = { fg = c.wisteria1 }, - - -- Neogit - NeogitBranch = { fg = c.yellow }, - NeogitRemote = { fg = c.brown }, - NeogitHunkHeader = { fg = c.fg, bg = c.bg1 }, - NeogitHunkHeaderHighlight = { fg = c.yellow, bg = c.bg1 }, - NeogitDiffContextHighlight = { bg = c.none }, - NeogitDiffDeleteHighlight = { fg = c.red_1, bg = c.none }, - NeogitDiffDeleteRegion = { fg = c.red_1, bg = c.none }, - NeogitDiffAddHighlight = { fg = c.green, bg = c.none }, - NeogitDiffAddRegion = { fg = c.green, bg = c.none }, - NeogitDiffDelete = { fg = c.red }, - NeogitDiffAdd = { fg = c.green }, - NeogitCommitViewHeader = { fg = c.quartz }, - NeogitNotificationInfo = { fg = c.wisteria }, - NeogitNotificationWarning = { fg = c.brown }, - NeogitNotificationError = { fg = c.red_1 }, - - -- WhichKey - WhichKey = { fg = c.wisteria1, style = 'bold' }, - WhichKeyGroup = { fg = c.light_blue }, - WhichKeyDesc = { fg = c.wisteria, style = 'italic' }, - WhichKeySeperator = { fg = c.green }, - WhichKeyFloat = { bg = c.bg1 }, - - -- nvim-treesitter-context - TreesitterContext = { fg = c.none, bg = c.bg1 }, - - -- Indent Blankline - IndentBlanklineChar = { fg = c.niagara_2, style = 'nocombine' }, - IndentBlanklineSpaceChar = { fg = c.bg5, style = 'nocombine' }, - IndentBlanklineSpaceCharBlankline = { fg = c.bg5, style = 'nocombine' }, - IndentBlanklineContextChar = { fg = c.wisteria1, style = 'nocombine' }, - IndentBlanklineContextStart = { style = 'underline', sp = c.wisteria1 }, - - -- Nvim dap - DapBreakpoint = { fg = c.red }, - DapStopped = { fg = c.green }, - - -- Hop - HopNextKey = { fg = c.red1, style = 'bold' }, - HopNextKey1 = { fg = c.light_blue, style = 'bold' }, - HopNextKey2 = { fg = c.wisteria1 }, - HopUnmatched = { fg = c.bg5 }, - } - - return plugins - end - - function theme.load_terminal() - -- dark - vim.g.terminal_color_0 = c.bg1 - vim.g.terminal_color_8 = c.niagara_2 - - -- light - vim.g.terminal_color_7 = c.fg - vim.g.terminal_color_15 = c.white - - -- colors - vim.g.terminal_color_1 = c.red - vim.g.terminal_color_9 = c.red1 - - vim.g.terminal_color_2 = c.green - vim.g.terminal_color_10 = c.green - - vim.g.terminal_color_3 = c.yellow - vim.g.terminal_color_11 = c.yellow - - vim.g.terminal_color_4 = c.wisteria - vim.g.terminal_color_12 = c.wisteria - - vim.g.terminal_color_5 = c.wisteria1 - vim.g.terminal_color_13 = c.wisteria1 - - vim.g.terminal_color_6 = c.light_blue - vim.g.terminal_color_14 = c.light_blue - end - - return vim.tbl_deep_extend('error', load_syntax(), load_editor(), load_treesitter(), load_lsp(), load_plugins()) -end - -return theme diff --git a/lua/neogruber/util.lua b/lua/neogruber/util.lua deleted file mode 100644 index 577eae1..0000000 --- a/lua/neogruber/util.lua +++ /dev/null @@ -1,53 +0,0 @@ -local theme = require 'neogruber.theme' - -local util = {} - --- Highlight the given group according to the color values -function util.highlight(group, colors) - local style = colors.style and 'gui=' .. colors.style or 'gui=NONE' - local fg = colors.fg and 'guifg=' .. colors.fg or 'guifg=NONE' - local bg = colors.bg and 'guibg=' .. colors.bg or 'guibg=NONE' - local sp = colors.sp and 'guisp=' .. colors.sp or '' - - local hl = 'highlight ' .. group .. ' ' .. style .. ' ' .. fg .. ' ' .. bg .. ' ' .. sp - - vim.cmd(hl) - if colors.link then - vim.cmd('highlight! link ' .. group .. ' ' .. colors.link) - end -end - --- Load the theme -function util.load(colors, exec_autocmd) - local config = require('neogruber.config').options - - -- Set the theme environment - if vim.g.colors_name then - vim.cmd 'hi clear' - end - - if vim.fn.exists 'syntax_on' then - vim.cmd 'syntax reset' - end - - vim.o.termguicolors = true - vim.g.colors_name = 'neogruber' - - -- Load highlights - colors = vim.tbl_deep_extend('force', colors, config.custom_colors) - local base_highlights = theme.highlights(colors, config) - - local highlights = vim.tbl_deep_extend('force', base_highlights, config.custom_highlights) - - for group, color in pairs(highlights) do - util.highlight(group, color) - end - - theme.load_terminal() - - if exec_autocmd then - vim.cmd 'doautocmd ColorScheme' - end -end - -return util