1

I'm trying to enable autoformatting of Elm code (I guess the problem would be the same for any language). In Elm the elm-format program can normally used to format the code.

I see that there's an option in ALE to set the path of elm-format so I guess elm-format is supported by ALE. However I have no idea how to activate the option of autoformatting.

I can only see an option to set the path of elm-format, but I already have elm-format in the default path.

How do I enable the autoformatting ? Or maybe there's a key I have to type so that the code gets formatted? What key is it?

3N4N
  • 5,684
  • 18
  • 45
  • 1
    Have you read the README? – 3N4N Oct 13 '22 at 02:08
  • I had skimmed through it and had searched for something about my problem, but having no idea this feature was called "fixing" (I thought it would be called formatting or autoformatting), I had missed that section entirely. Thanks for poiting me to the right paragraph. It's working now. What I was missing was the let g:ale_fix_on_save = 1 – John Smith Optional Oct 13 '22 at 11:39
  • 2
    If you want to add an answer to the topic, I will happily accept it. – John Smith Optional Oct 13 '22 at 11:39

1 Answers1

4

You have to enable the feature of automatically formatting on save. This can be done by using :h autocmd, or with the global variable ale provides which enables it. The latter is much simpler and thus preferable.

let g:ale_fix_on_save = 1
3N4N
  • 5,684
  • 18
  • 45