GithubHelp home page GithubHelp logo

Comments (5)

rktjmp avatar rktjmp commented on June 3, 2024

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.

rktjmp avatar rktjmp commented on June 3, 2024

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.

rktjmp avatar rktjmp commented on June 3, 2024

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.

mcchrish avatar mcchrish commented on June 3, 2024

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.

musjj avatar musjj commented on June 3, 2024

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)

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.