Comments (3)
Hmm.
hsl
types will convert to hex when they're coerced into strings, so I would opt to call tostring
in apply_template automatically. Any value you pass in you explicitly want as a string in the template, and this lets other types with a tostring
work automatically too.
local function apply_template(template, map)
-- ensure that each replacement value is a string
local replacements = {}
for key, val in pairs(map) do
replacements[key] = tostring(val)
end
local output = string.gsub(template, "$([%w%d_]+)", replacements)
return output
end
This does mean if you pass in a table you'll get table 0xdeadbeef
instead of a lua invalid replacement
error, but I think it's probably the right step anyway.
Wonder if it's worth checking for table|function 0x\d+
as a value and warning. People who want that value explicitly could pass that in as a string if they really want it. Sometimes that kind of "smarts" can be annoying though, especially if it's applied inconsistently.
from lush.nvim.
Fixed (?) in rktjmp/shipwright.nvim@114c3a1
Not sure if it's still worth having a to_hex
transform if having templates work automatically probably covers most use cases?
If there was some other internal transform you had to do, I think you'd be operating at a point where you're already looping a whole spec and can just add .hex
to that function, or it might be working automatically if you're doing some kind of Normal.fg .. "-something-something"
?
Not a no, but a concrete usecase might be needed.
from lush.nvim.
Not sure if it's still worth having a
to_hex
transform if having templates work automatically probably covers most use cases?
No need I think and the current solution is better imo.
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.