cideM / yui

A minimal Vim/Neovim color scheme inspired by Dieter Rams
MIT License
135 stars 7 forks source link

Add conditional combinators for And, Or and Cond #39

Closed cideM closed 1 year ago

cideM commented 1 year ago

This PR first adds a stylua file and applies those formatting rules to the codebase.

Then, it adds some combinators for conditionals. There are a few places in the theme where conditionals are necessary:

All three cases were handled separately, and in an ad-hoc fashion. This resulted in duplication, and meant that every case was special. Adding any new conditional meant thinking about how to implement it, what API to use, and so on.

In the end I considered just going back to plain Vim script but that would have complicated things quite a bit. First, I don't know Vim script. And what would I have done about the current Lua code for automatically picking terminal color codes?

So I decided to double down on the Lua-to-Vim approach. It's also more fun.

I ended up adding combinators, since I'm a bit more familiar with this approach from Haskell. I also tried to take some inspiration by the elegance and simplicity of LISP macros. Meaning, code is data and you can traverse and modify these combinators like any other data structure.

I'd like to also add more combinators in the future for other Vim primitives, such as highlight groups.