26 June 2022
I’ve been using the Kakoune text editor with Go for about half a
year. If you’re not familiar with it, Kakoune is a modal text editor that’s loosely based on vim,
but re-designed to make the editing commands simpler and more consistent. Making it work well with
Go required adding just a few lines to the configuration file (usually ~/.config/kak
):
try %{
source-runtime rc/tools/format.kak
}
hook global WinSetOption filetype=go %{
set-option buffer tabstop 4
set-option buffer indentwidth 0
set-option buffer formatcmd 'gofmt'
hook buffer BufWritePre .* format-buffer
}
To clear, this won’t turn Kakoune into an IDE -- for that, take a look at kak-lsp or, you know, an actual IDE. It just sets up two things:
gofmt
before saving. To make that work, the
configuration above loads the file format.kak
, which is installed with Kakoune, and
configures it to use the gofmt
command whenever a Go file is saved.