💾 Archived View for gemini.ctrl-c.club › ~tjp › gemlog › 2022-06-29-neovim-lua.gmi captured on 2022-07-17 at 05:02:31. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
I ported all my vim configs to lua over the weekend and I've never been happier with them.
It's mostly a lateral move, and was rather a lot of work to have my editor function exactly the same, albeit with a loading speed improvement beneath the level of perceptibility.
But the major sea change is that it now *feels changeable*. Vimscript is the ostensibly-a-programming-language that every vim user needs (and learns the bare minimum) but nobody uses on the regular. It doesn't even behave like any programming language we developers do use on a daily basis, because it's such an editor configuration DSL. Changing things in my vimscript configs was always a matter of consulting the documentation for all the things I've forgotten since the last edit, and then mostly banging on it until it appeared to work. Then of course it would frequently break when met with inputs I hadn't initially tested with.
But lua is a proper programming language. I intuitively understand how to break code apart into useful functions and modules. Of course I could write vimscript functions, but they were quirky. I could break configs out into separate files, but the only way to include them was with the shell-like "source", essentially eval-ing the other file in place. Lua on the other hand exposes separate files as *modules*, and within those you can make decisions about what becomes part of the public API and what does not.
Granted, so far I haven't made very full use of these capabilities, since it was already a fairly sizable task just to port vimscript to lua 1-for-1 (but I did break it into separate topical files that makes them all much more digestable as a reader). But even being a language that supports such a refactor, under language constructs that behave like I expect, makes it feel entirely different.
I highly recommend making that jump, even if you don't have any particular configuration improvement to tackle simultaneously. With any sort of background in programming, it'll give you a fresh feeling that your editor is now far more configurable than before.