Comments (8)
extends.with
and merge
now in mainline cc5ba40. https://github.com/rktjmp/lush.nvim#advanced-usage
Closing this as I believe it covers it, else re-open.
from lush.nvim.
I think when extends is in mainline, that would solve this? Since everything is a module, you can do this in different files or not.
config = get_config()
-- default settings
base = lush(function()
return {
Normal { ... },
Comment { fg: ... }
}
end)
-- define the Comment group, using base.Comment but adjust for config
-- no extends, we just want to define a few groups
comments = lush(function()
return {
-- where comment_settings has been processed into the correct string (including NONE)
Comment { base.Comment, gui = config.comment_settings }
}
end)
-- prepare to generate "end spec", order matters!
combined = {base, comments}
-- maybe adjust specs as needed
if config.load_rust then table.insert(combined, require 'theme.rust') end
-- generate what vim will actually see (api may not need unpack in release)
return lush.extends(unpack(combined)).with(function()
return {
-- may have no content or may define always set but not base groups
LineNr { ... }
}
end)
from lush.nvim.
from lush.nvim.
OK, so the structure with this would be to:
- make the base theme
- Make a table with the extensions (through some conditions) like so:
{base, extensions...}
- define the final scheme with
.with(function()
return{
-- some definitions
})
I do not understand the usefulness of with
. You could rely on the base
definitions in the extensions but not on the ones in with
, but the definitions both in base
and with
are always applied... Why would I not define everything in base
, when there is no difference in it? If it is so, then why not drop the with
and only rely on extends, which would return the full spec? Sorry if I do not understand... @rktjmp
from lush.nvim.
extend()
tells lush "hey, remember these specs."
with()
says, "here's a spec, build and return it. Also merge it onto these from extend".
Without calling with()
you just have a list of specs waiting to be combined. It is functionally equivalent to lush()
but lush.extends(base, another).lush(...)
is weird to read; where as you can read this as "lush should extend these specs with this".
That's why it could be empty, it just has to be called to kick off the merge. I could make it so extends(a, b, c,)()
worked like an empty call to with, but I would rather keep the magic to a minimum, there being one API style of extends->specs->with->spec :: parsed_spec
.
The usefulness of with is for when I want to use your scheme, but some parts need changing:
nord = require('lush_theme.nord)
lush.extend(nord).with(function()
return {
-- i like nord but need brighter normal text
Normal { fg = nord.Normal.fg.li(30) },
Comment { fg = colorblind_safe_green } -- also I cant see normal color
MyPlug { ... } -- and I want my custom local plugin to mirror some nord settings.
}
end)
from lush.nvim.
Right. I understand this after the explanation. Maybe the API could be more intuitive by renaming the methods so that this logic behind it is intuitively obvious from the names.
I would suggest renaming:
.extend()
->.chain()
- and more importantly
.with()
->.collect()
What is your opinion? @rktjmp
from lush.nvim.
Not sure I agree that "extend(these specs) with(this spec)" is less intuitive than "chain(these specs)" and "collect(this spec)", esp since chain would normally be related to functions and collect to lists you want to reduce (IMO). Maybe "collect(these specs) into(this spec)".
from lush.nvim.
Well, I thought of it more like a builder style API. I was thinking about it like you have a object (a spec), you can modify it by extending it and and then collecting it into a theme. Well that is a matter of preference I guess, I just think that the chain
/extend
, collect
API is more intuitive. Maybe should I ask in #8 to get more opinions?
from lush.nvim.
Related Issues (20)
- parser.lua error HOT 3
- 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
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.