Fix background
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
|
||||
local cfg = {bg_transparent = true, italic_enabled = true, gamma = 1.0}
|
||||
|
||||
return cfg
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
local M = {}
|
||||
local hl = require('tokyo.theme')
|
||||
|
||||
function M.setup() require('tokyo.theme').set_hl() end
|
||||
local highlight = vim.api.nvim_set_hl
|
||||
local set_hl_ns = vim.api.nvim__set_hl_ns or vim.api.nvim_set_hl_ns
|
||||
local create_namespace = vim.api.nvim_create_namespace
|
||||
|
||||
local function colorscheme()
|
||||
vim.cmd("hi clear")
|
||||
if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end
|
||||
vim.o.background = "dark"
|
||||
vim.o.termguicolors = true
|
||||
local ns = create_namespace("tokyo")
|
||||
for _, group in pairs(hl) do
|
||||
for group_name, group_settings in pairs(group) do
|
||||
highlight(ns, group_name, group_settings)
|
||||
end
|
||||
end
|
||||
set_hl_ns(ns)
|
||||
end
|
||||
|
||||
-- vim.cmd [[augroup Tokyo]]
|
||||
-- vim.cmd [[ autocmd!]]
|
||||
-- vim.cmd [[ autocmd ColorScheme * lua require("tokyo.theme").set_hl()]]
|
||||
function M.setup() colorscheme() end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
local color_gamma = require('tokyo.utils').color_gamma
|
||||
local gamma = require('tokyo.config').gamma
|
||||
|
||||
local colors = {
|
||||
black = '#06080A',
|
||||
bg0 = '#11121D',
|
||||
@@ -21,5 +24,10 @@ local colors = {
|
||||
grey = '#3b4261',
|
||||
none = 'NONE'
|
||||
}
|
||||
local function gamma_correction(colors)
|
||||
local colors_corrected = {}
|
||||
for k, v in pairs(colors) do colors_corrected[k] = color_gamma(v, gamma) end
|
||||
return colors_corrected
|
||||
end
|
||||
|
||||
return colors
|
||||
return gamma_correction(colors)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
local M = {}
|
||||
local p = require 'tokyo.palette'
|
||||
local utils = require 'tokyo.utils'
|
||||
local function opt_italic(lhs, rhs) vim.tbl_extend('force', lhs, {italic = rhs}) end
|
||||
local cfg = require('tokyo.config')
|
||||
local hl = {}
|
||||
|
||||
local cfg = {bg_transparent = false, italic_enabled = true}
|
||||
|
||||
hl.predef = {
|
||||
Fg = {fg = p.fg},
|
||||
Gray = {fg = p.gray},
|
||||
@@ -15,18 +12,15 @@ hl.predef = {
|
||||
Green = {fg = p.green},
|
||||
Blue = {fg = p.blue},
|
||||
Purple = {fg = p.purple},
|
||||
BlueItalic = {fg = p.blue, italic = true},
|
||||
GreenItalic = {fg = p.green, italic = true},
|
||||
RedItalic = {fg = p.red, italic = true}
|
||||
}
|
||||
|
||||
hl.common = {
|
||||
Normal = {fg = p.fg, bg = not cfg.bg_transparent and p.bg0},
|
||||
Terminal = {fg = p.fg, bg = not cfg.bg_transparent and p.bg0},
|
||||
EndOfBuffer = {fg = p.bg2, bg = not cfg.bg_transparent and p.bg0},
|
||||
FoldColumn = {fg = p.fg, bg = not cfg.bg_transparent and p.bg1},
|
||||
Folded = {fg = p.fg, bg = not cfg.bg_transparent and p.bg1},
|
||||
SignColumn = {fg = p.fg, bg = not cfg.bg_transparent and p.bg0},
|
||||
Normal = {fg = p.fg, bg = cfg.bg_transparent and p.none or p.bg0},
|
||||
Terminal = {fg = p.fg, bg = cfg.bg_transparent and p.none or p.bg0},
|
||||
EndOfBuffer = {fg = p.bg2, bg = cfg.bg_transparent and p.none or p.bg0},
|
||||
FoldColumn = {fg = p.fg, bg = cfg.bg_transparent and p.none or p.bg1},
|
||||
Folded = {fg = p.fg, bg = cfg.bg_transparent and p.none or p.bg1},
|
||||
SignColumn = {fg = p.fg, bg = cfg.bg_transparent and p.none or p.bg0},
|
||||
ToolbarLine = {fg = p.fg},
|
||||
Cursor = {reverse = true},
|
||||
vCursor = {reverse = true},
|
||||
@@ -297,30 +291,5 @@ hl.cmake = {
|
||||
cmakeKWwrite_file = hl.predef.Green
|
||||
}
|
||||
|
||||
local highlight = vim.api.nvim_set_hl
|
||||
local set_hl_ns = vim.api.nvim__set_hl_ns
|
||||
local create_namespace = vim.api.nvim_create_namespace
|
||||
|
||||
function M.set_hl()
|
||||
vim.cmd("hi clear")
|
||||
if vim.fn.exists("syntax_on") then vim.cmd("syntax reset") end
|
||||
vim.o.background = "dark"
|
||||
vim.o.termguicolors = true
|
||||
vim.g.colors_name = "tokyo"
|
||||
local ns = create_namespace("tokyo")
|
||||
for _, group in pairs(hl) do
|
||||
for group_name, group_settings in pairs(group) do
|
||||
if group_settings.link ~= nil then
|
||||
print(group_settings.link)
|
||||
end
|
||||
highlight(ns, group_name, group_settings)
|
||||
-- print(group_name)
|
||||
end
|
||||
end
|
||||
set_hl_ns(ns)
|
||||
|
||||
end
|
||||
|
||||
return M
|
||||
-- utils.tprint(hl)
|
||||
return hl
|
||||
|
||||
|
||||
@@ -17,7 +17,24 @@ end
|
||||
|
||||
function U.hex2rgb(hex)
|
||||
hex = hex:gsub("#", "")
|
||||
return tonumber("0x"..hex:sub(1,2)), tonumber("0x"..hex:sub(3,4)), tonumber("0x"..hex:sub(5,6))
|
||||
return tonumber("0x" .. hex:sub(1, 2)), tonumber("0x" .. hex:sub(3, 4)),
|
||||
tonumber("0x" .. hex:sub(5, 6))
|
||||
end
|
||||
|
||||
function U.gamma_corrector(value, gamma)
|
||||
value = ((value / 255) ^ (1 / gamma)) * 255
|
||||
return math.min(math.max(math.floor(value), 0), 255)
|
||||
end
|
||||
|
||||
function U.color_gamma(hex, gamma)
|
||||
if hex:find('#') == nil then
|
||||
return hex
|
||||
end
|
||||
local r, g, b = U.hex2rgb(hex)
|
||||
r = U.gamma_corrector(r, gamma)
|
||||
g = U.gamma_corrector(g, gamma)
|
||||
b = U.gamma_corrector(b, gamma)
|
||||
return string.format("#%02x%02x%02x", r, g, b)
|
||||
end
|
||||
|
||||
return U
|
||||
|
||||
Reference in New Issue
Block a user