improve docs

This commit is contained in:
Michael Chris Lopez
2021-10-11 11:18:09 +08:00
parent f2735033f5
commit 059586d542

View File

@@ -85,7 +85,9 @@ print(theme.StatusLine.bg.hex)
print(palette.blossom.darken(20).hex) print(palette.blossom.darken(20).hex)
``` ```
Here's an example of how to extend/override some highlights: Here's an example of how to extend/override some highlights.
`lua/customize_zenbones.lua`:
```lua ```lua
local function customize_zenbones() local function customize_zenbones()
@@ -96,19 +98,20 @@ local function customize_zenbones()
local lush = require "lush" local lush = require "lush"
local base = require "zenbones" local base = require "zenbones"
-- Create some specs
local specs = lush.parse(function() local specs = lush.parse(function()
return { return {
TabLine { base.TabLine, gui = "italic" }, -- setting gui to "italic" TabLine { base.TabLine, gui = "italic" }, -- setting gui to "italic"
}
end) end)
-- Apply specs using lush tool-chain
lush.apply(lush.compile(specs)) lush.apply(lush.compile(specs))
end end
return customize_zenbones return customize_zenbones
``` ```
And then somewhere in your config: And then somewhere in your `init.vim`:
```vim ```vim
autocmd VimEnter,ColorScheme * lua require("customize_zenbones")() autocmd VimEnter,ColorScheme * lua require("customize_zenbones")()
@@ -121,7 +124,7 @@ more options.
### Create your own colorscheme ### Create your own colorscheme
You can ultimately create your own colorscheme that is based on Zenbones by You can ultimately create your own colorscheme that is based on Zenbones by
modifying the base palette and extending the specs. Best way to demonstrate this defining a palette and generating a specs. Best way to demonstrate this
is through an example. Let's make a zenbones-flavored Gruvbox colorscheme called is through an example. Let's make a zenbones-flavored Gruvbox colorscheme called
`gruvbones`. `gruvbones`.
@@ -130,17 +133,17 @@ Let's define our
`nvim/colors/gruvbones.lua`. And it contains the following: `nvim/colors/gruvbones.lua`. And it contains the following:
```lua ```lua
vim.g.colors_name = "gruvbones" vim.g.colors_name = "gruvbones" -- Required when defining a colorscheme
local lush = require "lush" local lush = require "lush"
local hsluv = lush.hsluv -- human-friendly hsl local hsluv = lush.hsluv -- Human-friendly hsl
local util = require "zenbones.util" local util = require "zenbones.util"
-- let's base bg=dark, bg=light on zenflesh, zenbones specs respectively -- Let's base bg=dark, bg=light on zenflesh, zenbones specs respectively
local base_name = util.bg_to_base_name() local base_name = util.bg_to_base_name()
-- create a palette. Use palette_extend to fill unspecified colors -- Define a palette. Use `palette_extend` to fill unspecified colors
-- based on https://github.com/gruvbox-community/gruvbox#palette -- Based on https://github.com/gruvbox-community/gruvbox#palette
local palette local palette
if base_name == "zenbones" then if base_name == "zenbones" then
palette = util.palette_extend({ palette = util.palette_extend({
@@ -166,11 +169,11 @@ else
}, "zenflesh") }, "zenflesh")
end end
-- generate the lush specs using the generator util -- Generate the lush specs using the generator util
local generator = require(base_name .. ".specs") local generator = require(base_name .. ".specs")
local base_specs = generator.generate(palette, generator.get_global_config(base_name)) local base_specs = generator.generate(palette, generator.get_global_config(base_name))
-- optionally extend specs using Lush -- Optionally extend specs using Lush
local specs = lush.extends({ base_specs }).with(function() local specs = lush.extends({ base_specs }).with(function()
return { return {
Statement { base_specs.Statement, fg = palette.rose }, Statement { base_specs.Statement, fg = palette.rose },
@@ -179,10 +182,10 @@ local specs = lush.extends({ base_specs }).with(function()
} }
end) end)
-- include our theme file and pass it to lush to apply -- Pass the specs to lush to apply
lush(specs) lush(specs)
-- optionally, set term colors -- Optionally set term colors
require("zenbones.term").apply_colors(palette) require("zenbones.term").apply_colors(palette)
``` ```