feat: darker sidebars

This commit is contained in:
Folke Lemaitre
2021-04-20 12:19:20 +02:00
parent b7e7b8c163
commit a425e02942
5 changed files with 59 additions and 53 deletions

View File

@@ -70,49 +70,28 @@ require('lualine').setup {
The theme comes in two styles, `storm` and a darker variant `night`. The theme comes in two styles, `storm` and a darker variant `night`.
Lua: | Option | Default | Description |
| ----------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tokyonight_style | `"storm"` | The theme comes in two styles, `"storm"` and a darker variant `"night"`. |
| tokyonight_terminal_colors | `true` | Configure the colors used when opening a `:terminal` in Neovim |
| tokyonight_italic_comments | `true` | Make comments italic |
| tokyonight_italic_keywords | `true` | Make keywords italic |
| tokyonight_italic_functions | `false` | Make functions italic |
| tokyonight_transparent | `false` | Enable this to disable setting the background color |
| tokyonight_hide_inactive_statusline | `false` | Enabling this option, will hide inactive statuslines and replace them with a thin border instead. Should work with the standard **StatusLine** and **LuaLine**. |
| tokyonight_sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `["quickfix", "__vista__", "terminal"]` |
```lua ```lua
-- The theme comes in two styles, "storm" and a darker variant "night". -- Example config in Lua
vim.g.tokyonight_style = "storm" vim.g.tokyonight_style = "night"
vim.g.tokyonight_italic_functions = true
-- Comments are italicized by default vim.g.tokyonight_sidebars = { "quickfix", "__vista__", "terminal" }
vim.g.tokyonight_italic_comments = true
-- Keywords are italicized by default
vim.g.tokyonight_italic_keywords = true
-- Functions are not italicized by default
vim.g.tokyonight_italic_functions = false
-- Enable this to disable setting the background color
vim.g.tokyonight_transparent = false
-- Enabling this option, will hide inactive statuslines and
-- replace them with a thin border instead. Should work with
-- the standard `StatusLine` and `LuaLine`.
vim.g.tokyonight_hide_inactive_statusline = true
``` ```
Vim Script:
```vim ```vim
" The theme comes in two styles, 'storm' and a darker variant 'night'. " Example config in VimScript
let g:tokyonight_style = "storm" let g:tokyonight_style = "night"
let g:tokyonight_italic_functions = true
" Comments are italicized by default let g:tokyonight_sidebars = [ "quickfix", "__vista__", "terminal" ]
let g:tokyonight_italic_comments = 1
" Keywords are italicized by default
let g:tokyonight_italic_keywords = 1
" Functions are not italicized by default
let g:tokyonight_italic_functions = 0
" Enable this to disable setting the background color
let g:tokyonight_transparent = 0
" Enabling this option, will hide inactive statuslines and
" replace them with a thin border instead. Should work with
" the standard `StatusLine` and `LuaLine`.
let g:tokyonight_hide_inactive_statusline = 1
``` ```

View File

@@ -7,10 +7,3 @@ lua package.loaded['tokyonight.util'] = nil
lua package.loaded['tokyonight.config'] = nil lua package.loaded['tokyonight.config'] = nil
lua require('tokyonight').colorscheme() lua require('tokyonight').colorscheme()
augroup TokyoNight
autocmd!
autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight
augroup end
" autocmd BufWinEnter quickfix setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB

View File

@@ -11,8 +11,8 @@ tokyonight.normal = {
} }
tokyonight.insert = { tokyonight.insert = {
a = { bg = colors.green3, fg = colors.bg_dark }, a = { bg = colors.green, fg = colors.bg_dark },
b = { bg = colors.fg_gutter, fg = colors.green3 }, b = { bg = colors.fg_gutter, fg = colors.green },
c = c, c = c,
} }
@@ -23,8 +23,8 @@ tokyonight.command = {
} }
tokyonight.visual = { tokyonight.visual = {
a = { bg = colors.magenta, fg = colors.bg_dark }, a = { bg = colors.blue0, fg = colors.fg },
b = { bg = colors.fg_gutter, fg = colors.magenta }, b = { bg = colors.fg_gutter, fg = colors.fg },
c = c, c = c,
} }

View File

@@ -1,6 +1,9 @@
---@class Config ---@class Config
local config local config
-- shim vim for kitty and other generators
vim = vim or { g = {} }
local function opt(key, default) local function opt(key, default)
key = "tokyonight_" .. key key = "tokyonight_" .. key
if vim.g[key] == nil then return default end if vim.g[key] == nil then return default end
@@ -16,6 +19,8 @@ config = {
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), terminalColors = opt("terminal_colors", true),
sidebars = opt("sidebars", {}),
dev = opt("dev", false),
} }
return config return config

View File

@@ -31,8 +31,8 @@ function util.blend(fg, bg, alpha)
return string.format("#%02X%02X%02X", blendChannel(1), blendChannel(2), blendChannel(3)) return string.format("#%02X%02X%02X", blendChannel(1), blendChannel(2), blendChannel(3))
end end
function util.darken(hex, amount, bg) return blend(hex, bg or util.bg, math.abs(amount)) end function util.darken(hex, amount, bg) return util.blend(hex, bg or util.bg, math.abs(amount)) end
function util.lighten(hex, amount, fg) return blend(hex, fg or util.fg, math.abs(amount)) end function util.lighten(hex, amount, fg) return util.blend(hex, fg or util.fg, math.abs(amount)) end
function util.highlight(group, color) function util.highlight(group, color)
if color.fg then util.colorsUsed[color.fg] = true end if color.fg then util.colorsUsed[color.fg] = true end
@@ -59,6 +59,34 @@ function util.debug(colors)
end end
end end
---@param config Config
function util.autocmds(config)
vim.cmd [[augroup TokyoNight]]
vim.cmd [[ autocmd!]]
if config.dev then
vim.cmd [[ autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight]]
end
for _, sidebar in ipairs(config.sidebars) do
if sidebar == "terminal" then
vim.cmd [[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]]
else
vim.cmd([[ autocmd BufWinEnter ]] .. sidebar ..
[[ setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]])
end
end
vim.cmd [[augroup end]]
end
-- Simple string interpolation.
--
-- Example template: "${name} is ${value}"
--
---@param str string template string
---@param table table key value pairs to replace in the string
function util.template(str, table)
return (str:gsub("($%b{})", function(w) return table[w:sub(3, -2)] or w 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
---@param colors ColorScheme ---@param colors ColorScheme
@@ -107,6 +135,7 @@ function util.load(theme)
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)
util.autocmds(theme.config)
async:close() async:close()
end)) end))
async:send() async:send()