mirror of
https://github.com/ViViDboarder/wombat.nvim.git
synced 2025-02-22 13:54:07 +00:00
Small refactor again to make it easier to select base ansi themes
This commit is contained in:
parent
e41359fa29
commit
5b50320c99
54
README.md
54
README.md
@ -17,21 +17,57 @@ A colorscheme based on the original wombat256mod colorscheme. This does not have
|
||||
|
||||
### wombat_lush
|
||||
|
||||
A colorscheme based on the original wombat256mod colorscheme, but with extended support for newer Neovim features.
|
||||
A slight departure from the wombat256mod colorscheme, but with extended support for newer Neovim features.
|
||||
|
||||
## Installation
|
||||
|
||||
### With Packer
|
||||
|
||||
use {
|
||||
"ViViDboarder/wombat.nvim",
|
||||
requires = "rktjmp/lush.nvim",
|
||||
}
|
||||
```lua
|
||||
use {
|
||||
"ViViDboarder/wombat.nvim",
|
||||
requires = "rktjmp/lush.nvim",
|
||||
}
|
||||
```
|
||||
|
||||
## Extending
|
||||
### With lazy.nvim
|
||||
|
||||
If you are using a terminal colorsceme based on Wombat and would like your colors to match more percisely, you can define a new set of ansi colors in a lua file similar to the one shown in `lua/wombat/ansi_iterm.lua'. It should be in a path `lua/wombat/ansi_new_theme.lua`.
|
||||
```lua
|
||||
{
|
||||
"ViViDboarder/wombat.nvim",
|
||||
dependencies = { { "rktjmp/lush.nvim" } },
|
||||
opts = {
|
||||
-- You can optionally specify the name of the ansi colors you wish to use
|
||||
-- This defaults to nil and will use the default ansi colors for the theme
|
||||
ansi_colors_name = nil,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Then you can create a new colorscheme file similar to `colors/wombat.vim`, but reference the new file name instead of `ansi_iterm`.
|
||||
## Configuration
|
||||
|
||||
This will define a new colorscheme using the same mappings as defined in wombat.nvim, but with your new ansi colors.
|
||||
You can overide the base ANSI color schemes to match your terminal by selecting an alternative scheme when setting up the module.
|
||||
|
||||
```lua
|
||||
require('wombat').setup({
|
||||
ansi_colors_name = "ghostty",
|
||||
})
|
||||
```
|
||||
|
||||
## Setting the theme in Lua
|
||||
|
||||
You can set the theme using any combination of theme file and ansi colors using the lua command:
|
||||
|
||||
```lua
|
||||
require("wombat").set_colorschme("theme_name", require("lush_theme.wombat_lush"), "ghostty")
|
||||
```
|
||||
|
||||
This may be useful to you if you want to extend the team to be based on more percise ansi colors matching your terminal.
|
||||
|
||||
## Extending ansi colors
|
||||
|
||||
If you are using a terminal colorsceme based on Wombat and would like your colors to match more percisely, you can define a new set of ansi colors in a lua file similar to the one shown in `lua/wombat/ansi_iterm2.lua`. It should be in a path `lua/wombat/ansi_new_theme.lua`.
|
||||
|
||||
You can then set this as the default ansi colors by setting the `ansi_colors_name` in the setup function shown above.
|
||||
|
||||
If you want to be able to set this via `:colorscheme`, you can create a new colorscheme file similar to `colors/wombat.vim`, but reference the new file name instead of `iterm2`.
|
||||
|
@ -1,19 +1 @@
|
||||
" You probably always want to set this in your vim file
|
||||
let g:colors_name='wombat'
|
||||
|
||||
" By setting our module to nil, we clear lua's cache,
|
||||
" which means the require ahead will *always* occur.
|
||||
"
|
||||
" This isn't strictly required but it can be a useful trick if you are
|
||||
" incrementally editing your config a lot and want to be sure your themes
|
||||
" changes are being picked up without restarting neovim.
|
||||
"
|
||||
" Note if you're working in on your theme and have :Lushify'd the buffer,
|
||||
" your changes will be applied with our without the following line.
|
||||
"
|
||||
" The performance impact of this call can be measured in the hundreds of
|
||||
" *nanoseconds* and such could be considered 'production safe'.
|
||||
lua package.loaded['lush_theme.lush_template'] = nil
|
||||
|
||||
" include our theme file and pass it to lush to apply
|
||||
lua require('lush')(require('lush_theme.wombat_lush').with_ansi("ansi_iterm"))
|
||||
lua require("wombat").set_colorscheme("wombat", require("lush_theme.wombat_lush"), "iterm2")
|
||||
|
@ -1,19 +1 @@
|
||||
" You probably always want to set this in your vim file
|
||||
let g:colors_name='wombat_classic'
|
||||
|
||||
" By setting our module to nil, we clear lua's cache,
|
||||
" which means the require ahead will *always* occur.
|
||||
"
|
||||
" This isn't strictly required but it can be a useful trick if you are
|
||||
" incrementally editing your config a lot and want to be sure your themes
|
||||
" changes are being picked up without restarting neovim.
|
||||
"
|
||||
" Note if you're working in on your theme and have :Lushify'd the buffer,
|
||||
" your changes will be applied with our without the following line.
|
||||
"
|
||||
" The performance impact of this call can be measured in the hundreds of
|
||||
" *nanoseconds* and such could be considered 'production safe'.
|
||||
lua package.loaded['lush_theme.lush_template'] = nil
|
||||
|
||||
" include our theme file and pass it to lush to apply
|
||||
lua require('lush')(require('lush_theme.wombat_classic').with_ansi("ansi_256mod"))
|
||||
lua require("wombat").set_colorscheme("wombat_classic", require("lush_theme.wombat_classic"), "256mod")
|
||||
|
@ -1,19 +1 @@
|
||||
" You probably always want to set this in your vim file
|
||||
let g:colors_name='wombat_lush'
|
||||
|
||||
" By setting our module to nil, we clear lua's cache,
|
||||
" which means the require ahead will *always* occur.
|
||||
"
|
||||
" This isn't strictly required but it can be a useful trick if you are
|
||||
" incrementally editing your config a lot and want to be sure your themes
|
||||
" changes are being picked up without restarting neovim.
|
||||
"
|
||||
" Note if you're working in on your theme and have :Lushify'd the buffer,
|
||||
" your changes will be applied with our without the following line.
|
||||
"
|
||||
" The performance impact of this call can be measured in the hundreds of
|
||||
" *nanoseconds* and such could be considered 'production safe'.
|
||||
lua package.loaded['lush_theme.lush_template'] = nil
|
||||
|
||||
" include our theme file and pass it to lush to apply
|
||||
lua require('lush')(require('lush_theme.wombat_lush').with_ansi("ansi_256mod"))
|
||||
lua require("wombat").set_colorscheme("wombat_lush", require("lush_theme.wombat_lush"), "lush")
|
||||
|
@ -42,7 +42,9 @@
|
||||
--
|
||||
-- `:lua require('lush').ify()`
|
||||
|
||||
local M = {}
|
||||
local M = {
|
||||
default_ansi_colors_name = "256mod",
|
||||
}
|
||||
|
||||
function M.with_ansi(ansi_colors_name)
|
||||
local lush = require("lush")
|
||||
@ -50,7 +52,7 @@ function M.with_ansi(ansi_colors_name)
|
||||
|
||||
local c = require("wombat.colors").from_ansi(ansi_colors_name)
|
||||
-- Import 256mod colors because we always use that background in classic
|
||||
local c256mod = require("wombat.colors").from_ansi("ansi_256mod")
|
||||
local c256mod = require("wombat.colors").from_ansi("256mod")
|
||||
local italic = "italic"
|
||||
|
||||
-- LSP/Linters mistakenly show `undefined global` errors in the spec, they may
|
||||
|
@ -42,7 +42,9 @@
|
||||
--
|
||||
-- `:lua require('lush').ify()`
|
||||
|
||||
local M = {}
|
||||
local M = {
|
||||
default_ansi_colors_name = "lush",
|
||||
}
|
||||
|
||||
function M.with_ansi(ansi_colors_name)
|
||||
local lush = require("lush")
|
||||
|
36
lua/wombat/ansi_ghostty.lua
Normal file
36
lua/wombat/ansi_ghostty.lua
Normal file
@ -0,0 +1,36 @@
|
||||
-- ANSI scheme from iTerm2-Color-Schemes as converted to hex
|
||||
-- NOTE: This does not actually represent what iTerm2 shows
|
||||
-- but rather what is shown here:
|
||||
-- https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/ghostty/Wombat
|
||||
local lush = require("lush")
|
||||
local hsl = lush.hsl
|
||||
|
||||
-- ANSI terminal colors
|
||||
return {
|
||||
black = hsl("#000000"),
|
||||
red = hsl("#ff615a"),
|
||||
green = hsl("#b1e969"),
|
||||
yellow = hsl("#ebd99c"),
|
||||
blue = hsl("#5da9f6"),
|
||||
magenta = hsl("#e86aff"),
|
||||
cyan = hsl("#82fff7"),
|
||||
white = hsl("#dedacf"),
|
||||
|
||||
bright_black = hsl("#313131"),
|
||||
bright_red = hsl("#f58c80"),
|
||||
bright_green = hsl("#ddf88f"),
|
||||
bright_yellow = hsl("#eee5b2"),
|
||||
bright_blue = hsl("#a5c7ff"),
|
||||
bright_magenta = hsl("#ddaaff"),
|
||||
bright_cyan = hsl("#b7fff9"),
|
||||
bright_white = hsl("#ffffff"),
|
||||
|
||||
foreground = hsl("#dedacf"),
|
||||
background = hsl("#171717"),
|
||||
|
||||
cursor = hsl("#bbbbbb"),
|
||||
cursor_text = hsl("#ffffff"),
|
||||
|
||||
selection_background = hsl("#453b39"),
|
||||
selection_foreground = hsl("#b6bbc0"),
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
-- Define the base color palet for wombat
|
||||
local lush = require("lush")
|
||||
local hsl = lush.hsl
|
||||
|
||||
local M = {}
|
||||
|
||||
-- ANSI terminal colors
|
||||
M.black = hsl("#000000")
|
||||
M.red = hsl("#ff615a")
|
||||
M.green = hsl("#b1e969")
|
||||
M.yellow = hsl("#ebd99c")
|
||||
M.blue = hsl("#5da9f6")
|
||||
M.magenta = hsl("#e86aff")
|
||||
M.cyan = hsl("#82fff7")
|
||||
M.white = hsl("#dedacf")
|
||||
|
||||
M.bright_black = hsl("#313131")
|
||||
M.bright_red = hsl("#f58c80")
|
||||
M.bright_green = hsl("#ddf88f")
|
||||
M.bright_yellow = hsl("#eee5b2")
|
||||
M.bright_blue = hsl("#a5c7ff")
|
||||
M.bright_magenta = hsl("#ddaaff")
|
||||
M.bright_cyan = hsl("#b7fff9")
|
||||
M.bright_white = hsl("#ffffff")
|
||||
|
||||
M.foreground = hsl("#dedacf")
|
||||
M.background = hsl("#171717")
|
||||
|
||||
M.cursor = hsl("#bbbbbb")
|
||||
M.cursor_text = hsl("#ffffff")
|
||||
|
||||
M.selection_background = hsl("#453b39")
|
||||
M.selection_foreground = hsl("#b6bbc0")
|
||||
|
||||
return M
|
33
lua/wombat/ansi_iterm2.lua
Normal file
33
lua/wombat/ansi_iterm2.lua
Normal file
@ -0,0 +1,33 @@
|
||||
-- ANSI scheme using hex values pulled from iTerm2's Wombat theme
|
||||
local lush = require("lush")
|
||||
local hsl = lush.hsl
|
||||
|
||||
-- ANSI terminal colors
|
||||
return {
|
||||
black = hsl("#000000"),
|
||||
red = hsl("#f08072"),
|
||||
green = hsl("#c6e889"),
|
||||
yellow = hsl("#ecdfb1"),
|
||||
blue = hsl("#7fb7f2"),
|
||||
magenta = hsl("#e08cf8"),
|
||||
cyan = hsl("#aafaf7"),
|
||||
white = hsl("#e4e1d8"),
|
||||
|
||||
bright_black = hsl("#404040"),
|
||||
bright_red = hsl("#eca395"),
|
||||
bright_green = hsl("#e6f6a9"),
|
||||
bright_yellow = hsl("#f0e9c3"),
|
||||
bright_blue = hsl("#b9d1fb"),
|
||||
bright_magenta = hsl("#debefa"),
|
||||
bright_cyan = hsl("#cefcf9"),
|
||||
bright_white = hsl("#fefefe"),
|
||||
|
||||
foreground = hsl("#e4e1d8"),
|
||||
background = hsl("#1e1e1e"),
|
||||
|
||||
cursor = hsl("#c7c7c7"),
|
||||
cursor_text = hsl("#feffff"),
|
||||
|
||||
selection_background = hsl("#554c49"),
|
||||
selection_foreground = hsl("#c3c7ca"),
|
||||
}
|
@ -1,37 +1,34 @@
|
||||
-- Define the base color palet for wombat
|
||||
-- Define the base color pallet for wombat
|
||||
local lush = require("lush")
|
||||
local hsl = lush.hsl
|
||||
|
||||
local c_step = 20
|
||||
|
||||
local M = {}
|
||||
return {
|
||||
black = hsl("#000000"),
|
||||
red = hsl("#ff786c").darken(c_step),
|
||||
green = hsl("#95e454"),
|
||||
yellow = hsl("#efdeab"),
|
||||
blue = hsl("#6eb9f8"),
|
||||
magenta = hsl("#ee87ff"),
|
||||
cyan = hsl("#90fdf8"),
|
||||
white = hsl("#e4e0d7"),
|
||||
|
||||
M.black = hsl("#000000")
|
||||
M.red = hsl("#ff786c").darken(c_step)
|
||||
M.green = hsl("#95e454")
|
||||
M.yellow = hsl("#efdeab")
|
||||
M.blue = hsl("#6eb9f8") -- 256mod #88b8f6
|
||||
M.magenta = hsl("#ee87ff")
|
||||
M.cyan = hsl("#90fdf8")
|
||||
M.white = hsl("#e4e0d7")
|
||||
bright_black = hsl("#313131"),
|
||||
bright_red = hsl("#ff786c"),
|
||||
bright_green = hsl("#bde97c"),
|
||||
bright_yellow = hsl("#ffffd7"),
|
||||
bright_blue = hsl("#6eb9f8").lighten(c_step),
|
||||
bright_magenta = hsl("#ee87ff").lighten(c_step),
|
||||
bright_cyan = hsl("#90fdf8").lighten(c_step),
|
||||
bright_white = hsl("#ffffff"),
|
||||
|
||||
M.bright_black = hsl("#313131")
|
||||
M.bright_red = hsl("#ff786c")
|
||||
M.bright_green = hsl("#bde97c") -- 256mod #cae982
|
||||
M.bright_yellow = hsl("#ffffd7")
|
||||
M.bright_blue = M.blue.lighten(c_step)
|
||||
M.bright_magenta = M.magenta.lighten(c_step)
|
||||
M.bright_cyan = M.cyan.lighten(c_step)
|
||||
M.bright_white = hsl("#ffffff")
|
||||
foreground = hsl("#e4e0d7"),
|
||||
background = hsl("#1e1e1e"),
|
||||
|
||||
-- Set some fg/bg colors
|
||||
M.foreground = hsl("#e4e0d7")
|
||||
M.background = hsl("#1e1e1e")
|
||||
cursor = hsl("#bbbbbb"),
|
||||
cursor_text = hsl("#ffffff"),
|
||||
|
||||
M.cursor = hsl("#bbbbbb")
|
||||
M.cursor_text = hsl("#ffffff")
|
||||
|
||||
M.selection_background = hsl("#574b49")
|
||||
M.selection_foreground = hsl("#c3c6ca")
|
||||
|
||||
return M
|
||||
selection_background = hsl("#574b49"),
|
||||
selection_foreground = hsl("#c3c6ca"),
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Define the base color palet for wombat
|
||||
-- Define the base color pallet for wombat extending from ansi colors
|
||||
local M = {}
|
||||
|
||||
function M.from_ansi(ansi_colors_name)
|
||||
@ -7,7 +7,7 @@ function M.from_ansi(ansi_colors_name)
|
||||
|
||||
local c_step = 20
|
||||
|
||||
local ansi_colors = require("wombat." .. ansi_colors_name)
|
||||
local ansi_colors = require("wombat.ansi_" .. ansi_colors_name)
|
||||
local c = ansi_colors
|
||||
|
||||
-- Add dark color variants not in pallet
|
||||
|
18
lua/wombat/init.lua
Normal file
18
lua/wombat/init.lua
Normal file
@ -0,0 +1,18 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup(opts)
|
||||
M.ansi_colors_name = opts["ansi_colors_name"]
|
||||
end
|
||||
|
||||
function M.set_colorscheme(colors_name, theme_module, default_ansi_colors_name)
|
||||
vim.g.colors_name = colors_name
|
||||
|
||||
package.loaded["lush_theme.lush_template"] = nil
|
||||
|
||||
-- Use the ansi colors that the user sets on setup, or use the default
|
||||
local ansi_colors_name = (M.ansi_colors_name or default_ansi_colors_name or theme_module.default_ansi_colors_name)
|
||||
|
||||
require("lush")(theme_module.with_ansi(ansi_colors_name))
|
||||
end
|
||||
|
||||
return M
|
Loading…
x
Reference in New Issue
Block a user