Comments (5)
lush(...)
already infers on table && table.__lush && table.__lush.type == "parsed_lush_spec"
, so we would either
- be checking the table didn't have those keys, or
- or have a
lush.new_config()
which returns a map with type information - or you call
lush.with_config()
or similar
from lush.nvim.
I have a theme, it has two styles, regular and no italics, how do I build this?
spec into extends(spec).with(group = {spec.group, gui = "" or gui = spec.group.gui.rep(italic, "")
I have a theme, it has two styles, subzero and scorpion. It is a direct palette swap.
lush.inject(palette).with( normal fg = palette.normal.fg, bg = palette.color1)
I have a theme, it has two styles, lake and ocean, ocean is generally the same as lake but some colors are darker and a few groups change.
Get lake as parsed spec, ocean extends lake and just fiddles which groups it needs to.
Two styles, light and dark. Half the specs are shared half are not.
Palettes should conform to some agreed shape, probably have three specs
- base (never exposed to end user) probably just the raw function that accepts a palette
- light
- dark
Define palettes
-- norm and comment are different colors but are applied the same
-- no matter which spec
-- light_palette.lua -- dark_palette.lua
light = { dark = {
norm = hsl(blue), norm = hsl(dark_blue),
comment = hsl(red) comment = hsl(dark_red),
light_tone = hsl(green) dark_tone = hsl(orange)
} }
Define base
-- base.lua
return function(palette)
Normal { fg = palette.norm },
Comment { fg = palett.comment }
end
Define light
-- light.lua
-- get palette
palette = require("lush_theme.ld.light_palette")
-- get base generator
base_fn = require("lush_theme.ld.base")
-- apply palette to base
base_spec = lush.inject(palette).with(base_fn)
-- extend base for light specifics
return lush.extends(base_spec).with(function()
CursorLine { bg = palette.light_tone },
Search { base.Normal, fg = base.Normal.fg.lighten(20) }
end)
Define dark
-- dark.lua
-- get palette
palette = require("lush_theme.ld.dark_palette")
-- get base generator
base_fn = require("lush_theme.ld.base")
-- apply palette to base
base_spec = lush.inject(palette).with(base_fn)
-- extend base for light specifics
return lush.extends(base_spec).with(function()
CursorLine { bg = palette.dark_tone },
Search { base.Normal, fg = base.Normal.fg.darken(20) }
end)
Important, both light.lua and dark.lua return valid specs, so they can be used with extends by an end user. A lush spec file should always return a lush spec, fully formed.
Now either colors.vim checks some config val
" colors.vim
if g:ld_style == "light" then
lua require("lush")(require("lush_theme.ld.light")
else
lua require("lush")(require("lush_theme.ld.light")
end
OR, there is a third "spec" that does the same thing in lua and returns the real spec.
-- light_or_dark.lua
return require("lush_theme.ld."..vim.g.ld_style)
-- colors.vim
lua require("lush")(require("lush_theme.ld.light_or_dark")
from lush.nvim.
The split files starts to break :Lushify
, buit fwatch can actually fix this for us, probably :LushifyDir
and just bang lush on every file change? Needs to do the unwatch/rewatch shuffle for vims save style.
from lush.nvim.
This is an interesting feature for me. I'm building some spin-offs to zenbones but my solution so far is "monkey-patching" the palette module used in generating the specs. It technically works but it's ugly and probably a maintenance hell.
It can probably be worked around by wrapping things into functions that can generate palettes or specs.
local function generate_specs(palette)
return lush(function()
return {
Normal { fg = palette.fg }
}
end)
end
lush(generate_specs({ fg = lush.hsl(0, 0, 0) }))
from lush.nvim.
My idea for backwards compatibility: in addition to colors that can be stringified, we can have a function that accepts a dependency table.
Of course there should be a helper to make it easy:
local function InjectableColors()
return setmetatable({}, {
__index = function(_, key)
return function(deps) return deps[key] end
end,
})
end
local colors = InjectableColors()
local parsed = lush(function()
return {
HighlightA = colors.blue, -- function that can accept a dependency later on
HighlightB = hsl("#dadada"), -- can be stringified directly
}
end)
lush(parsed) -- errors, because dependency is still missing
parsed.inject { blue = hsl("#3238a8") } -- associate this table as a dependency for this spec
lush(parsed) -- injectable color objects will now be resolved here using the table above
parsed.inject { blue = hsl("#16c4f7") } -- re-injection is possible
lush(parsed)
What do you think of this workflow?
from lush.nvim.
Related Issues (20)
- Unreliable Lushify behaviour HOT 1
- Using new Treesitter groups/tags HOT 4
- How to specify treesitter highlight groups? HOT 2
- How to define treesitter `@x.y` groups HOT 14
- Transparent function HOT 4
- separate colors for keywords and brackets in JavaScript? HOT 3
- Theme the nvim-cmp HOT 2
- `:LushImport` broken HOT 5
- `:Lushify` doesn't work with `lush.extends()` HOT 2
- Built-in support for `g:terminal_color_*` variables HOT 1
- Following the guide to configure an existing theme removes icon colors HOT 7
- Changing boilerplate `sed` code results in error in Mac HOT 4
- `Cursor` highlight group appears not to be working HOT 1
- HSV support ? HOT 2
- `LushImport` doesn't work and errors saying bad argument HOT 3
- slow startup time HOT 8
- Cannot add colour variation for filetype sh HOT 4
- Add warning in :LushRunTutorial to avoid loss of work with naive `:w`'s HOT 1
- Error `bad argument #1 to 'unpack' (table expected, got nil)` HOT 8
- altfont style support is missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lush.nvim.