Tom Waddington

Parediting in Helix

I’ll level with you, I’m a long-time Clojurer but I’ve never been much of a Pareditor.

Thanks to the first-class tree-sitter support in Helix, much of the functionality provided by Paredit plug-ins in other editors has equivalents available by default. As I described in my previous post about Helix and Clojure, there are built-in motion and selection commands for navigating about the syntax tree parsed by tree-sitter.

What Helix lacks are the structural editing commands provided by Paredit – slurping, barfing, dragging, raising and splicing. Until now!

Julien Vincent’s nvim-paredit for NeoVim demonstrates a comparatively lightweight approach to Paredit, leaning on tree-sitter for parsing. Since Helix already relies on tree-sitter, this looked like a promising solution. I made an initial attempt at adding the functionality last year but, at that time, the Steel Scheme plug-in branch didn’t expose any tree-sitter bindings. Implementing everything from scratch, knowing a much simpler solution would probably be viable someday, seemed like a waste of effort, so I abandoned it.

The Steel branch gained a full set of tree-sitter bindings in February and this week I finally got around to revisiting the idea.

paredit.hx is a Helix plug-in that completes the set of Paredit operations in what I hope is a suitably Helix-ish fashion. Support is currently built-in for Clojure, Common Lisp, Fennel, Janet and Scheme.

I’ve provided suggested keybindings for normal and select modes that puts these operations under <space>.< and <space>.>, for backwards and forwards operations respectively, with the direction-agnostic operations duplicated in both. But they’re completely regular Helix commands that can be bound to any key combination you prefer, if you already have muscle memory built up from another editor.

Barfing and slurping in Helix with paredit.hx
Slurp your barf to your heart’s content.

As with my nREPL.hx plug-in, you will need to be running the Helix Steel plug-in fork to use this. But the latest word is that Steel will be landing in Helix master imminently, as soon as the ongoing and urgent workspace trust piece is finished and released.

Like I say, I’ve never been much for Paredit in the past. Previously, my preferred editor has never supported it well. So, please raise an issue if something isn’t working or I’ve missed the point of what any of these operations are intended to achieve in other editors.