Merge pull request #191 from folke/refactor
feat: big refactor of the theme
This commit is contained in:
96
README.md
96
README.md
@@ -107,56 +107,68 @@ The theme comes in three styles, `storm`, a darker variant `night` and `day`.
|
|||||||
|
|
||||||
The **day** style will be used if:
|
The **day** style will be used if:
|
||||||
|
|
||||||
- `vim.g.tokyonight_style = "day"`
|
- `{ style = "day"}` was passed to `setup(options)`
|
||||||
- or `vim.o.background = "light"`
|
- or `vim.o.background = "light"`
|
||||||
|
|
||||||
| Option | Default | Description |
|
TokyoNight will use the default options, unless you call `setup`.
|
||||||
| ----------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| tokyonight_style | `"storm"` | The theme comes in three styles, `storm`, a darker variant `night` and `day`. |
|
```lua
|
||||||
| tokyonight_terminal_colors | `true` | Configure the colors used when opening a `:terminal` in Neovim |
|
require("tokyonight").setup({
|
||||||
| tokyonight_italic_comments | `true` | Make comments italic |
|
-- your configuration comes here
|
||||||
| tokyonight_italic_keywords | `true` | Make keywords italic |
|
-- or leave it empty to use the default settings
|
||||||
| tokyonight_italic_functions | `false` | Make functions italic |
|
style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
|
||||||
| tokyonight_italic_variables | `false` | Make variables and identifiers italic |
|
transparent = false, -- Enable this to disable setting the background color
|
||||||
| tokyonight_transparent | `false` | Enable this to disable setting the background color |
|
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim |
|
||||||
| 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**. |
|
styles = {
|
||||||
| tokyonight_sidebars | `{}` | Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` |
|
-- Style to be applied to different syntax groups
|
||||||
| tokyonight_transparent_sidebar | `false` | Sidebar like windows like `NvimTree` get a transparent background |
|
-- Value is any valid attr-list value `:help attr-list`
|
||||||
| tokyonight_dark_sidebar | `true` | Sidebar like windows like `NvimTree` get a darker background |
|
comments = "italic",
|
||||||
| tokyonight_dark_float | `true` | Float windows like the lsp diagnostics windows get a darker background. |
|
keywords = "italic",
|
||||||
| tokyonight_colors | `{}` | You can override specific color groups to use other groups or a hex color |
|
functions = "NONE",
|
||||||
| tokyonight_day_brightness | `0.3` | Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors |
|
variables = "NONE",
|
||||||
| tokyonight_lualine_bold | `false` | When `true`, section headers in the lualine theme will be bold |
|
-- Background styles. Can be "dark", "transparent" or "normal"
|
||||||
|
sidebars = "dark", -- style for sidebars, see below
|
||||||
|
floats = "dark", -- style for floating windows
|
||||||
|
},
|
||||||
|
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` |
|
||||||
|
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors |
|
||||||
|
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**. |
|
||||||
|
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold |
|
||||||
|
|
||||||
|
--- You can override specific color groups to use other groups or a hex color |
|
||||||
|
--- fucntion will be called with a ColorScheme table
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_colors = function(colors) end,
|
||||||
|
|
||||||
|
--- You can override specific highlights to use other groups or a hex color |
|
||||||
|
--- fucntion will be called with a Highlights and ColorScheme table
|
||||||
|
---@param highlights Highlights
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_highlights = function(highlights, colors) end,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Example config in Lua
|
-- Example config in Lua
|
||||||
vim.g.tokyonight_style = "night"
|
require("tokyonight").setup({
|
||||||
vim.g.tokyonight_italic_functions = true
|
-- use the night style
|
||||||
vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" }
|
style = "night",
|
||||||
|
-- disable italic for functions
|
||||||
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
|
styles = {
|
||||||
vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" }
|
functions = "NONE"
|
||||||
|
},
|
||||||
|
sidebars = { "qf", "vista_kind", "terminal", "packer" },
|
||||||
|
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
|
||||||
|
on_colors = function(colors) {
|
||||||
|
colors.hint = colors.orange
|
||||||
|
colors.error = "#ff0000"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Load the colorscheme
|
-- Load the colorscheme
|
||||||
vim.cmd[[colorscheme tokyonight]]
|
vim.cmd[[colorscheme tokyonight]]
|
||||||
```
|
```
|
||||||
|
|
||||||
```vim
|
|
||||||
" Example config in VimScript
|
|
||||||
let g:tokyonight_style = "night"
|
|
||||||
let g:tokyonight_italic_functions = 1
|
|
||||||
let g:tokyonight_sidebars = [ "qf", "vista_kind", "terminal", "packer" ]
|
|
||||||
|
|
||||||
" Change the "hint" color to the "orange" color, and make the "error" color bright red
|
|
||||||
let g:tokyonight_colors = {
|
|
||||||
\ 'hint': 'orange',
|
|
||||||
\ 'error': '#ff0000'
|
|
||||||
\ }
|
|
||||||
|
|
||||||
" Load the colorscheme
|
|
||||||
colorscheme tokyonight
|
|
||||||
```
|
|
||||||
|
|
||||||
### Making `undercurls` work properly in **Tmux**
|
### Making `undercurls` work properly in **Tmux**
|
||||||
|
|
||||||
To have undercurls show up and in color, add the following to your **Tmux** config file:
|
To have undercurls show up and in color, add the following to your **Tmux** config file:
|
||||||
@@ -177,7 +189,7 @@ Extra color configs for **Kitty**, **Alacritty**, **Fish**, **WezTerm**, **iTerm
|
|||||||
You can easily use the color palette for other plugins inside your Neovim config:
|
You can easily use the color palette for other plugins inside your Neovim config:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local colors = require("tokyonight.colors").setup({}) -- pass in any of the config options as explained above
|
local colors = require("tokyonight.colors").setup() -- pass in any of the config options as explained above
|
||||||
local util = require("tokyonight.util")
|
local util = require("tokyonight.util")
|
||||||
|
|
||||||
aplugin.background = colors.bg_dark
|
aplugin.background = colors.bg_dark
|
||||||
@@ -192,5 +204,5 @@ How to add a new extra template:
|
|||||||
|
|
||||||
1. create a file like `lua/tokyonight/extra/cool-app.lua`
|
1. create a file like `lua/tokyonight/extra/cool-app.lua`
|
||||||
2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua`
|
2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua`
|
||||||
3. in the root directory, run `$ lua lua/tokyonight/extra/init.lua` to generate / update extra themes
|
3. in Nvim, run `:lua require("tokyonight.extra").setup()` to generate / update extra themes
|
||||||
4. commit the newly created themes under `extra/`
|
4. commit the newly created themes under `extra/`
|
||||||
|
|||||||
1
colors/tokyonight-day.lua
Normal file
1
colors/tokyonight-day.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("tokyonight").load({ style = "day" })
|
||||||
1
colors/tokyonight-night.lua
Normal file
1
colors/tokyonight-night.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("tokyonight").load({ style = "night" })
|
||||||
1
colors/tokyonight-storm.lua
Normal file
1
colors/tokyonight-storm.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("tokyonight").load({ style = "storm" })
|
||||||
1
colors/tokyonight.lua
Normal file
1
colors/tokyonight.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require("tokyonight").load()
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
" clear cache so this reloads changes.
|
|
||||||
" useful for development
|
|
||||||
" lua package.loaded['tokyonight'] = nil
|
|
||||||
" lua package.loaded['tokyonight.theme'] = nil
|
|
||||||
" lua package.loaded['tokyonight.colors'] = nil
|
|
||||||
" lua package.loaded['tokyonight.util'] = nil
|
|
||||||
lua package.loaded['tokyonight.config'] = nil
|
|
||||||
|
|
||||||
lua require('tokyonight').colorscheme()
|
|
||||||
@@ -153,56 +153,68 @@ The theme comes in three styles, `storm`, a darker variant `night` and `day`.
|
|||||||
The **day** style will be used if:
|
The **day** style will be used if:
|
||||||
|
|
||||||
|
|
||||||
- `vim.g.tokyonight_style = "day"`
|
- `{ style = "day"}` was passed to `setup(options)`
|
||||||
- or `vim.o.background = "light"`
|
- or `vim.o.background = "light"`
|
||||||
|
|
||||||
|
|
||||||
│ Option │ Default │ Description │
|
TokyoNight will use the default options, unless you call `setup`.
|
||||||
│tokyonight_style │"storm" │The theme comes in three styles, storm, a darker variant night and day. │
|
|
||||||
│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_italic_variables │false │Make variables and identifiers 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: ["qf", "vista_kind", "terminal", "packer"] │
|
|
||||||
│tokyonight_transparent_sidebar │false │Sidebar like windows like NvimTree get a transparent background │
|
|
||||||
│tokyonight_dark_sidebar │true │Sidebar like windows like NvimTree get a darker background │
|
|
||||||
│tokyonight_dark_float │true │Float windows like the lsp diagnostics windows get a darker background. │
|
|
||||||
│tokyonight_colors │{} │You can override specific color groups to use other groups or a hex color │
|
|
||||||
│tokyonight_day_brightness │0.3 │Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors │
|
|
||||||
│tokyonight_lualine_bold │false │When true, section headers in the lualine theme will be bold │
|
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
-- Example config in Lua
|
require("tokyonight").setup({
|
||||||
vim.g.tokyonight_style = "night"
|
-- your configuration comes here
|
||||||
vim.g.tokyonight_italic_functions = true
|
-- or leave it empty to use the default settings
|
||||||
vim.g.tokyonight_sidebars = { "qf", "vista_kind", "terminal", "packer" }
|
style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
|
||||||
|
transparent = false, -- Enable this to disable setting the background color
|
||||||
|
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim |
|
||||||
|
styles = {
|
||||||
|
-- Style to be applied to different syntax groups
|
||||||
|
-- Value is any valid attr-list value `:help attr-list`
|
||||||
|
comments = "italic",
|
||||||
|
keywords = "italic",
|
||||||
|
functions = "NONE",
|
||||||
|
variables = "NONE",
|
||||||
|
-- Background styles. Can be "dark", "transparent" or "normal"
|
||||||
|
sidebars = "dark", -- style for sidebars, see below
|
||||||
|
floats = "dark", -- style for floating windows
|
||||||
|
},
|
||||||
|
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` |
|
||||||
|
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors |
|
||||||
|
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**. |
|
||||||
|
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold |
|
||||||
|
|
||||||
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
|
--- You can override specific color groups to use other groups or a hex color |
|
||||||
vim.g.tokyonight_colors = { hint = "orange", error = "#ff0000" }
|
--- fucntion will be called with a ColorScheme table
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_colors = function(colors) end,
|
||||||
|
|
||||||
-- Load the colorscheme
|
--- You can override specific highlights to use other groups or a hex color |
|
||||||
vim.cmd[[colorscheme tokyonight]]
|
--- fucntion will be called with a Highlights and ColorScheme table
|
||||||
|
---@param highlights Highlights
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_highlights = function(highlights, colors) end,
|
||||||
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
" Example config in VimScript
|
-- Example config in Lua
|
||||||
let g:tokyonight_style = "night"
|
require("tokyonight").setup({
|
||||||
let g:tokyonight_italic_functions = 1
|
-- use the night style
|
||||||
let g:tokyonight_sidebars = [ "qf", "vista_kind", "terminal", "packer" ]
|
style = "night",
|
||||||
|
-- disable italic for functions
|
||||||
|
styles = {
|
||||||
|
functions = "NONE"
|
||||||
|
},
|
||||||
|
sidebars = { "qf", "vista_kind", "terminal", "packer" },
|
||||||
|
-- Change the "hint" color to the "orange" color, and make the "error" color bright red
|
||||||
|
on_colors = function(colors) {
|
||||||
|
colors.hint = colors.orange
|
||||||
|
colors.error = "#ff0000"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
" Change the "hint" color to the "orange" color, and make the "error" color bright red
|
-- Load the colorscheme
|
||||||
let g:tokyonight_colors = {
|
vim.cmd[[colorscheme tokyonight]]
|
||||||
\ 'hint': 'orange',
|
|
||||||
\ 'error': '#ff0000'
|
|
||||||
\ }
|
|
||||||
|
|
||||||
" Load the colorscheme
|
|
||||||
colorscheme tokyonight
|
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
@@ -234,7 +246,7 @@ You can easily use the color palette for other plugins inside your Neovim
|
|||||||
config:
|
config:
|
||||||
|
|
||||||
>
|
>
|
||||||
local colors = require("tokyonight.colors").setup({}) -- pass in any of the config options as explained above
|
local colors = require("tokyonight.colors").setup() -- pass in any of the config options as explained above
|
||||||
local util = require("tokyonight.util")
|
local util = require("tokyonight.util")
|
||||||
|
|
||||||
aplugin.background = colors.bg_dark
|
aplugin.background = colors.bg_dark
|
||||||
@@ -252,7 +264,7 @@ How to add a new extra template:
|
|||||||
|
|
||||||
1. create a file like `lua/tokyonight/extra/cool-app.lua`
|
1. create a file like `lua/tokyonight/extra/cool-app.lua`
|
||||||
2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua`
|
2. add the name and output file extension to the `extras` table in `lua/tokyonight/extra/init.lua`
|
||||||
3. in the root directory, run `$ lua lua/tokyonight/extra/init.lua` to generate / update extra themes
|
3. in Nvim, run `:lua require("tokyonight.extra").setup()` to generate / update extra themes
|
||||||
4. commit the newly created themes under `extra/`
|
4. commit the newly created themes under `extra/`
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ cursor_text_color #e1e2e7
|
|||||||
|
|
||||||
# Tabs
|
# Tabs
|
||||||
active_tab_background #2e7de9
|
active_tab_background #2e7de9
|
||||||
active_tab_foreground #d4d6e4
|
active_tab_foreground #e9e9ec
|
||||||
inactive_tab_background #c4c8da
|
inactive_tab_background #c4c8da
|
||||||
inactive_tab_foreground #8990b3
|
inactive_tab_foreground #8990b3
|
||||||
#tab_bar_background #e9e9ed
|
#tab_bar_background #e9e9ed
|
||||||
@@ -44,4 +44,4 @@ color15 #3760bf
|
|||||||
# extended colors
|
# extended colors
|
||||||
color16 #b15c00
|
color16 #b15c00
|
||||||
color17 #c64343
|
color17 #c64343
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ cursor_text_color #1a1b26
|
|||||||
|
|
||||||
# Tabs
|
# Tabs
|
||||||
active_tab_background #7aa2f7
|
active_tab_background #7aa2f7
|
||||||
active_tab_foreground #1f2335
|
active_tab_foreground #16161e
|
||||||
inactive_tab_background #292e42
|
inactive_tab_background #292e42
|
||||||
inactive_tab_foreground #545c7e
|
inactive_tab_foreground #545c7e
|
||||||
#tab_bar_background #15161E
|
#tab_bar_background #15161E
|
||||||
@@ -44,4 +44,4 @@ color15 #c0caf5
|
|||||||
# extended colors
|
# extended colors
|
||||||
color16 #ff9e64
|
color16 #ff9e64
|
||||||
color17 #db4b4b
|
color17 #db4b4b
|
||||||
|
|
||||||
@@ -44,4 +44,4 @@ color15 #c0caf5
|
|||||||
# extended colors
|
# extended colors
|
||||||
color16 #ff9e64
|
color16 #ff9e64
|
||||||
color17 #db4b4b
|
color17 #db4b4b
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ set -g pane-active-border-style "fg=#2e7de9"
|
|||||||
set -g status "on"
|
set -g status "on"
|
||||||
set -g status-justify "left"
|
set -g status-justify "left"
|
||||||
|
|
||||||
set -g status-style "fg=#2e7de9,bg=#d4d6e4"
|
set -g status-style "fg=#2e7de9,bg=#e9e9ec"
|
||||||
|
|
||||||
set -g status-left-length "100"
|
set -g status-left-length "100"
|
||||||
set -g status-right-length "100"
|
set -g status-right-length "100"
|
||||||
@@ -21,12 +21,12 @@ set -g status-right-length "100"
|
|||||||
set -g status-left-style NONE
|
set -g status-left-style NONE
|
||||||
set -g status-right-style NONE
|
set -g status-right-style NONE
|
||||||
|
|
||||||
set -g status-left "#[fg=#e9e9ed,bg=#2e7de9,bold] #S #[fg=#2e7de9,bg=#d4d6e4,nobold,nounderscore,noitalics]"
|
set -g status-left "#[fg=#e9e9ed,bg=#2e7de9,bold] #S #[fg=#2e7de9,bg=#e9e9ec,nobold,nounderscore,noitalics]"
|
||||||
set -g status-right "#[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#d4d6e4] #{prefix_highlight} #[fg=#a8aecb,bg=#d4d6e4,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb] %Y-%m-%d %I:%M %p #[fg=#2e7de9,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#e9e9ed,bg=#2e7de9,bold] #h "
|
set -g status-right "#[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#e9e9ec] #{prefix_highlight} #[fg=#a8aecb,bg=#e9e9ec,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb] %Y-%m-%d %I:%M %p #[fg=#2e7de9,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#e9e9ed,bg=#2e7de9,bold] #h "
|
||||||
|
|
||||||
setw -g window-status-activity-style "underscore,fg=#6172b0,bg=#d4d6e4"
|
setw -g window-status-activity-style "underscore,fg=#6172b0,bg=#e9e9ec"
|
||||||
setw -g window-status-separator ""
|
setw -g window-status-separator ""
|
||||||
setw -g window-status-style "NONE,fg=#6172b0,bg=#d4d6e4"
|
setw -g window-status-style "NONE,fg=#6172b0,bg=#e9e9ec"
|
||||||
setw -g window-status-format "#[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]#[default] #I #W #F #[fg=#d4d6e4,bg=#d4d6e4,nobold,nounderscore,noitalics]"
|
setw -g window-status-format "#[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]#[default] #I #W #F #[fg=#e9e9ec,bg=#e9e9ec,nobold,nounderscore,noitalics]"
|
||||||
setw -g window-status-current-format "#[fg=#d4d6e4,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb,bold] #I #W #F #[fg=#a8aecb,bg=#d4d6e4,nobold,nounderscore,noitalics]"
|
setw -g window-status-current-format "#[fg=#e9e9ec,bg=#a8aecb,nobold,nounderscore,noitalics]#[fg=#2e7de9,bg=#a8aecb,bold] #I #W #F #[fg=#a8aecb,bg=#e9e9ec,nobold,nounderscore,noitalics]"
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ set -g pane-active-border-style "fg=#7aa2f7"
|
|||||||
set -g status "on"
|
set -g status "on"
|
||||||
set -g status-justify "left"
|
set -g status-justify "left"
|
||||||
|
|
||||||
set -g status-style "fg=#7aa2f7,bg=#1f2335"
|
set -g status-style "fg=#7aa2f7,bg=#16161e"
|
||||||
|
|
||||||
set -g status-left-length "100"
|
set -g status-left-length "100"
|
||||||
set -g status-right-length "100"
|
set -g status-right-length "100"
|
||||||
@@ -21,12 +21,12 @@ set -g status-right-length "100"
|
|||||||
set -g status-left-style NONE
|
set -g status-left-style NONE
|
||||||
set -g status-right-style NONE
|
set -g status-right-style NONE
|
||||||
|
|
||||||
set -g status-left "#[fg=#15161E,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#1f2335,nobold,nounderscore,noitalics]"
|
set -g status-left "#[fg=#15161E,bg=#7aa2f7,bold] #S #[fg=#7aa2f7,bg=#16161e,nobold,nounderscore,noitalics]"
|
||||||
set -g status-right "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#1f2335] #{prefix_highlight} #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#7aa2f7,bold] #h "
|
set -g status-right "#[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#16161e] #{prefix_highlight} #[fg=#3b4261,bg=#16161e,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261] %Y-%m-%d %I:%M %p #[fg=#7aa2f7,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#15161E,bg=#7aa2f7,bold] #h "
|
||||||
|
|
||||||
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#1f2335"
|
setw -g window-status-activity-style "underscore,fg=#a9b1d6,bg=#16161e"
|
||||||
setw -g window-status-separator ""
|
setw -g window-status-separator ""
|
||||||
setw -g window-status-style "NONE,fg=#a9b1d6,bg=#1f2335"
|
setw -g window-status-style "NONE,fg=#a9b1d6,bg=#16161e"
|
||||||
setw -g window-status-format "#[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]#[default] #I #W #F #[fg=#1f2335,bg=#1f2335,nobold,nounderscore,noitalics]"
|
setw -g window-status-format "#[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]#[default] #I #W #F #[fg=#16161e,bg=#16161e,nobold,nounderscore,noitalics]"
|
||||||
setw -g window-status-current-format "#[fg=#1f2335,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I #W #F #[fg=#3b4261,bg=#1f2335,nobold,nounderscore,noitalics]"
|
setw -g window-status-current-format "#[fg=#16161e,bg=#3b4261,nobold,nounderscore,noitalics]#[fg=#7aa2f7,bg=#3b4261,bold] #I #W #F #[fg=#3b4261,bg=#16161e,nobold,nounderscore,noitalics]"
|
||||||
|
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
local config = require("tokyonight.config")
|
local colors = require("tokyonight.colors").setup({ transform = true })
|
||||||
local colors = require("tokyonight.colors").setup(config)
|
|
||||||
local util = require("tokyonight.util")
|
|
||||||
|
|
||||||
local tokyonight = {}
|
local tokyonight = {}
|
||||||
|
|
||||||
@@ -37,15 +35,4 @@ tokyonight.tabline = {
|
|||||||
tabsel = { { colors.blue, colors.fg_gutter }, { colors.dark3, colors.bg } },
|
tabsel = { { colors.blue, colors.fg_gutter }, { colors.dark3, colors.bg } },
|
||||||
}
|
}
|
||||||
|
|
||||||
if vim.o.background == "light" then
|
|
||||||
for _, mode in pairs(tokyonight) do
|
|
||||||
for _, section in pairs(mode) do
|
|
||||||
for _, subsection in pairs(section) do
|
|
||||||
subsection[1] = util.getColor(subsection[1])
|
|
||||||
subsection[2] = util.getColor(subsection[2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return tokyonight
|
return tokyonight
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
local config = require("tokyonight.config")
|
local colors = require("tokyonight.colors").setup({ transform = true })
|
||||||
local colors = require("tokyonight.colors").setup(config)
|
local config = require("tokyonight.config").options
|
||||||
local util = require("tokyonight.util")
|
|
||||||
|
|
||||||
local tokyonight = {}
|
local tokyonight = {}
|
||||||
|
|
||||||
@@ -36,20 +35,7 @@ tokyonight.inactive = {
|
|||||||
c = { bg = colors.bg_statusline, fg = colors.fg_gutter },
|
c = { bg = colors.bg_statusline, fg = colors.fg_gutter },
|
||||||
}
|
}
|
||||||
|
|
||||||
if vim.o.background == "light" then
|
if config.lualine_bold then
|
||||||
for _, mode in pairs(tokyonight) do
|
|
||||||
for _, section in pairs(mode) do
|
|
||||||
if section.bg then
|
|
||||||
section.bg = util.getColor(section.bg)
|
|
||||||
end
|
|
||||||
if section.fg then
|
|
||||||
section.fg = util.getColor(section.fg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.g.tokyonight_lualine_bold then
|
|
||||||
for _, mode in pairs(tokyonight) do
|
for _, mode in pairs(tokyonight) do
|
||||||
mode.a.gui = "bold"
|
mode.a.gui = "bold"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ local util = require("tokyonight.util")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
---@param config Config
|
|
||||||
---@return ColorScheme
|
---@return ColorScheme
|
||||||
function M.setup(config)
|
function M.setup(opts)
|
||||||
config = config or require("tokyonight.config")
|
opts = opts or {}
|
||||||
|
local config = require("tokyonight.config").options
|
||||||
|
|
||||||
-- Color Palette
|
-- Color Palette
|
||||||
---@class ColorScheme
|
---@class ColorScheme
|
||||||
@@ -40,15 +40,14 @@ function M.setup(config)
|
|||||||
teal = "#1abc9c",
|
teal = "#1abc9c",
|
||||||
red = "#f7768e",
|
red = "#f7768e",
|
||||||
red1 = "#db4b4b",
|
red1 = "#db4b4b",
|
||||||
git = { change = "#6183bb", add = "#449dab", delete = "#914c54", conflict = "#bb7a61" },
|
git = { change = "#6183bb", add = "#449dab", delete = "#914c54" },
|
||||||
gitSigns = { add = "#164846", change = "#394b70", delete = "#823c41" },
|
|
||||||
}
|
}
|
||||||
if config.style == "night" or config.style == "day" or vim.o.background == "light" then
|
if config.style == "night" or config.style == "day" or vim.o.background == "light" then
|
||||||
colors.bg = "#1a1b26"
|
colors.bg = "#1a1b26"
|
||||||
colors.bg_dark = "#16161e"
|
colors.bg_dark = "#16161e"
|
||||||
end
|
end
|
||||||
util.bg = colors.bg
|
util.bg = colors.bg
|
||||||
util.day_brightness = config.dayBrightness
|
util.day_brightness = config.day_brightness
|
||||||
|
|
||||||
colors.diff = {
|
colors.diff = {
|
||||||
add = util.darken(colors.green2, 0.15),
|
add = util.darken(colors.green2, 0.15),
|
||||||
@@ -58,9 +57,9 @@ function M.setup(config)
|
|||||||
}
|
}
|
||||||
|
|
||||||
colors.gitSigns = {
|
colors.gitSigns = {
|
||||||
add = util.brighten(colors.gitSigns.add, 0.2),
|
add = "#266d6a",
|
||||||
change = util.brighten(colors.gitSigns.change, 0.2),
|
change = "#536c9e",
|
||||||
delete = util.brighten(colors.gitSigns.delete, 0.2),
|
delete = "#b2555b",
|
||||||
}
|
}
|
||||||
|
|
||||||
colors.git.ignore = colors.dark3
|
colors.git.ignore = colors.dark3
|
||||||
@@ -73,8 +72,13 @@ function M.setup(config)
|
|||||||
colors.bg_statusline = colors.bg_dark
|
colors.bg_statusline = colors.bg_dark
|
||||||
|
|
||||||
-- Sidebar and Floats are configurable
|
-- Sidebar and Floats are configurable
|
||||||
colors.bg_sidebar = (config.transparentSidebar and colors.none) or config.darkSidebar and colors.bg_dark or colors.bg
|
colors.bg_sidebar = config.styles.sidebars == "transparent" and colors.none
|
||||||
colors.bg_float = config.darkFloat and colors.bg_dark or colors.bg
|
or config.styles.sidebars == "dark" and colors.bg_dark
|
||||||
|
or colors.bg
|
||||||
|
|
||||||
|
colors.bg_float = config.styles.floats == "transparent" and colors.none
|
||||||
|
or config.styles.floats == "dark" and colors.bg_dark
|
||||||
|
or colors.bg
|
||||||
|
|
||||||
colors.bg_visual = util.darken(colors.blue0, 0.7)
|
colors.bg_visual = util.darken(colors.blue0, 0.7)
|
||||||
colors.bg_search = colors.blue0
|
colors.bg_search = colors.blue0
|
||||||
@@ -85,10 +89,9 @@ function M.setup(config)
|
|||||||
colors.info = colors.blue2
|
colors.info = colors.blue2
|
||||||
colors.hint = colors.teal
|
colors.hint = colors.teal
|
||||||
|
|
||||||
util.color_overrides(colors, config)
|
config.on_colors(colors)
|
||||||
|
if opts.transform and (config.style == "day" or vim.o.background == "light") then
|
||||||
if config.transform_colors and (config.style == "day" or vim.o.background == "light") then
|
util.invert_colors(colors)
|
||||||
return util.light_colors(colors)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return colors
|
return colors
|
||||||
|
|||||||
@@ -1,40 +1,51 @@
|
|||||||
-- shim vim for kitty and other generators
|
local M = {}
|
||||||
vim = vim or { g = {}, o = {} }
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
---@class Config
|
---@class Config
|
||||||
local config = {
|
local defaults = {
|
||||||
style = opt("style", "storm"),
|
style = "storm", -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
|
||||||
dayBrightness = opt("day_brightness", 0.3),
|
transparent = false, -- Enable this to disable setting the background color
|
||||||
transparent = opt("transparent", false),
|
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim |
|
||||||
commentStyle = opt("italic_comments", true) and "italic" or "NONE",
|
styles = {
|
||||||
keywordStyle = opt("italic_keywords", true) and "italic" or "NONE",
|
-- Style to be applied to different syntax groups
|
||||||
functionStyle = opt("italic_functions", false) and "italic" or "NONE",
|
-- Value is any valid attr-list value `:help attr-list`
|
||||||
variableStyle = opt("italic_variables", false) and "italic" or "NONE",
|
comments = "italic",
|
||||||
hideInactiveStatusline = opt("hide_inactive_statusline", false),
|
keywords = "italic",
|
||||||
terminalColors = opt("terminal_colors", true),
|
functions = "NONE",
|
||||||
sidebars = opt("sidebars", {}),
|
variables = "NONE",
|
||||||
colors = opt("colors", {}),
|
-- Background styles. Can be "dark", "transparent" or "normal"
|
||||||
dev = opt("dev", false),
|
sidebars = "dark", -- style for sidebars, see below
|
||||||
darkFloat = opt("dark_float", true),
|
floats = "dark", -- style for floating windows
|
||||||
darkSidebar = opt("dark_sidebar", true),
|
},
|
||||||
transparentSidebar = opt("transparent_sidebar", false),
|
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows. For example: `["qf", "vista_kind", "terminal", "packer"]` |
|
||||||
transform_colors = false,
|
day_brightness = 0.3, -- Adjusts the brightness of the colors of the **Day** style. Number between 0 and 1, from dull to vibrant colors |
|
||||||
lualineBold = opt("lualine_bold", false),
|
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**. |
|
||||||
|
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold |
|
||||||
|
|
||||||
|
--- You can override specific color groups to use other groups or a hex color |
|
||||||
|
--- fucntion will be called with a ColorScheme table
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_colors = function(colors) end,
|
||||||
|
|
||||||
|
--- You can override specific highlights to use other groups or a hex color |
|
||||||
|
--- fucntion will be called with a Highlights and ColorScheme table
|
||||||
|
---@param highlights Highlights
|
||||||
|
---@param colors ColorScheme
|
||||||
|
on_highlights = function(highlights, colors) end,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.style == "day" then
|
---@type Config
|
||||||
vim.o.background = "light"
|
M.options = {}
|
||||||
|
|
||||||
|
---@param options Config|nil
|
||||||
|
function M.setup(options)
|
||||||
|
M.options = vim.tbl_deep_extend("force", {}, defaults, options or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
return config
|
---@param options Config|nil
|
||||||
|
function M.extend(options)
|
||||||
|
M.options = vim.tbl_deep_extend("force", {}, M.options or defaults, options or {})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.setup()
|
||||||
|
|
||||||
|
return M
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package.path = "./lua/?/init.lua;./lua/?.lua"
|
local M = {}
|
||||||
|
|
||||||
local config = require("tokyonight.config")
|
|
||||||
|
|
||||||
local function write(str, fileName)
|
local function write(str, fileName)
|
||||||
print("[write] extra/" .. fileName)
|
print("[write] extra/" .. fileName)
|
||||||
@@ -9,35 +7,40 @@ local function write(str, fileName)
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- map of plugin name to plugin extension
|
function M.setup()
|
||||||
local extras = {
|
local config = require("tokyonight.config")
|
||||||
kitty = "conf",
|
vim.o.background = "dark"
|
||||||
fish = "fish",
|
|
||||||
alacritty = "yml",
|
|
||||||
wezterm = "toml",
|
|
||||||
tmux = "tmux",
|
|
||||||
xresources = "Xresources",
|
|
||||||
xfceterm = "theme",
|
|
||||||
foot = "ini",
|
|
||||||
tilix = "json",
|
|
||||||
}
|
|
||||||
-- map of style to style name
|
|
||||||
local styles = {
|
|
||||||
storm = " Storm",
|
|
||||||
night = "",
|
|
||||||
day = " Day",
|
|
||||||
}
|
|
||||||
|
|
||||||
for extra, ext in pairs(extras) do
|
-- map of plugin name to plugin extension
|
||||||
local plugin = require("tokyonight.extra." .. extra)
|
local extras = {
|
||||||
for style, style_name in pairs(styles) do
|
kitty = "conf",
|
||||||
config.style = style
|
fish = "fish",
|
||||||
config = config or require("tokyonight.config")
|
alacritty = "yml",
|
||||||
config.transform_colors = true
|
wezterm = "toml",
|
||||||
local colors = require("tokyonight.colors").setup(config)
|
tmux = "tmux",
|
||||||
local fname = extra .. "_tokyonight_" .. style .. "." .. ext
|
xresources = "Xresources",
|
||||||
colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname
|
xfceterm = "theme",
|
||||||
colors["_style_name"] = "Tokyo Night" .. style_name
|
foot = "ini",
|
||||||
write(plugin.generate(colors), fname)
|
tilix = "json",
|
||||||
|
}
|
||||||
|
-- map of style to style name
|
||||||
|
local styles = {
|
||||||
|
storm = " Storm",
|
||||||
|
night = "",
|
||||||
|
day = " Day",
|
||||||
|
}
|
||||||
|
|
||||||
|
for extra, ext in pairs(extras) do
|
||||||
|
local plugin = require("tokyonight.extra." .. extra)
|
||||||
|
for style, style_name in pairs(styles) do
|
||||||
|
config.setup({ style = style })
|
||||||
|
local colors = require("tokyonight.colors").setup({ transform = true })
|
||||||
|
local fname = extra .. "_tokyonight_" .. style .. "." .. ext
|
||||||
|
colors["_upstream_url"] = "https://github.com/folke/tokyonight.nvim/raw/main/extras/" .. fname
|
||||||
|
colors["_style_name"] = "Tokyo Night" .. style_name
|
||||||
|
write(plugin.generate(colors), fname)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
local util = require("tokyonight.util")
|
local util = require("tokyonight.util")
|
||||||
local theme = require("tokyonight.theme")
|
local theme = require("tokyonight.theme")
|
||||||
|
local config = require("tokyonight.config")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.colorscheme()
|
---@param opts Config|nil
|
||||||
|
function M.load(opts)
|
||||||
|
if opts then
|
||||||
|
require("tokyonight.config").extend(opts)
|
||||||
|
end
|
||||||
util.load(theme.setup())
|
util.load(theme.setup())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.setup = config.setup
|
||||||
|
|
||||||
|
-- keep for backward compatibility
|
||||||
|
M.colorscheme = M.load
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -2,21 +2,31 @@ local util = require("tokyonight.util")
|
|||||||
local colors = require("tokyonight.colors")
|
local colors = require("tokyonight.colors")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
--
|
||||||
|
---@class Highlight
|
||||||
|
---@field fg string|nil
|
||||||
|
---@field bg string|nil
|
||||||
|
---@field sp string|nil
|
||||||
|
---@field style string|nil
|
||||||
|
|
||||||
|
---@alias Highlights table<string,Highlight>
|
||||||
|
|
||||||
---@param config Config
|
|
||||||
---@return Theme
|
---@return Theme
|
||||||
function M.setup(config)
|
function M.setup()
|
||||||
config = config or require("tokyonight.config")
|
local config = require("tokyonight.config").options
|
||||||
|
|
||||||
---@class Theme
|
---@class Theme
|
||||||
local theme = {}
|
---@field highlights Highlights
|
||||||
theme.config = config
|
local theme = {
|
||||||
theme.colors = colors.setup(config)
|
config = config,
|
||||||
|
colors = colors.setup(),
|
||||||
|
}
|
||||||
|
|
||||||
local c = theme.colors
|
local c = theme.colors
|
||||||
|
|
||||||
theme.base = {
|
theme.highlights = {
|
||||||
Comment = { fg = c.comment, style = config.commentStyle }, -- any comment
|
Foo = { bg = c.magenta2, fg = c.magenta2 },
|
||||||
|
|
||||||
|
Comment = { fg = c.comment, style = config.styles.comments }, -- any comment
|
||||||
ColorColumn = { bg = c.black }, -- used for the columns set with 'colorcolumn'
|
ColorColumn = { bg = c.black }, -- used for the columns set with 'colorcolumn'
|
||||||
Conceal = { fg = c.dark5 }, -- placeholder characters substituted for concealed text (see 'conceallevel')
|
Conceal = { fg = c.dark5 }, -- placeholder characters substituted for concealed text (see 'conceallevel')
|
||||||
Cursor = { fg = c.bg, bg = c.fg }, -- character under the cursor
|
Cursor = { fg = c.bg, bg = c.fg }, -- character under the cursor
|
||||||
@@ -34,6 +44,7 @@ function M.setup(config)
|
|||||||
-- TermCursorNC= { }, -- cursor in an unfocused terminal
|
-- TermCursorNC= { }, -- cursor in an unfocused terminal
|
||||||
ErrorMsg = { fg = c.error }, -- error messages on the command line
|
ErrorMsg = { fg = c.error }, -- error messages on the command line
|
||||||
VertSplit = { fg = c.border }, -- the column separating vertically split windows
|
VertSplit = { fg = c.border }, -- the column separating vertically split windows
|
||||||
|
WinSeparator = { fg = c.border, style = "bold" }, -- the column separating vertically split windows
|
||||||
Folded = { fg = c.blue, bg = c.fg_gutter }, -- line used for closed folds
|
Folded = { fg = c.blue, bg = c.fg_gutter }, -- line used for closed folds
|
||||||
FoldColumn = { bg = c.bg, fg = c.comment }, -- 'foldcolumn'
|
FoldColumn = { bg = c.bg, fg = c.comment }, -- 'foldcolumn'
|
||||||
SignColumn = { bg = config.transparent and c.none or c.bg, fg = c.fg_gutter }, -- column where |signs| are displayed
|
SignColumn = { bg = config.transparent and c.none or c.bg, fg = c.fg_gutter }, -- column where |signs| are displayed
|
||||||
@@ -90,15 +101,15 @@ function M.setup(config)
|
|||||||
-- 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
|
||||||
|
|
||||||
Identifier = { fg = c.magenta, style = config.variableStyle }, -- (preferred) any variable name
|
Identifier = { fg = c.magenta, style = config.styles.variables }, -- (preferred) any variable name
|
||||||
Function = { fg = c.blue, style = config.functionStyle }, -- function name (also: methods for classes)
|
Function = { fg = c.blue, style = config.styles.functions }, -- 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, style = config.keywordStyle }, -- any other keyword
|
Keyword = { fg = c.cyan, style = config.styles.keywords }, -- 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
|
||||||
@@ -179,26 +190,6 @@ function M.setup(config)
|
|||||||
|
|
||||||
ALEErrorSign = { fg = c.error },
|
ALEErrorSign = { fg = c.error },
|
||||||
ALEWarningSign = { fg = c.warning },
|
ALEWarningSign = { fg = c.warning },
|
||||||
}
|
|
||||||
|
|
||||||
if not vim.diagnostic then
|
|
||||||
local severity_map = {
|
|
||||||
Error = "Error",
|
|
||||||
Warn = "Warning",
|
|
||||||
Info = "Information",
|
|
||||||
Hint = "Hint",
|
|
||||||
}
|
|
||||||
local types = { "Default", "VirtualText", "Underline" }
|
|
||||||
for _, type in ipairs(types) do
|
|
||||||
for snew, sold in pairs(severity_map) do
|
|
||||||
theme.base["LspDiagnostics" .. type .. sold] = {
|
|
||||||
link = "Diagnostic" .. (type == "Default" and "" or type) .. snew,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
theme.plugins = {
|
|
||||||
|
|
||||||
-- These groups are for the neovim tree-sitter highlights.
|
-- These groups are for the neovim tree-sitter highlights.
|
||||||
-- As of writing, tree-sitter support is a WIP, group names may change.
|
-- As of writing, tree-sitter support is a WIP, group names may change.
|
||||||
@@ -227,8 +218,8 @@ function M.setup(config)
|
|||||||
-- 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 = { fg = c.purple, style = config.keywordStyle }, -- For keywords that don't fall in previous categories.
|
TSKeyword = { fg = c.purple, style = config.styles.keywords }, -- For keywords that don't fall in previous categories.
|
||||||
TSKeywordFunction = { fg = c.magenta, style = config.functionStyle }, -- For keywords used to define a fuction.
|
TSKeywordFunction = { fg = c.magenta, style = config.styles.functions }, -- For keywords used to define a fuction.
|
||||||
TSLabel = { fg = c.blue }, -- For labels: `label:` in C and `:label:` in Lua.
|
TSLabel = { fg = c.blue }, -- For labels: `label:` in C and `:label:` in Lua.
|
||||||
-- TSMethod = { }; -- For method calls and definitions.
|
-- TSMethod = { }; -- For method calls and definitions.
|
||||||
-- TSNamespace = { }; -- For identifiers referring to modules and namespaces.
|
-- TSNamespace = { }; -- For identifiers referring to modules and namespaces.
|
||||||
@@ -248,7 +239,7 @@ function M.setup(config)
|
|||||||
-- 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.
|
||||||
TSVariable = { style = config.variableStyle }, -- Any variable name that does not have another highlight.
|
TSVariable = { style = config.styles.variables }, -- Any variable name that does not have another highlight.
|
||||||
TSVariableBuiltin = { fg = c.red }, -- Variable names that are defined by the languages, like `this` or `self`.
|
TSVariableBuiltin = { fg = c.red }, -- Variable names that are defined by the languages, like `this` or `self`.
|
||||||
|
|
||||||
-- TSTag = { }; -- Tags like html tag names.
|
-- TSTag = { }; -- Tags like html tag names.
|
||||||
@@ -275,9 +266,9 @@ function M.setup(config)
|
|||||||
rainbowcol7 = { fg = c.red },
|
rainbowcol7 = { fg = c.red },
|
||||||
|
|
||||||
-- LspTrouble
|
-- LspTrouble
|
||||||
LspTroubleText = { fg = c.fg_dark },
|
TroubleText = { fg = c.fg_dark },
|
||||||
LspTroubleCount = { fg = c.magenta, bg = c.fg_gutter },
|
TroubleCount = { fg = c.magenta, bg = c.fg_gutter },
|
||||||
LspTroubleNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar },
|
TroubleNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar },
|
||||||
|
|
||||||
-- Illuminate
|
-- Illuminate
|
||||||
illuminatedWord = { bg = c.fg_gutter },
|
illuminatedWord = { bg = c.fg_gutter },
|
||||||
@@ -316,8 +307,8 @@ function M.setup(config)
|
|||||||
GitSignsDelete = { fg = c.gitSigns.delete }, -- diff mode: Deleted line |diff.txt|
|
GitSignsDelete = { fg = c.gitSigns.delete }, -- diff mode: Deleted line |diff.txt|
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
TelescopeBorder = { fg = c.border_highlight, bg = config.transparent and c.bg_float or c.bg },
|
TelescopeBorder = { fg = c.border_highlight, bg = c.bg_float },
|
||||||
TelescopeNormal = { fg = c.fg, bg = config.transparent and c.bg_float or c.bg },
|
TelescopeNormal = { fg = c.fg, bg = c.bg_float },
|
||||||
|
|
||||||
-- NvimTree
|
-- NvimTree
|
||||||
NvimTreeNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar },
|
NvimTreeNormal = { fg = c.fg_sidebar, bg = c.bg_sidebar },
|
||||||
@@ -510,7 +501,7 @@ function M.setup(config)
|
|||||||
MiniStarterCurrent = { style = "nocombine" },
|
MiniStarterCurrent = { style = "nocombine" },
|
||||||
MiniStarterFooter = { fg = c.yellow, style = "italic" },
|
MiniStarterFooter = { fg = c.yellow, style = "italic" },
|
||||||
MiniStarterHeader = { fg = c.blue },
|
MiniStarterHeader = { fg = c.blue },
|
||||||
MiniStarterInactive = { fg = c.comment, style = config.commentStyle },
|
MiniStarterInactive = { fg = c.comment, style = config.styles.comments },
|
||||||
MiniStarterItem = { fg = c.fg, bg = config.transparent and c.none or c.bg },
|
MiniStarterItem = { fg = c.fg, bg = config.transparent and c.none or c.bg },
|
||||||
MiniStarterItemBullet = { fg = c.border_highlight },
|
MiniStarterItemBullet = { fg = c.border_highlight },
|
||||||
MiniStarterItemPrefix = { fg = c.warning },
|
MiniStarterItemPrefix = { fg = c.warning },
|
||||||
@@ -546,13 +537,30 @@ function M.setup(config)
|
|||||||
MiniTrailspace = { bg = c.red },
|
MiniTrailspace = { bg = c.red },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not vim.diagnostic then
|
||||||
|
local severity_map = {
|
||||||
|
Error = "Error",
|
||||||
|
Warn = "Warning",
|
||||||
|
Info = "Information",
|
||||||
|
Hint = "Hint",
|
||||||
|
}
|
||||||
|
local types = { "Default", "VirtualText", "Underline" }
|
||||||
|
for _, type in ipairs(types) do
|
||||||
|
for snew, sold in pairs(severity_map) do
|
||||||
|
theme.highlights["LspDiagnostics" .. type .. sold] = {
|
||||||
|
link = "Diagnostic" .. (type == "Default" and "" or type) .. snew,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
theme.defer = {}
|
theme.defer = {}
|
||||||
|
|
||||||
if config.hideInactiveStatusline then
|
if config.hide_inactive_statusline then
|
||||||
local inactive = { style = "underline", bg = c.none, fg = c.bg, sp = c.border }
|
local inactive = { style = "underline", bg = c.none, fg = c.bg, sp = c.border }
|
||||||
|
|
||||||
-- StatusLineNC
|
-- StatusLineNC
|
||||||
theme.base.StatusLineNC = inactive
|
theme.highlights.StatusLineNC = inactive
|
||||||
|
|
||||||
-- LuaLine
|
-- LuaLine
|
||||||
for _, section in ipairs({ "a", "b", "c" }) do
|
for _, section in ipairs({ "a", "b", "c" }) do
|
||||||
@@ -560,7 +568,14 @@ function M.setup(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- mini.statusline
|
-- mini.statusline
|
||||||
theme.plugins.MiniStatuslineInactive = inactive
|
theme.highlights.MiniStatuslineInactive = inactive
|
||||||
|
end
|
||||||
|
|
||||||
|
config.on_highlights(theme.highlights, theme.colors)
|
||||||
|
|
||||||
|
if config.style == "day" or vim.o.background == "light" then
|
||||||
|
util.invert_colors(theme.colors)
|
||||||
|
util.invert_highlights(theme.highlights)
|
||||||
end
|
end
|
||||||
|
|
||||||
return theme
|
return theme
|
||||||
|
|||||||
@@ -1,29 +1,19 @@
|
|||||||
local hsluv = require("tokyonight.hsluv")
|
local M = {}
|
||||||
|
|
||||||
local util = {}
|
M.bg = "#000000"
|
||||||
|
M.fg = "#ffffff"
|
||||||
|
M.day_brightness = 0.3
|
||||||
|
|
||||||
util.colorsUsed = {}
|
---@param c string
|
||||||
util.colorCache = {}
|
local function hexToRgb(c)
|
||||||
|
c = string.lower(c)
|
||||||
util.bg = "#000000"
|
return { tonumber(c:sub(2, 3), 16), tonumber(c:sub(4, 5), 16), tonumber(c:sub(6, 7), 16) }
|
||||||
util.fg = "#ffffff"
|
|
||||||
util.day_brightness = 0.3
|
|
||||||
|
|
||||||
local function hexToRgb(hex_str)
|
|
||||||
local hex = "[abcdef0-9][abcdef0-9]"
|
|
||||||
local pat = "^#(" .. hex .. ")(" .. hex .. ")(" .. hex .. ")$"
|
|
||||||
hex_str = string.lower(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)
|
|
||||||
return { tonumber(r, 16), tonumber(g, 16), tonumber(b, 16) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param fg string foreground color
|
---@param fg string foreground color
|
||||||
---@param bg string background color
|
---@param bg string background color
|
||||||
---@param alpha number number between 0 and 1. 0 results in bg, 1 results in fg
|
---@param alpha number number between 0 and 1. 0 results in bg, 1 results in fg
|
||||||
function util.blend(fg, bg, alpha)
|
function M.blend(fg, bg, alpha)
|
||||||
bg = hexToRgb(bg)
|
bg = hexToRgb(bg)
|
||||||
fg = hexToRgb(fg)
|
fg = hexToRgb(fg)
|
||||||
|
|
||||||
@@ -32,105 +22,41 @@ function util.blend(fg, bg, alpha)
|
|||||||
return math.floor(math.min(math.max(0, ret), 255) + 0.5)
|
return math.floor(math.min(math.max(0, ret), 255) + 0.5)
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
function M.darken(hex, amount, bg)
|
||||||
return util.blend(hex, bg or util.bg, math.abs(amount))
|
return M.blend(hex, bg or M.bg, math.abs(amount))
|
||||||
end
|
end
|
||||||
function util.lighten(hex, amount, fg)
|
function M.lighten(hex, amount, fg)
|
||||||
return util.blend(hex, fg or util.fg, math.abs(amount))
|
return M.blend(hex, fg or M.fg, math.abs(amount))
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.brighten(color, percentage)
|
function M.invert_color(color)
|
||||||
local hsl = hsluv.hex_to_hsluv(color)
|
local hsluv = require("tokyonight.hsluv")
|
||||||
local larpSpace = 100 - hsl[3]
|
|
||||||
if percentage < 0 then
|
|
||||||
larpSpace = hsl[3]
|
|
||||||
end
|
|
||||||
hsl[3] = hsl[3] + larpSpace * percentage
|
|
||||||
return hsluv.hsluv_to_hex(hsl)
|
|
||||||
end
|
|
||||||
|
|
||||||
function util.invertColor(color)
|
|
||||||
if color ~= "NONE" then
|
if color ~= "NONE" then
|
||||||
local hsl = hsluv.hex_to_hsluv(color)
|
local hsl = hsluv.hex_to_hsluv(color)
|
||||||
hsl[3] = 100 - hsl[3]
|
hsl[3] = 100 - hsl[3]
|
||||||
if hsl[3] < 40 then
|
if hsl[3] < 40 then
|
||||||
hsl[3] = hsl[3] + (100 - hsl[3]) * util.day_brightness
|
hsl[3] = hsl[3] + (100 - hsl[3]) * M.day_brightness
|
||||||
end
|
end
|
||||||
return hsluv.hsluv_to_hex(hsl)
|
return hsluv.hsluv_to_hex(hsl)
|
||||||
end
|
end
|
||||||
return color
|
return color
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.randomColor(color)
|
function M.highlight(group, color)
|
||||||
if color ~= "NONE" then
|
local hl = { fg = color.fg, bg = color.bg, sp = color.sp, link = color.link }
|
||||||
local hsl = hsluv.hex_to_hsluv(color)
|
if color.style and color.style:lower() ~= "none" then
|
||||||
hsl[1] = math.random(1, 360)
|
for s in string.gmatch(color.style, "([^,]+)") do
|
||||||
return hsluv.hsluv_to_hex(hsl)
|
hl[s] = true
|
||||||
end
|
|
||||||
return color
|
|
||||||
end
|
|
||||||
|
|
||||||
function util.getColor(color)
|
|
||||||
if vim.o.background == "dark" then
|
|
||||||
return color
|
|
||||||
end
|
|
||||||
if not util.colorCache[color] then
|
|
||||||
util.colorCache[color] = util.invertColor(color)
|
|
||||||
end
|
|
||||||
return util.colorCache[color]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- local ns = vim.api.nvim_create_namespace("tokyonight")
|
|
||||||
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 fg = color.fg and "guifg=" .. util.getColor(color.fg) or "guifg=NONE"
|
|
||||||
local bg = color.bg and "guibg=" .. util.getColor(color.bg) or "guibg=NONE"
|
|
||||||
local sp = color.sp and "guisp=" .. util.getColor(color.sp) or ""
|
|
||||||
|
|
||||||
local hl = "highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp
|
|
||||||
|
|
||||||
if color.link then
|
|
||||||
vim.cmd("highlight! link " .. group .. " " .. color.link)
|
|
||||||
else
|
|
||||||
-- local data = {}
|
|
||||||
-- if color.fg then data.foreground = color.fg end
|
|
||||||
-- if color.bg then data.background = color.bg end
|
|
||||||
-- if color.sp then data.special = color.sp end
|
|
||||||
-- if color.style then data[color.style] = true end
|
|
||||||
-- vim.api.nvim_set_hl(ns, group, data)
|
|
||||||
vim.cmd(hl)
|
|
||||||
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
|
||||||
|
vim.api.nvim_set_hl(0, group, hl)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Delete the autocmds when the theme changes to something else
|
--- Delete the autocmds when the theme changes to something else
|
||||||
function util.onColorScheme()
|
function M.onColorScheme()
|
||||||
if vim.g.colors_name ~= "tokyonight" then
|
if vim.g.colors_name ~= "tokyonight" then
|
||||||
vim.cmd([[autocmd! TokyoNight]])
|
vim.cmd([[autocmd! TokyoNight]])
|
||||||
vim.cmd([[augroup! TokyoNight]])
|
vim.cmd([[augroup! TokyoNight]])
|
||||||
@@ -138,13 +64,10 @@ function util.onColorScheme()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---@param config Config
|
---@param config Config
|
||||||
function util.autocmds(config)
|
function M.autocmds(config)
|
||||||
vim.cmd([[augroup TokyoNight]])
|
vim.cmd([[augroup TokyoNight]])
|
||||||
vim.cmd([[ autocmd!]])
|
vim.cmd([[ autocmd!]])
|
||||||
vim.cmd([[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]])
|
vim.cmd([[ autocmd ColorScheme * lua require("tokyonight.util").onColorScheme()]])
|
||||||
if config.dev then
|
|
||||||
vim.cmd([[ autocmd BufWritePost */lua/tokyonight/** nested colorscheme tokyonight]])
|
|
||||||
end
|
|
||||||
for _, sidebar in ipairs(config.sidebars) do
|
for _, sidebar in ipairs(config.sidebars) do
|
||||||
if sidebar == "terminal" then
|
if sidebar == "terminal" then
|
||||||
vim.cmd([[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]])
|
vim.cmd([[ autocmd TermOpen * setlocal winhighlight=Normal:NormalSB,SignColumn:SignColumnSB]])
|
||||||
@@ -161,20 +84,20 @@ end
|
|||||||
--
|
--
|
||||||
---@param str string template string
|
---@param str string template string
|
||||||
---@param table table key value pairs to replace in the string
|
---@param table table key value pairs to replace in the string
|
||||||
function util.template(str, table)
|
function M.template(str, table)
|
||||||
return (str:gsub("($%b{})", function(w)
|
return (str:gsub("($%b{})", function(w)
|
||||||
return table[w:sub(3, -2)] or w
|
return table[w:sub(3, -2)] or w
|
||||||
end))
|
end))
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.syntax(syntax)
|
function M.syntax(syntax)
|
||||||
for group, colors in pairs(syntax) do
|
for group, colors in pairs(syntax) do
|
||||||
util.highlight(group, colors)
|
M.highlight(group, colors)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param colors ColorScheme
|
---@param colors ColorScheme
|
||||||
function util.terminal(colors)
|
function M.terminal(colors)
|
||||||
-- dark
|
-- dark
|
||||||
vim.g.terminal_color_0 = colors.black
|
vim.g.terminal_color_0 = colors.black
|
||||||
vim.g.terminal_color_8 = colors.terminal_black
|
vim.g.terminal_color_8 = colors.terminal_black
|
||||||
@@ -201,130 +124,56 @@ function util.terminal(colors)
|
|||||||
|
|
||||||
vim.g.terminal_color_6 = colors.cyan
|
vim.g.terminal_color_6 = colors.cyan
|
||||||
vim.g.terminal_color_14 = colors.cyan
|
vim.g.terminal_color_14 = colors.cyan
|
||||||
|
end
|
||||||
|
|
||||||
if vim.o.background == "light" then
|
---@param colors ColorScheme
|
||||||
for i = 0, 15, 1 do
|
function M.invert_colors(colors)
|
||||||
vim.g["terminal_color_" .. i] = util.getColor(vim.g["terminal_color_" .. i])
|
if type(colors) == "string" then
|
||||||
|
---@diagnostic disable-next-line: return-type-mismatch
|
||||||
|
return M.invert_color(colors)
|
||||||
|
end
|
||||||
|
for key, value in pairs(colors) do
|
||||||
|
colors[key] = M.invert_colors(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---@param hls Highlights
|
||||||
|
function M.invert_highlights(hls)
|
||||||
|
for _, hl in pairs(hls) do
|
||||||
|
if hl.fg then
|
||||||
|
hl.fg = M.invert_color(hl.fg)
|
||||||
|
end
|
||||||
|
if hl.bg then
|
||||||
|
hl.bg = M.invert_color(hl.bg)
|
||||||
|
end
|
||||||
|
if hl.sp then
|
||||||
|
hl.sp = M.invert_color(hl.sp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.light_colors(colors)
|
|
||||||
if type(colors) == "string" then
|
|
||||||
return util.getColor(colors)
|
|
||||||
end
|
|
||||||
local ret = {}
|
|
||||||
for key, value in pairs(colors) do
|
|
||||||
ret[key] = util.light_colors(value)
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param theme Theme
|
---@param theme Theme
|
||||||
function util.load(theme)
|
function M.load(theme)
|
||||||
-- only needed to clear when not the default colorscheme
|
-- only needed to clear when not the default colorscheme
|
||||||
if vim.g.colors_name then
|
if vim.g.colors_name then
|
||||||
vim.cmd("hi clear")
|
vim.cmd("hi clear")
|
||||||
end
|
end
|
||||||
-- if vim.fn.exists("syntax_on") then
|
|
||||||
-- vim.cmd("syntax reset")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
vim.o.termguicolors = true
|
vim.o.termguicolors = true
|
||||||
vim.g.colors_name = "tokyonight"
|
vim.g.colors_name = "tokyonight"
|
||||||
-- vim.api.nvim__set_hl_ns(ns)
|
|
||||||
-- load base theme
|
M.syntax(theme.highlights)
|
||||||
util.syntax(theme.base)
|
|
||||||
util.syntax(theme.plugins)
|
-- vim.api.nvim_set_hl_ns(M.ns)
|
||||||
if theme.config.terminalColors then
|
if theme.config.terminal_colors then
|
||||||
util.terminal(theme.colors)
|
M.terminal(theme.colors)
|
||||||
end
|
end
|
||||||
|
|
||||||
util.autocmds(theme.config)
|
M.autocmds(theme.config)
|
||||||
|
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
util.syntax(theme.defer)
|
M.syntax(theme.defer)
|
||||||
end, 100)
|
end, 100)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param config Config
|
return M
|
||||||
---@param colors ColorScheme
|
|
||||||
function util.color_overrides(colors, config)
|
|
||||||
if type(config.colors) == "table" then
|
|
||||||
for key, value in pairs(config.colors) do
|
|
||||||
if not colors[key] then
|
|
||||||
error("Color " .. key .. " does not exist")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Patch: https://github.com/ful1e5/onedark.nvim/issues/6
|
|
||||||
if type(colors[key]) == "table" then
|
|
||||||
util.color_overrides(colors[key], { colors = value })
|
|
||||||
else
|
|
||||||
if value:lower() == "none" then
|
|
||||||
-- set to none
|
|
||||||
colors[key] = "NONE"
|
|
||||||
elseif string.sub(value, 1, 1) == "#" then
|
|
||||||
-- hex override
|
|
||||||
colors[key] = value
|
|
||||||
else
|
|
||||||
-- another group
|
|
||||||
if not colors[value] then
|
|
||||||
error("Color " .. value .. " does not exist")
|
|
||||||
end
|
|
||||||
colors[key] = colors[value]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function util.light(brightness)
|
|
||||||
for hl_name, hl in pairs(vim.api.nvim__get_hl_defs(0)) do
|
|
||||||
local def = {}
|
|
||||||
for key, def_key in pairs({ foreground = "fg", background = "bg", special = "sp" }) do
|
|
||||||
if type(hl[key]) == "number" then
|
|
||||||
local hex = string.format("#%06x", hl[key])
|
|
||||||
local color = util.invertColor(hex)
|
|
||||||
if brightness then
|
|
||||||
color = util.brighten(hex, brightness)
|
|
||||||
end
|
|
||||||
table.insert(def, "gui" .. def_key .. "=" .. color)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if hl_name ~= "" and #def > 0 then
|
|
||||||
for _, style in pairs({ "bold", "italic", "underline", "undercurl", "reverse" }) do
|
|
||||||
if hl[style] then
|
|
||||||
table.insert(def, "gui=" .. style)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function util.random()
|
|
||||||
local colors = {}
|
|
||||||
for hl_name, hl in pairs(vim.api.nvim__get_hl_defs(0)) do
|
|
||||||
local def = {}
|
|
||||||
for key, def_key in pairs({ foreground = "fg", background = "bg", special = "sp" }) do
|
|
||||||
if type(hl[key]) == "number" then
|
|
||||||
local hex = string.format("#%06x", hl[key])
|
|
||||||
local color = colors[hex] and colors[hex] or util.randomColor(hex)
|
|
||||||
colors[hex] = color
|
|
||||||
table.insert(def, "gui" .. def_key .. "=" .. color)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if hl_name ~= "" and #def > 0 then
|
|
||||||
for _, style in pairs({ "bold", "italic", "underline", "undercurl", "reverse" }) do
|
|
||||||
if hl[style] then
|
|
||||||
table.insert(def, "gui=" .. style)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.cmd("highlight! " .. hl_name .. " " .. table.concat(def, " "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return util
|
|
||||||
|
|||||||
Reference in New Issue
Block a user