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:
the different branches of option groups
if HL groups are only available in Neovim but not Vim (or vice versa)
to determine which terminal color syntax to use, since Neovim and Vim use a different API
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.
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.