completed v1

This commit is contained in:
Folke Lemaitre
2021-04-19 14:39:35 +02:00
parent c5f69155d9
commit 5dbdf8193a
6 changed files with 233 additions and 180 deletions

1
.gitignore vendored
View File

@@ -0,0 +1 @@
.vscode

View File

@@ -1,28 +1,15 @@
" You probably always want to set this in your vim fileeee " clear cache so this reloads changes.
set background=dark " useful for development
let g:colors_name="tokyonight"
" include our theme file and pass it to lush to apply
" By setting our module to nil, we clear lua's cache,
" which means the require ahead will *always* occur.
"
" This isn't strictly required but it can be a useful trick if you are
" incrementally editing your config a lot and want to be sure your themes
" changes are being picked up without restarting neovim.
"
" The performance impact of this call can be measured in the hundreds of
" *nanoseconds* and such could be considered "production safe".
lua package.loaded['tokyonight'] = nil lua package.loaded['tokyonight'] = nil
lua package.loaded['tokyonight.theme'] = nil lua package.loaded['tokyonight.theme'] = nil
lua package.loaded['tokyonight.colors'] = nil lua package.loaded['tokyonight.colors'] = nil
lua package.loaded['tokyonight.config'] = nil
lua require('tokyonight').colorscheme() lua require('tokyonight').colorscheme()
if exists('g:autoloaded_tokyonight') augroup TokyoNight
finish autocmd!
endif
let g:autoloaded_tokyonight = 1
autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight
augroup end
" autocmd BufWinEnter quickfix setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB

View File

@@ -5,89 +5,52 @@ local config = require("tokyonight.config")
---@class ColorScheme ---@class ColorScheme
local colors = { local colors = {
none = "NONE", none = "NONE",
fg = "#a9b1d6", bg_dark = "#1f2335",
bg = "#24283b", bg = "#24283b",
-- bg = "#99283b", bg_highlight = "#292e42",
sidebar_fg = "#7982a9", fg = "#c0caf5",
sidebar_bg = "#1f2335", fg_dark = "#a9b1d6",
light0 = "#c0caf5", fg_gutter = "#3b4261",
light1 = "#394b70",
black = "#1f2335",
dark1 = "#292e42",
dark2 = "#3b4261",
dark3 = "#545c7e", dark3 = "#545c7e",
dark4 = "#565f89", comment = "#565f89",
dark5 = "#737aa2", dark5 = "#737aa2",
blue0 = "#3d59a1", blue0 = "#3d59a1",
blue = "#7aa2f7", blue = "#7aa2f7",
cyan = "#7dcfff", cyan = "#7dcfff",
blue1 = "#2ac3de", blue1 = "#2ac3de",
blue4 = "#b4f9f8",
blue5 = "#89ddff", blue5 = "#89ddff",
blue6 = "#0da0ba", blue6 = "#B4F9F8",
magenta = "#bb9af7", magenta = "#bb9af7",
violet = "#9d7cd8", purple = "#9d7cd8",
orange = "#ff9e64", orange = "#ff9e64",
yellow = "#e0af68", yellow = "#e0af68",
green3 = "#9ece6a", green3 = "#9ece6a",
green = "#73daca", green = "#73daca",
green2 = "#164846", teal = "#1abc9c",
teal = "#10B981",
red = "#f7768e", red = "#f7768e",
red1 = "#db4b4b", red1 = "#db4b4b",
red2 = "#914c54", diff = { add = "#164846", delete = "#823c41", change = "#394b70" },
red3 = "#bb616b",
red4 = "#823c41",
grey = "#cfc9c2",
} }
colors.black = util.darken(colors.bg_dark, 10)
colors.diff = { add = colors.green2, delete = colors.red4, change = colors.light1 }
if config.style == "night" then colors.bg = "#1a1b26" end if config.style == "night" then colors.bg = "#1a1b26" end
colors.border_highlight = colors.blue0
colors.border = colors.black
local zephyr = { colors.bg_popup = colors.bg_dark
base0 = "#1B2229", colors.bg_sidebar = colors.bg_dark
base1 = "#1c1f24", colors.bg_statusline = colors.bg_dark
base2 = "#202328", colors.bg_float = colors.bg
base3 = "#23272e", colors.bg_visual = util.darken(colors.blue0, 30)
base4 = "#3f444a", colors.bg_search = colors.blue0
base5 = "#5B6268", colors.fg_sidebar = colors.fg_dark
base6 = "#73797e",
base7 = "#9ca0a4",
base8 = "#b1b1b1",
bg = "#282a36", colors.error = colors.red1
bg1 = "#504945", colors.warning = colors.yellow
bg_popup = "#3E4556", colors.info = colors.teal
bg_highlight = "#2E323C", colors.hint = colors.info
bg_visual = "#b3deef",
fg = "#bbc2cf", util.bg = colors.bg
fg_alt = "#5B6268", -- util.fg = colors.fg
red = "#e95678",
redwine = "#d16d9e",
orange = "#D98E48",
yellow = "#f0c674",
light_green = "#abcf84",
green = "#afd700",
dark_green = "#98be65",
cyan = "#36d0e0",
blue = "#61afef",
violet = "#b294bb",
magenta = "#c678dd",
teal = "#1abc9c",
grey = "#928374",
brown = "#c78665",
black = "#000000",
bracket = "#80A0C2",
currsor_bg = "#4f5b66",
none = "NONE",
}
return colors return colors

View File

@@ -1,7 +1,20 @@
---@class Config ---@class Config
local config local config
config = { style = "storm" }
if vim.g.tokyonight_style == "night" then config.style = "night" end local function opt(key, default)
key = "tokyonight_" .. key
if vim.g[key] == nil then return default end
if vim.g[key] == 0 then return false end
return vim.g[key]
end
config = {
style = opt("style", "storm"),
transparent = opt("transparent", false),
commentStyle = opt("italic_comments", true) and "italic" or "NONE",
keywordStyle = opt("italic_keywords", true) and "italic" or "NONE",
functionStyle = opt("italic_functions", false) and "italic" or "NONE",
hideInactiveStatusline = opt("hide_inactive_statusline", false),
}
return config return config

View File

@@ -1,4 +1,5 @@
local util = require("tokyonight.util") local util = require("tokyonight.util")
local config = require("tokyonight.config")
local c = require("tokyonight.colors") local c = require("tokyonight.colors")
---@class Theme ---@class Theme
@@ -6,63 +7,66 @@ local theme = {}
theme.colors = c theme.colors = c
theme.base = { theme.base = {
Comment = { fg = c.dark4, style = "italic" }, -- any comment Comment = { fg = c.comment, style = config.commentStyle }, -- any comment
-- ColorColumn = { }, -- used for the columns set with 'colorcolumn' ColorColumn = { bg = c.bg_visual }, -- used for the columns set with 'colorcolumn'
-- Conceal = { }, -- placeholder characters substituted for concealed text (see 'conceallevel') Conceal = { fg = c.fg_gutter }, -- placeholder characters substituted for concealed text (see 'conceallevel')
-- Cursor = { }, -- character under the cursor Cursor = { style = "reverse" }, -- character under the cursor
-- lCursor = { }, -- the character under the cursor when |language-mapping| is used (see 'guicursor') lCursor = { style = "reverse" }, -- the character under the cursor when |language-mapping| is used (see 'guicursor')
-- CursorIM = { }, -- like Cursor, but used when in IME mode |CursorIM| CursorIM = { style = "reverse" }, -- like Cursor, but used when in IME mode |CursorIM|
-- CursorColumn= { }, -- Screen-column at the cursor, when 'cursorcolumn' is set. CursorColumn = { bg = c.bg_highlight }, -- Screen-column at the cursor, when 'cursorcolumn' is set.
CursorLine = { bg = c.dark1 }, -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set. CursorLine = { bg = c.bg_highlight }, -- Screen-line at the cursor, when 'cursorline' is set. Low-priority if foreground (ctermfg OR guifg) is not set.
-- Directory = { }, -- directory names (and other special names in listings) Directory = { fg = c.fg_dark }, -- directory names (and other special names in listings)
DiffAdd = { bg = c.diff.add }, -- diff mode: Added line |diff.txt| DiffAdd = { bg = c.diff.add }, -- diff mode: Added line |diff.txt|
DiffChange = { bg = c.diff.change }, -- diff mode: Changed line |diff.txt| DiffChange = { bg = c.diff.change }, -- diff mode: Changed line |diff.txt|
DiffDelete = { bg = c.diff.delete }, -- diff mode: Deleted line |diff.txt| DiffDelete = { bg = c.diff.delete }, -- diff mode: Deleted line |diff.txt|
DiffText = { bg = c.red4 }, -- diff mode: Changed text within a changed line |diff.txt| DiffText = { bg = c.diff.change }, -- diff mode: Changed text within a changed line |diff.txt|
EndOfBuffer = { fg = c.dark2 }, -- filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|. EndOfBuffer = { fg = c.bg }, -- filler lines (~) after the end of the buffer. By default, this is highlighted like |hl-NonText|.
-- TermCursor = { }, -- cursor in a focused terminal -- TermCursor = { }, -- cursor in a focused terminal
-- TermCursorNC= { }, -- cursor in an unfocused terminal -- TermCursorNC= { }, -- cursor in an unfocused terminal
ErrorMsg = { fg = c.red1 }, -- error messages on the command line ErrorMsg = { fg = c.error }, -- error messages on the command line
VertSplit = { fg = c.black }, -- the column separating vertically split windows VertSplit = { fg = c.border }, -- the column separating vertically split windows
-- Folded = { }, -- line used for closed folds Folded = { fg = c.blue, bg = c.fg_gutter }, -- line used for closed folds
-- FoldColumn = { }, -- 'foldcolumn' FoldColumn = { bg = c.bg, fg = c.comment }, -- 'foldcolumn'
SignColumn = { bg = c.bg }, -- column where |signs| are displayed SignColumn = { bg = c.bg, fg = c.fg_gutter }, -- column where |signs| are displayed
IncSearch = { bg = util.darken(c.blue0, 34) }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c" SignColumnSB = { bg = c.bg_sidebar, fg = c.fg_gutter }, -- column where |signs| are displayed
-- Substitute = { }, -- |:substitute| replacement text highlighting Substitute = { bg = c.red }, -- |:substitute| replacement text highlighting
LineNr = { fg = c.dark2 }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. LineNr = { fg = c.fg_gutter }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set.
CursorLineNr = { fg = c.dark5 }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. CursorLineNr = { fg = c.dark5 }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line.
-- MatchParen = { }, -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt| MatchParen = { fg = c.orange, style = "bold" }, -- The character under the cursor or just before it, if it is a paired bracket, and its match. |pi_paren.txt|
-- ModeMsg = { }, -- 'showmode' message (e.g., "-- INSERT -- ") ModeMsg = { fg = c.fg_dark, style = "bold" }, -- 'showmode' message (e.g., "-- INSERT -- ")
-- MsgArea = { }, -- Area for messages and cmdline MsgArea = { fg = c.fg_dark }, -- Area for messages and cmdline
-- MsgSeparator= { }, -- Separator for scrolled messages, `msgsep` flag of 'display' -- MsgSeparator= { }, -- Separator for scrolled messages, `msgsep` flag of 'display'
-- MoreMsg = { }, -- |more-prompt| MoreMsg = { fg = c.blue }, -- |more-prompt|
NonText = { fg = c.dark3 }, -- '@' 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.dark3 }, -- '@' 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.light0, bg = c.bg }, -- normal text Normal = { fg = c.fg, bg = config.transparent and c.none or c.bg }, -- normal text
NormalFloat = { fg = c.fg_float }, -- Normal text in floating windows. NormalNC = { fg = c.fg, bg = config.transparent and c.none or c.bg }, -- normal text in non-current windows
-- NormalNC = { }, -- normal text in non-current windows NormalSB = { fg = c.fg_sidebar, bg = c.bg_sidebar }, -- normal text in non-current windows
Pmenu = { bg = c.dark1, fg = c.fg }, -- Popup menu: normal item. NormalFloat = { fg = c.fg, bg = c.bg_float }, -- Normal text in floating windows.
PmenuSel = { bg = util.darken(c.dark2, 20) }, -- Popup menu: selected item. FloatBorder = { fg = c.border_highlight },
PmenuSbar = { bg = util.lighten(c.dark1, 5) }, -- Popup menu: scrollbar. Pmenu = { bg = c.bg_popup, c.fg }, -- Popup menu: normal item.
PmenuThumb = { bg = c.dark2 }, -- Popup menu: Thumb of the scrollbar. PmenuSel = { bg = util.darken(c.fg_gutter, 20) }, -- Popup menu: selected item.
-- Question = { }, -- |hit-enter| prompt and yes/no questions PmenuSbar = { bg = util.lighten(c.bg_popup, 5) }, -- Popup menu: scrollbar.
-- QuickFixLine= { }, -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there. PmenuThumb = { bg = c.fg_gutter }, -- Popup menu: Thumb of the scrollbar.
Search = { bg = util.darken(c.blue0, 34) }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out. Question = { fg = c.blue }, -- |hit-enter| prompt and yes/no questions
-- SpecialKey = { }, -- Unprintable characters: text displayed differently from what it really is. But not 'listchars' whitespace. |hl-Whitespace| QuickFixLine = { bg = c.bg_visual, style = "bold" }, -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there.
SpellBad = { sp = c.red1 }, -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise. Search = { bg = c.bg_search }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
-- SpellCap = { }, -- Word that should start with a capital. |spell| Combined with the highlighting used otherwise. IncSearch = { bg = c.bg_search }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
-- SpellLocal = { }, -- Word that is recognized by the spellchecker as one that is used in another region. |spell| Combined with the highlighting used otherwise. SpecialKey = { fg = c.dark3 }, -- Unprintable characters: text displayed differently from what it really is. But not 'listchars' whitespace. |hl-Whitespace|
-- SpellRare = { }, -- Word that is recognized by the spellchecker as one that is hardly ever used. |spell| Combined with the highlighting used otherwise. SpellBad = { fg = c.error, style = "undercurl" }, -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise.
StatusLine = { fg = c.black }, -- status line of current window SpellCap = { fg = c.warning, style = "undercurl" }, -- Word that should start with a capital. |spell| Combined with the highlighting used otherwise.
StatusLineNC = { fg = c.black }, -- status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window. SpellLocal = { fg = c.info, style = "undercurl" }, -- Word that is recognized by the spellchecker as one that is used in another region. |spell| Combined with the highlighting used otherwise.
-- TabLine = { }, -- tab pages line, not active tab page label SpellRare = { fg = c.hint, style = "undercurl" }, -- Word that is recognized by the spellchecker as one that is hardly ever used. |spell| Combined with the highlighting used otherwise.
-- TabLineFill = { }, -- tab pages line, where there are no labels StatusLine = { fg = c.fg_sidebar, bg = c.bg_statusline }, -- status line of current window
-- TabLineSel = { }, -- tab pages line, active tab page label StatusLineNC = { fg = c.fg_sidebar, bg = c.bg_statusline }, -- status lines of not-current windows Note: if this is equal to "StatusLine" Vim will use "^^^" in the status line of the current window.
Title = { bg = c.dark1, fg = c.dark4 }, -- titles for output from ":set all", ":autocmd" etc. TabLine = { bg = c.bg_statusline, fg = c.fg_gutter }, -- tab pages line, not active tab page label
Visual = { bg = util.darken(c.blue0, 34) }, -- Visual mode selection TabLineFill = { bg = c.bg_statusline }, -- tab pages line, where there are no labels
VisualNOS = { bg = util.darken(c.blue0, 34) }, -- Visual mode selection when vim is "Not Owning the Selection". TabLineSel = { fg = c.blue, bg = c.bg }, -- tab pages line, active tab page label
WarningMsg = { fg = c.orange }, -- warning messages Title = { fg = c.blue, style = "bold" }, -- titles for output from ":set all", ":autocmd" etc.
Whitespace = { fg = c.dark2 }, -- "nbsp", "space", "tab" and "trail" in 'listchars' Visual = { bg = c.bg_visual }, -- Visual mode selection
-- WildMenu = { }, -- current match in 'wildmenu' completion VisualNOS = { bg = c.bg_visual }, -- Visual mode selection when vim is "Not Owning the Selection".
WarningMsg = { fg = c.warning }, -- warning messages
Whitespace = { fg = c.fg_gutter }, -- "nbsp", "space", "tab" and "trail" in 'listchars'
WildMenu = { bg = c.bg_visual }, -- current match in 'wildmenu' completion
-- These groups are not listed as default vim groups, -- These groups are not listed as default vim groups,
-- but they are defacto standard group names for syntax highlighting. -- but they are defacto standard group names for syntax highlighting.
@@ -78,14 +82,14 @@ theme.base = {
-- Float = { }, -- a floating point constant: 2.3e10 -- Float = { }, -- a floating point constant: 2.3e10
Identifier = { fg = c.magenta }, -- (preferred) any variable name Identifier = { fg = c.magenta }, -- (preferred) any variable name
Function = { fg = c.blue }, -- function name (also: methods for classes) Function = { fg = c.blue, style = config.functionStyle }, -- function name (also: methods for classes)
Statement = { fg = c.magenta }, -- (preferred) any statement Statement = { fg = c.magenta }, -- (preferred) any statement
-- Conditional = { }, -- if, then, else, endif, switch, etc. -- Conditional = { }, -- if, then, else, endif, switch, etc.
-- Repeat = { }, -- for, do, while, etc. -- Repeat = { }, -- for, do, while, etc.
-- Label = { }, -- case, default, etc. -- Label = { }, -- case, default, etc.
Operator = { fg = c.blue5 }, -- "sizeof", "+", "*", etc. Operator = { fg = c.blue5 }, -- "sizeof", "+", "*", etc.
Keyword = { fg = c.cyan }, -- any other keyword Keyword = { fg = c.cyan, style = config.keywordStyle }, -- any other keyword
-- Exception = { }, -- try, catch, throw -- Exception = { }, -- try, catch, throw
PreProc = { fg = c.cyan }, -- (preferred) generic Preprocessor PreProc = { fg = c.cyan }, -- (preferred) generic Preprocessor
@@ -113,9 +117,18 @@ theme.base = {
-- ("Ignore", below, may be invisible...) -- ("Ignore", below, may be invisible...)
-- Ignore = { }, -- (preferred) left blank, hidden |hl-Ignore| -- Ignore = { }, -- (preferred) left blank, hidden |hl-Ignore|
Error = { bg = c.red }, -- (preferred) any erroneous construct Error = { fg = c.error }, -- (preferred) any erroneous construct
Todo = { bg = c.yellow, fg = c.bg }, -- (preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX
Todo = { bg = c.teal }, -- (preferred) anything that needs extra attention; mostly the keywords TODO FIXME and XXX qfLineNr = { fg = c.dark5 },
qfFileName = { fg = c.blue },
htmlH1 = { fg = c.magenta, style = "bold" },
markdownH1 = { fg = c.magenta, style = "bold" },
markdownH1Delimiter = { fg = c.magenta },
htmlH2 = { fg = c.blue, style = "bold" },
markdownH2 = { fg = c.blue, style = "bold" },
markdownH2Delimiter = { fg = c.blue },
-- These groups are for the native LSP client. Some other LSP clients may -- These groups are for the native LSP client. Some other LSP clients may
-- use these groups, or use their own. Consult your LSP client's -- use these groups, or use their own. Consult your LSP client's
@@ -123,24 +136,24 @@ theme.base = {
} }
theme.plugins = { theme.plugins = {
LspReferenceText = { bg = c.dark2 }, -- used for highlighting "text" references LspReferenceText = { bg = c.fg_gutter }, -- used for highlighting "text" references
LspReferenceRead = { bg = c.dark2 }, -- used for highlighting "read" references LspReferenceRead = { bg = c.fg_gutter }, -- used for highlighting "read" references
LspReferenceWrite = { bg = c.dark2 }, -- used for highlighting "write" references LspReferenceWrite = { bg = c.fg_gutter }, -- used for highlighting "write" references
LspDiagnosticsDefaultError = { fg = c.red1 }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) LspDiagnosticsDefaultError = { fg = c.error }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline)
LspDiagnosticsDefaultWarning = { fg = c.yellow }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) LspDiagnosticsDefaultWarning = { fg = c.warning }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline)
LspDiagnosticsDefaultInformation = { fg = c.blue6 }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) LspDiagnosticsDefaultInformation = { fg = c.info }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline)
LspDiagnosticsDefaultHint = {}, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline) LspDiagnosticsDefaultHint = { fg = c.hint }, -- Used as the base highlight group. Other LspDiagnostic highlights link to this by default (except Underline)
-- LspDiagnosticsVirtualTextError = { }, -- Used for "Error" diagnostic virtual text LspDiagnosticsVirtualTextError = { bg = util.darken(c.error, 90), fg = c.error }, -- Used for "Error" diagnostic virtual text
-- LspDiagnosticsVirtualTextWarning = { }, -- Used for "Warning" diagnostic virtual text LspDiagnosticsVirtualTextWarning = { bg = util.darken(c.warning, 90), fg = c.warning }, -- Used for "Warning" diagnostic virtual text
-- LspDiagnosticsVirtualTextInformation= { }, -- Used for "Information" diagnostic virtual text LspDiagnosticsVirtualTextInformation = { bg = util.darken(c.info, 90), fg = c.info }, -- Used for "Information" diagnostic virtual text
-- LspDiagnosticsVirtualTextHint = { }, -- Used for "Hint" diagnostic virtual text LspDiagnosticsVirtualTextHint = { bg = util.darken(c.hint, 90), fg = c.hint }, -- Used for "Hint" diagnostic virtual text
LspDiagnosticsUnderlineError = { style = "undercurl", sp = c.red1 }, -- Used to underline "Error" diagnostics LspDiagnosticsUnderlineError = { style = "undercurl", sp = c.error }, -- Used to underline "Error" diagnostics
LspDiagnosticsUnderlineWarning = { style = "undercurl", sp = c.yellow }, -- Used to underline "Warning" diagnostics LspDiagnosticsUnderlineWarning = { style = "undercurl", sp = c.warning }, -- Used to underline "Warning" diagnostics
LspDiagnosticsUnderlineInformation = { style = "undercurl", sp = c.blue6 }, -- Used to underline "Information" diagnostics LspDiagnosticsUnderlineInformation = { style = "undercurl", sp = c.info }, -- Used to underline "Information" diagnostics
LspDiagnosticsUnderlineHint = { style = "undercurl" }, -- Used to underline "Hint" diagnostics LspDiagnosticsUnderlineHint = { style = "undercurl", sp = c.hint }, -- Used to underline "Hint" diagnostics
-- LspDiagnosticsFloatingError = { }, -- Used to color "Error" diagnostic messages in diagnostics float -- LspDiagnosticsFloatingError = { }, -- Used to color "Error" diagnostic messages in diagnostics float
-- LspDiagnosticsFloatingWarning = { }, -- Used to color "Warning" diagnostic messages in diagnostics float -- LspDiagnosticsFloatingWarning = { }, -- Used to color "Warning" diagnostic messages in diagnostics float
@@ -176,7 +189,7 @@ theme.plugins = {
-- TSFuncBuiltin = { }; -- For builtin functions: `table.insert` in Lua. -- TSFuncBuiltin = { }; -- For builtin functions: `table.insert` in Lua.
-- TSFuncMacro = { }; -- For macro defined fuctions (calls and definitions): each `macro_rules` in Rust. -- TSFuncMacro = { }; -- For macro defined fuctions (calls and definitions): each `macro_rules` in Rust.
-- TSInclude = { }; -- For includes: `#include` in C, `use` or `extern crate` in Rust, or `require` in Lua. -- TSInclude = { }; -- For includes: `#include` in C, `use` or `extern crate` in Rust, or `require` in Lua.
-- TSKeyword = { }; -- For keywords that don't fall in previous categories. TSKeyword = { fg = c.purple, style = config.keywordStyle }, -- For keywords that don't fall in previous categories.
-- TSKeywordFunction = { }; -- For keywords used to define a fuction. -- TSKeywordFunction = { }; -- For keywords used to define a fuction.
-- TSLabel = { }; -- For labels: `label:` in C and `:label:` in Lua. -- TSLabel = { }; -- For labels: `label:` in C and `:label:` in Lua.
-- TSMethod = { }; -- For method calls and definitions. -- TSMethod = { }; -- For method calls and definitions.
@@ -187,13 +200,13 @@ theme.plugins = {
TSParameter = { fg = c.yellow }, -- For parameters of a function. TSParameter = { fg = c.yellow }, -- For parameters of a function.
-- TSParameterReference= { }; -- For references to parameters of a function. -- TSParameterReference= { }; -- For references to parameters of a function.
TSProperty = { fg = c.green }, -- Same as `TSField`. TSProperty = { fg = c.green }, -- Same as `TSField`.
-- TSPunctDelimiter = { }; -- For delimiters ie: `.` TSPunctDelimiter = { fg = c.blue5 }, -- For delimiters ie: `.`
-- TSPunctBracket = { }; -- For brackets and parens. TSPunctBracket = { fg = c.fg_dark }, -- For brackets and parens.
-- TSPunctSpecial = { }; -- For special punctutation that does not fall in the catagories before. TSPunctSpecial = { fg = c.blue5 }, -- For special punctutation that does not fall in the catagories before.
-- TSRepeat = { }; -- For keywords related to loops. -- TSRepeat = { }; -- For keywords related to loops.
-- TSString = { }; -- For strings. -- TSString = { }; -- For strings.
-- TSStringRegex = { }; -- For regexes. TSStringRegex = { fg = c.blue6 }, -- For regexes.
-- TSStringEscape = { }; -- For escape characters within a string. TSStringEscape = { fg = c.magenta }, -- For escape characters within a string.
-- TSSymbol = { }; -- For identifiers referring to symbols or atoms. -- TSSymbol = { }; -- For identifiers referring to symbols or atoms.
-- TSType = { }; -- For types. -- TSType = { }; -- For types.
-- TSTypeBuiltin = { }; -- For builtin types. -- TSTypeBuiltin = { }; -- For builtin types.
@@ -203,6 +216,7 @@ theme.plugins = {
-- TSTag = { }; -- Tags like html tag names. -- TSTag = { }; -- Tags like html tag names.
-- TSTagDelimiter = { }; -- Tag delimiter like `<` `>` `/` -- TSTagDelimiter = { }; -- Tag delimiter like `<` `>` `/`
-- TSText = { }; -- For strings considered text in a markup language. -- TSText = { }; -- For strings considered text in a markup language.
TSTextReference = { fg = c.red }, -- FIXME
-- TSEmphasis = { }; -- For text to be represented with emphasis. -- TSEmphasis = { }; -- For text to be represented with emphasis.
-- TSUnderline = { }; -- For text to be represented with an underline. -- TSUnderline = { }; -- For text to be represented with an underline.
-- TSStrike = { }; -- For strikethrough text. -- TSStrike = { }; -- For strikethrough text.
@@ -210,25 +224,72 @@ theme.plugins = {
-- TSLiteral = { }; -- Literal text. -- TSLiteral = { }; -- Literal text.
-- TSURI = { }; -- Any URI like a link or email. -- TSURI = { }; -- Any URI like a link or email.
-- GitGutter, GitSigns -- GitGutter
GitGutterAdd = { fg = c.diff.add }, -- diff mode: Added line |diff.txt| GitGutterAdd = { fg = c.diff.add }, -- diff mode: Added line |diff.txt|
GitGutterChange = { fg = c.diff.change }, -- diff mode: Changed line |diff.txt| GitGutterChange = { fg = c.diff.change }, -- diff mode: Changed line |diff.txt|
GitGutterDelete = { fg = c.diff.delete }, -- diff mode: Deleted line |diff.txt| GitGutterDelete = { fg = c.diff.delete }, -- diff mode: Deleted line |diff.txt|
-- GitSigns
GitSignsAdd = { fg = c.diff.add }, -- diff mode: Added line |diff.txt| GitSignsAdd = { fg = c.diff.add }, -- diff mode: Added line |diff.txt|
GitSignsChange = { fg = c.diff.change }, -- diff mode: Changed line |diff.txt| GitSignsChange = { fg = c.diff.change }, -- diff mode: Changed line |diff.txt|
GitSignsDelete = { fg = c.diff.delete }, -- diff mode: Deleted line |diff.txt| GitSignsDelete = { fg = c.diff.delete }, -- diff mode: Deleted line |diff.txt|
-- Telescope -- Telescope
TelescopeBorder = { fg = c.blue0 }, TelescopeBorder = { fg = c.border_highlight },
-- NvimTree -- NvimTree
NvimTreeNormal = { fg = c.sidebar_fg, bg = c.sidebar_bg }, NvimTreeNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar },
NvimTreeRootFolder = { fg = c.magenta, style = "bold" },
NvimTreeGitDirty = { fg = c.blue },
-- NvimTreeFolderName= { fg = c.fg_float }, -- NvimTreeFolderName= { fg = c.fg_float },
NvimTreeFolderIcon = { fg = c.cyan },
NvimTreeRootFolder = { fg = c.magenta }, -- Dashboard
DashboardShortCut = { fg = c.cyan },
DashboardHeader = { fg = c.blue },
DashboardCenter = { fg = c.magenta },
DashboardFooter = { fg = c.yellow, style = "italic" },
-- WhichKey
WhichKey = { fg = c.cyan },
WhichKeyGroup = { fg = c.blue },
WhichKeyDesc = { fg = c.magenta },
WhichKeySeperator = { fg = c.comment },
WhichKeyFloating = { bg = c.bg_sidebar },
-- LspSaga
DiagnosticError = { fg = c.error },
DiagnosticWarning = { fg = c.warning },
DiagnosticInformation = { fg = c.info },
DiagnosticHint = { fg = c.hint },
-- NeoVim
healthError = { fg = c.error },
healthSuccess = { fg = c.green },
healthWarning = { fg = c.warning },
} }
-- LuaLine
for _, section in ipairs({ "b", "c" }) do
local bg = c.bg_sidebar
if section == "b" then bg = c.fg_gutter end
theme.plugins["lualine_" .. section .. "_diagnostics_error_normal"] = { fg = c.error, bg = bg }
theme.plugins["lualine_" .. section .. "_diagnostics_warn_normal"] = { fg = c.warning, bg = bg }
theme.plugins["lualine_" .. section .. "_diagnostics_info_normal"] = { fg = c.info, bg = bg }
end
if config.hideInactiveStatusline then
local inactive = { style = "underline", bg = c.bg, fg = c.bg, sp = c.border }
-- StatusLineNC
theme.base.StatusLineNC = inactive
-- LuaLine
for _, section in ipairs({ "a", "b", "c" }) do
theme.plugins["lualine_" .. section .. "_inactive"] = inactive
end
end
return theme return theme
-- vi:nowrap -- vi:nowrap

View File

@@ -1,8 +1,11 @@
local util = {} local util = {}
local function luma(hex_str, lum) util.colorsUsed = {}
-- Hex to RGB
-- normalise util.bg = "#000000"
util.fg = "#ffffff"
local function hexToRgb(hex_str)
local hex = "[abcdef0-9][abcdef0-9]" local hex = "[abcdef0-9][abcdef0-9]"
local pat = "^#(" .. hex .. ")(" .. hex .. ")(" .. hex .. ")$" local pat = "^#(" .. hex .. ")(" .. hex .. ")(" .. hex .. ")$"
hex_str = string.lower(hex_str) hex_str = string.lower(hex_str)
@@ -10,26 +13,51 @@ local function luma(hex_str, lum)
assert(string.find(hex_str, pat) ~= nil, "hex_to_rgb: invalid hex_str: " .. tostring(hex_str)) assert(string.find(hex_str, pat) ~= nil, "hex_to_rgb: invalid hex_str: " .. tostring(hex_str))
local r, g, b = string.match(hex_str, pat) local r, g, b = string.match(hex_str, pat)
lum = lum or 0; return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) }
local lumac = function(c)
c = tonumber(c, 16)
return math.floor(math.min(math.max(0, c + (c * lum / 100)), 255) + .5)
end end
return string.format("#%02X%02X%02X", lumac(r), lumac(g), lumac(b)) local function luma(color, alpha, bg)
bg = bg or util.bg
bg = hexToRgb(bg)
color = hexToRgb(color)
alpha = 1 - ((alpha or 0) / 100)
local blend = function(i)
return math.floor(math.min(math.max(0, (alpha * (color[i]) + ((1 - alpha) * (bg[i])))), 255) +
.5)
end end
function util.darken(hex, amount) return luma(hex, -math.abs(amount)) end return string.format("#%02X%02X%02X", blend(1), blend(2), blend(3))
end
function util.lighten(hex, amount) return luma(hex, math.abs(amount)) end function util.darken(hex, amount) return luma(hex, math.abs(amount), util.bg) end
function util.lighten(hex, amount) return luma(hex, math.abs(amount), util.fg) end
function util.highlight(group, color) function util.highlight(group, color)
if color.fg then util.colorsUsed[color.fg] = true end
if color.bg then util.colorsUsed[color.bg] = true end
if color.sp then util.colorsUsed[color.sp] = true end
local style = color.style and "gui=" .. color.style or "gui=NONE" local style = color.style and "gui=" .. color.style or "gui=NONE"
local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE" local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE"
local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE" local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE"
local sp = color.sp and "guisp=" .. color.sp or "" local sp = color.sp and "guisp=" .. color.sp or ""
vim.cmd("highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp) vim.cmd("highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp)
if color.link then vim.cmd("highlight! link " .. group .. " " .. color.link) end
end
function util.debug(colors)
colors = colors or require("tokyonight.colors")
-- Dump unused colors
for name, color in pairs(colors) do
if type(color) == "table" then
util.debug(color)
else
if util.colorsUsed[color] == nil then print("not used: " .. name .. " : " .. color) end
end
end
end end
function util.syntax(syntax) for group, colors in pairs(syntax) do util.highlight(group, colors) end end function util.syntax(syntax) for group, colors in pairs(syntax) do util.highlight(group, colors) end end
@@ -44,7 +72,7 @@ function util.terminal(colors)
vim.g.terminal_color_5 = colors.magenta vim.g.terminal_color_5 = colors.magenta
vim.g.terminal_color_6 = colors.cyan vim.g.terminal_color_6 = colors.cyan
vim.g.terminal_color_7 = colors.dark5 vim.g.terminal_color_7 = colors.dark5
vim.g.terminal_color_8 = colors.dark2 vim.g.terminal_color_8 = colors.fg_gutter
vim.g.terminal_color_9 = colors.red vim.g.terminal_color_9 = colors.red
vim.g.terminal_color_10 = colors.green vim.g.terminal_color_10 = colors.green
vim.g.terminal_color_11 = colors.orange vim.g.terminal_color_11 = colors.orange
@@ -68,7 +96,7 @@ function util.load(theme)
-- load syntax for plugins and terminal async -- load syntax for plugins and terminal async
local async local async
async = vim.loop.new_async(vim.schedule_wrap(function() async = vim.loop.new_async(vim.schedule_wrap(function()
util.terminal(theme.colors) -- util.terminal(theme.colors)
util.syntax(theme.plugins) util.syntax(theme.plugins)
async:close() async:close()
end)) end))