My Acme setup

This is a short description of my Acme setup, mostly so that I don’t forget the details.

And Acme from plan9port.

LSP

I use gopls as the language server for Go development, clangd for C/C++, and rls for Rust.

Hardware

I mostly use Acme with an Evoluent VerticalMouse 4, because that makes things like the 2-1 chord easier to perform and a vertical mouse is easier on the wrist than a regular flat mouse.

If I’m not at my desk, using Acme with just the touchpad and Ctrl/Alt (on Linux) or Command/Option (on MacOS) works nicely as well.

Scripts

This is the script I use to start Acme:

#!/bin/bash

# Starts all the stuff required for Acme to work nicely

if [[ -z $(pgrep plumber) ]]; then
	9 plumber
fi

if [[ -z $(pgrep fontsrv) ]]; then
	9 fontsrv &
fi

if [[ -z "$fontsz" ]]; then
	fontsz=14
fi

acme -a -f /mnt/font/GoMono/${fontsz}a/font -F /mnt/font/GoRegular/${fontsz}a/font "$@" &

sleep 1
acmefocused &
acme-lsp &
Adefaults &

Adefaults is the following script. It adds default options to the tag line of various Acme windows, depending on the file name:

#!/bin/bash

9p read acme/log | while read line; do
	winid=$(echo "$line" | cut -d' ' -f1)
	action=$(echo "$line" | cut -d' ' -f2)
	fname=$(echo "$line" | cut -d' ' -f3-)

	if [[ "$action" != "new" ]]; then
		continue
	fi

	if [[ -d "$fname" ]]; then
		cd "$fname" >/dev/null 2>&1 || continue

		# Directory listing
		# If it's in a git repo, add a few git commands to the tag
		if git status >/dev/null 2>&1; then
			printf "Gci Gpush " | 9p write acme/$winid/tag
		fi

		cd "$HOME"
	else
		# Regular file
		(
			printf " |I- |I+ "

			case "$fname" in
				*.beancount)
					printf '[fava $%%] :$ '
					;;
				*.md|*/guide)
					printf "|fmt |Check"
					;;
				*.go)
					printf "Lfmt Ldef Lrefs "
					;;
				*/go.mod)
					printf "Lws+ "
					;;
				*.py)
					printf "[Edit ,x/	/c/    /] "
					;;
				*/COMMIT_EDITMSG)
					printf "|fmt "
					;;
			esac
		) | 9p write acme/$winid/tag
	fi
done