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.

I use gopls as the language server for Go development, as well as a little language server for the beancount language to make my accounting easier.

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 " | 9p write acme/$winid/tag
		fi
	else
		# Regular file
		(
			printf " |I- |I+ "

			case "$fname" in
				*.go)
					printf "Lfmt Ldef Lrefs "
					;;
				*/go.mod)
					printf "Lws+ "
					;;
				*/COMMIT_EDITMSG|*.md)
					printf "|fmt "
					;;
			esac
		) | 9p write acme/$winid/tag
	fi
done