added terminal colors

This commit is contained in:
Folke Lemaitre 2021-04-20 11:58:45 +02:00
parent b7f2f10166
commit b7e7b8c163
4 changed files with 41 additions and 25 deletions

View File

@ -8,6 +8,7 @@ local colors = {
bg_dark = "#1f2335", bg_dark = "#1f2335",
bg = "#24283b", bg = "#24283b",
bg_highlight = "#292e42", bg_highlight = "#292e42",
terminal_black = "#414868",
fg = "#c0caf5", fg = "#c0caf5",
fg_dark = "#a9b1d6", fg_dark = "#a9b1d6",
fg_gutter = "#3b4261", fg_gutter = "#3b4261",
@ -24,8 +25,8 @@ local colors = {
purple = "#9d7cd8", purple = "#9d7cd8",
orange = "#ff9e64", orange = "#ff9e64",
yellow = "#e0af68", yellow = "#e0af68",
green3 = "#9ece6a", green = "#9ece6a",
green = "#73daca", green1 = "#73daca",
teal = "#1abc9c", teal = "#1abc9c",
red = "#f7768e", red = "#f7768e",
red1 = "#db4b4b", red1 = "#db4b4b",
@ -35,7 +36,7 @@ local colors = {
if config.style == "night" then colors.bg = "#1a1b26" end if config.style == "night" then colors.bg = "#1a1b26" end
util.bg = colors.bg util.bg = colors.bg
colors.git.ignore = colors.dark3 colors.git.ignore = colors.dark3
colors.black = util.darken(colors.bg, 0.7, "#000000") colors.black = util.darken(colors.bg, 0.8, "#000000")
colors.border_highlight = colors.blue0 colors.border_highlight = colors.blue0
colors.border = colors.black colors.border = colors.black

View File

@ -15,6 +15,7 @@ config = {
keywordStyle = opt("italic_keywords", true) and "italic" or "NONE", keywordStyle = opt("italic_keywords", true) and "italic" or "NONE",
functionStyle = opt("italic_functions", false) and "italic" or "NONE", functionStyle = opt("italic_functions", false) and "italic" or "NONE",
hideInactiveStatusline = opt("hide_inactive_statusline", false), hideInactiveStatusline = opt("hide_inactive_statusline", false),
terminalColors = opt("terminal_colors", true),
} }
return config return config

View File

@ -4,6 +4,7 @@ local c = require("tokyonight.colors")
---@class Theme ---@class Theme
local theme = {} local theme = {}
theme.config = config
theme.colors = c theme.colors = c
theme.base = { theme.base = {
@ -75,8 +76,8 @@ theme.base = {
-- Uncomment and edit if you want more specific syntax highlighting. -- Uncomment and edit if you want more specific syntax highlighting.
Constant = { fg = c.orange }, -- (preferred) any constant Constant = { fg = c.orange }, -- (preferred) any constant
String = { fg = c.green3 }, -- a string constant: "this is a string" String = { fg = c.green }, -- a string constant: "this is a string"
Character = { fg = c.green3 }, -- a character constant: 'c', '\n' Character = { fg = c.green }, -- a character constant: 'c', '\n'
-- Number = { }, -- a number constant: 234, 0xff -- Number = { }, -- a number constant: 234, 0xff
-- Boolean = { }, -- a boolean constant: TRUE, false -- Boolean = { }, -- a boolean constant: TRUE, false
-- Float = { }, -- a floating point constant: 2.3e10 -- Float = { }, -- a floating point constant: 2.3e10
@ -183,7 +184,7 @@ theme.plugins = {
-- TSConstMacro = { }; -- For constants that are defined by macros: `NULL` in C. -- TSConstMacro = { }; -- For constants that are defined by macros: `NULL` in C.
-- TSError = { }; -- For syntax/parser errors. -- TSError = { }; -- For syntax/parser errors.
-- TSException = { }; -- For exception related keywords. -- TSException = { }; -- For exception related keywords.
TSField = { fg = c.green }, -- For fields. TSField = { fg = c.green1 }, -- For fields.
-- TSFloat = { }; -- For floats. -- TSFloat = { }; -- For floats.
-- TSFunction = { }; -- For function (calls and definitions). -- TSFunction = { }; -- For function (calls and definitions).
-- TSFuncBuiltin = { }; -- For builtin functions: `table.insert` in Lua. -- TSFuncBuiltin = { }; -- For builtin functions: `table.insert` in Lua.
@ -199,7 +200,7 @@ theme.plugins = {
TSOperator = { fg = c.blue5 }, -- For any operator: `+`, but also `->` and `*` in C. TSOperator = { fg = c.blue5 }, -- For any operator: `+`, but also `->` and `*` in C.
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.green1 }, -- Same as `TSField`.
TSPunctDelimiter = { fg = c.blue5 }, -- For delimiters ie: `.` TSPunctDelimiter = { fg = c.blue5 }, -- For delimiters ie: `.`
TSPunctBracket = { fg = c.fg_dark }, -- For brackets and parens. TSPunctBracket = { fg = c.fg_dark }, -- For brackets and parens.
TSPunctSpecial = { fg = c.blue5 }, -- 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.
@ -270,7 +271,7 @@ theme.plugins = {
-- NeoVim -- NeoVim
healthError = { fg = c.error }, healthError = { fg = c.error },
healthSuccess = { fg = c.green }, healthSuccess = { fg = c.green1 },
healthWarning = { fg = c.warning }, healthWarning = { fg = c.warning },
-- BufferLine -- BufferLine

View File

@ -16,7 +16,10 @@ local function hexToRgb(hex_str)
return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) } return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) }
end end
local function blend(fg, bg, alpha) ---@param fg string foreground color
---@param bg string background color
---@param alpha number number between 0 and 1. 0 results in bg, 1 results in fg
function util.blend(fg, bg, alpha)
bg = hexToRgb(bg) bg = hexToRgb(bg)
fg = hexToRgb(fg) fg = hexToRgb(fg)
@ -60,22 +63,32 @@ function util.syntax(syntax) for group, colors in pairs(syntax) do util.highligh
---@param colors ColorScheme ---@param colors ColorScheme
function util.terminal(colors) function util.terminal(colors)
vim.g.terminal_color_0 = colors.bg -- dark
vim.g.terminal_color_1 = colors.red vim.g.terminal_color_0 = colors.terminal_black
vim.g.terminal_color_2 = colors.green vim.g.terminal_color_8 = colors.terminal_black
vim.g.terminal_color_3 = colors.orange
vim.g.terminal_color_4 = colors.blue -- light
vim.g.terminal_color_5 = colors.magenta vim.g.terminal_color_7 = colors.fg_dark
vim.g.terminal_color_6 = colors.cyan
vim.g.terminal_color_7 = colors.dark5
vim.g.terminal_color_8 = colors.fg_gutter
vim.g.terminal_color_9 = colors.red
vim.g.terminal_color_10 = colors.green
vim.g.terminal_color_11 = colors.orange
vim.g.terminal_color_12 = colors.blue
vim.g.terminal_color_13 = colors.magenta
vim.g.terminal_color_14 = colors.cyan
vim.g.terminal_color_15 = colors.fg vim.g.terminal_color_15 = colors.fg
-- colors
vim.g.terminal_color_1 = colors.red
vim.g.terminal_color_9 = colors.red
vim.g.terminal_color_2 = colors.green
vim.g.terminal_color_10 = colors.green
vim.g.terminal_color_3 = colors.yellow
vim.g.terminal_color_11 = colors.yellow
vim.g.terminal_color_4 = colors.blue
vim.g.terminal_color_12 = colors.blue
vim.g.terminal_color_5 = colors.magenta
vim.g.terminal_color_13 = colors.magenta
vim.g.terminal_color_6 = colors.cyan
vim.g.terminal_color_14 = colors.cyan
end end
---@param theme Theme ---@param theme Theme
@ -92,7 +105,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))