• Debugging Lua scripts running in Neovim

    In a previous blog post I wrote about testing Lua scripts in Neovim using the busted test framework. Today I want to look at how to debug Lua scripts in Neovim using the Debug Adapter Protocol (DAP). Just as before with busted, our problem is that we need to use Neovim as our Lua interpreter because we want to use Neovim's Lua API. At the same time, the debug adapter expects the Lua interpreter to conform to Lua's command-line interface. That's right: we need another command-line interface adapter.

    Continue reading…

  • Testing Neovim plugins with Busted

    The most annoying part about writing plugins for Neovim has been the lack of a good test framework. There are a couple of frameworks, and Vader has been my favourite so far, but they all have their downsides. This made me wonder: why limit myself to Vim/Neovim test frameworks? We have a full Lua runtime, and other people already have solved the testing problem for Lua. Busted does 90% of what we need, so let's fill in the remaining 10%. The following is based on my experience with adding tests to rainbow-delimiters.nvim.

    Continue reading…

  • A pipe operator for Lua

    I have recently been getting into Elixir, and one nice feature it has is the pipe operator. It allows us to express a pipeline of function through which an object will be dragged. This got me thinking: with how flexible Lua is, would it be possible to add something similar to Lua as well?

    Continue reading…

  • Spreading tables in Lua

    Javascript has a spreading operator which lets us splice the contents of an object or array into another object or array. This makes it very easy to create an object based on another object and override or add entries. Since Lua and Javascript are quite similar, wouldn't it be nice to have this operator in Lua as well? Lua is a minimal language, so adding a new operator seems unlikely, but Lua is also very flexible, and we can add a spreading function instead.

    Continue reading…