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`.
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
-- The theme comes in two styles, "storm" and a darker variant "night".
vim.g.tokyonight_style = "storm"
-- Comments are italicized by default
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
-- Example config in Lua
vim.g.tokyonight_style = "night"
vim.g.tokyonight_italic_functions = true
vim.g.tokyonight_sidebars = { "quickfix", "__vista__", "terminal" }
```
Vim Script:
```vim
" The theme comes in two styles, 'storm' and a darker variant 'night'.
let g:tokyonight_style = "storm"
" Comments are italicized by default
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
" Example config in VimScript
let g:tokyonight_style = "night"
let g:tokyonight_italic_functions = true
let g:tokyonight_sidebars = [ "quickfix", "__vista__", "terminal" ]
```

View File

@@ -7,10 +7,3 @@ lua package.loaded['tokyonight.util'] = nil
lua package.loaded['tokyonight.config'] = nil
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 = {
a = { bg = colors.green3, fg = colors.bg_dark },
b = { bg = colors.fg_gutter, fg = colors.green3 },
a = { bg = colors.green, fg = colors.bg_dark },
b = { bg = colors.fg_gutter, fg = colors.green },
c = c,
}
@@ -23,8 +23,8 @@ tokyonight.command = {
}
tokyonight.visual = {
a = { bg = colors.magenta, fg = colors.bg_dark },
b = { bg = colors.fg_gutter, fg = colors.magenta },
a = { bg = colors.blue0, fg = colors.fg },
b = { bg = colors.fg_gutter, fg = colors.fg },
c = c,
}

View File

@@ -1,6 +1,9 @@
---@class Config
local config
-- shim vim for kitty and other generators
vim = vim or { g = {} }
local function opt(key, default)
key = "tokyonight_" .. key
if vim.g[key] == nil then return default end
@@ -16,6 +19,8 @@ config = {
functionStyle = opt("italic_functions", false) and "italic" or "NONE",
hideInactiveStatusline = opt("hide_inactive_statusline", false),
terminalColors = opt("terminal_colors", true),
sidebars = opt("sidebars", {}),
dev = opt("dev", false),
}
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))
end
function util.darken(hex, amount, bg) return 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.darken(hex, amount, bg) return util.blend(hex, bg or util.bg, 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)
if color.fg then util.colorsUsed[color.fg] = true end
@@ -59,6 +59,34 @@ function util.debug(colors)
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
---@param colors ColorScheme
@@ -107,6 +135,7 @@ function util.load(theme)
async = vim.loop.new_async(vim.schedule_wrap(function()
util.terminal(theme.colors)
util.syntax(theme.plugins)
util.autocmds(theme.config)
async:close()
end))
async:send()