I also struggled to have the formatter automatically running in a consistent way and noticed mix format
does the trick, so just went ahead and created a manual task and keybinding to move on for now until I can get time to revisit the issue.
In tasks.json
{
"label": "mix format",
"type": "shell",
"command": "mix",
"args": [
"format",
"${file}"
],
"presentation": {
"echo": false,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false
}
},
and in keybindings.json
{
"key": "shift+alt+f",
"command": "workbench.action.tasks.runTask",
"args": "mix format",
"when": "editorTextFocus && editorLangId =~ /html-eex|elixir|phoenix-heex/"
},