1

How can I add a custom formatter that will be picked up by doom-emacs' format ((format +onsave)) module?

I want to run the erlfmt program on save when editing Erlang files, but I'm not sure how I should configure that.

Doom seems to be using https://github.com/lassik/emacs-format-all-the-code under the hood, so I tried adding the following to config.el:

(define-format-all-formatter erlfm
  (:executable "erlfm")
  (:install (macos "brew install erlfmt"))
  (:languages "Erlang"
  (:format (format-all--buffer-easy executable "-")))

However, this just gives me the error “Don't know how to format erlang-mode code” when I run format-all-buffer. (I get the same error if I change to :languages "erlang-mode".)

beta
  • 131
  • 6

1 Answers1

2

In the end, putting the following in config.el worked:

(set-formatter! 'erlfmt  "erlfmt -" :modes '(erlang-mode))
beta
  • 131
  • 6