What happened?
Nothing happened when I saved the file. However, manually invoking +buffer/format
makes wonders.
What did you expect to happen?
I would like to format yaml files with yamlfmt when saving. My elisp fu is more or less non-existent so I feel lost. I’m fond of this formatter as it’s possible to specify indentless_arrays, which treats a hyphen (-) as a space = less indentation madness.
Steps to reproduce
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
- Make a configuration file in `~/.config/yamlfmt/.yamlfmt, e.g.,:
formatter:
basic:
indentless_arrays: true
retain_line_breaks: true
- Favor the new formatter in
~/.doom.d/config.el
(setq-hook! 'yaml-mode-hook +format-with-lsp nil)
(setq-hook! 'yaml-mode +format-with 'yamlfmt)
(after! format-all
(set-formatter! 'yamlfmt
'("yamlfmt" "-")
:modes 'yaml-mode))
- Create a simple yaml file:
array:
- foo: abc
bar: cde
- baz: "abz"
- Save the file. The desired result would be (without manually calling
+buffer/format
):
array:
- foo: abc
bar: cde
- baz: "abz"
System information
Loading data dump...
I’ve tried forking emacs-format-all-the-code and added a yamlfmt formatter myself, and specified the fork as a local repository without it changing the outcome. Does anyone have a solution for how to make this work?