GithubHelp home page GithubHelp logo

Theme configuration about lush.nvim HOT 8 CLOSED

rktjmp avatar rktjmp commented on June 12, 2024
Theme configuration

from lush.nvim.

Comments (8)

rktjmp avatar rktjmp commented on June 12, 2024 1

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.

rktjmp avatar rktjmp commented on June 12, 2024

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.

rktjmp avatar rktjmp commented on June 12, 2024

@kunzaatko

from lush.nvim.

kunzaatko avatar kunzaatko commented on June 12, 2024

OK, so the structure with this would be to:

  1. make the base theme
  2. Make a table with the extensions (through some conditions) like so: {base, extensions...}
  3. 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.

rktjmp avatar rktjmp commented on June 12, 2024

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.

kunzaatko avatar kunzaatko commented on June 12, 2024

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.

rktjmp avatar rktjmp commented on June 12, 2024

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.

kunzaatko avatar kunzaatko commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.