Hello, hello! As my first post here, I’d like to present a little auto-pairs plugin I’ve been working on for a little while, twos.kak!
Of course, there already exists an auto-pairing plugin for Kakoune, auto-pairs.kak. It seems to work by keeping some internal state that is initialised upon opening a pair, which, notably, is lost upon exiting insert mode. I tend to jump in and out of insert mode quite frequently, and disliked the fact that inserting the same character in the same location of the same file wouldn’t always yield the same result. twos.kak addresses this by approaching the problem in a different way: through persistent hooks and checking the text surrounding the cursor to guide its behaviour.
(Of course, if this isn’t an issue for you and you’re a happy user of auto-pairs.kak, then keep using it! Unless, of course, the following points convince you to switch!)
Apart from the usual set of functionality that comes with all auto-pairing implementations, twos.kak also comes with a couple more (which can be disabled if you’d like!):
- With a cursor like this:
{|}, pressing<space>ensures there are spaces to either side of the cursor, so you end up with this:{ | } - You can insert triple-quoted strings (e.g. multiline strings in several languages) and sections surrounded by multiple backticks (e.g. codeblocks in Markdown)!
The plugin uses what it calls “conditions” to decide when it should or shouldn’t perform a given action. The default settings attempt to detect the following and act accordingly:
- backslash-escaped characters
- apostrophes (e.g.
their's) - character literals (e.g.
'"')
Conditions are also how you would go about disabling any of the extra functionality I introduced earlier if you decide that you dislike them (this actually isn’t mentioned on the README, but I shall be sure to update that at some point).
That is all! Thank you for your time!