• Beware of 'require' at startup in Neovim plugins

    Recently I tagged version 0.9.1 of rainbow-delimiters.nvim. This update got rid of one really nasty mistake I had been dragging along from the very beginning until just recently: every time you started up Neovim a number of require calls would run even if you never called require a single time yourself. In this post I would like to go over how this happened, why it is bad and how I got rid of it. Even though I am using rainbow-delimiters as an example here, everything I am about to say applies to other plugins as well.

    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…

  • Neovim plugin settings with Lua metatables

    A lot of new Neovim plugins come with a setup function which lets you specify the settings of the plugin. Users are expected to call that function with a table as arguments which contains the user's personal settings to override the defaults. This works, but Lua is all about tables, so let's look at an alternative.

    Continue reading…