Open jessekempf opened 6 years ago
Also manually invoking Run stylish-haskell
invokes Brittany instead of Stylish-Haskell.
Clarification of the above
Because stylish-haskell
plugin has been updated to use VSCode formatting API it is now conflicting with the other formatters people may have.
@newhoggy (and myself) is using Haskell IDE Engine which registers itself as a formatter for VSCode. So VSCode's Format Document/Format Selection
is now calling to HIE.
What makes it more confusing is that Run Stylish Haskell
command now does not actually run stylish-haskell
anymore. It executes stylishHaskell.runOnCurrent
which resolves to vscode.commands.executeCommand("editor.action.formatDocument");
: https://github.com/vigoo/stylish-haskell-vscode/commit/5c146ad273e4bcb3048facba0c104c11ce980177#diff-45327f86d4438556066de133327f4ca2R134
This means that in @newhoggy's case it actually executes HIE and not stylish-haskell
.
I think this change is rather unfortunate and, even if we want to hook stylish-haskell
to the formatting API, the Run Stylish Haskell
command should still run stylish-haskell
explicitly and not defer to editor.action.formatDocument
.
Because Format Document
and Format Selection
commands already exist in VSCode, having yet another one doing the same (calling editor.action.formatDocument
) seems to be redundant. But if Run Stylish Haskell
would still call to stylish-haskell
"no matter what" then it would be useful.
As for the issue @jessekempf is having, there is an option in VSCode to enable formatting on save: "editor.formatOnSave": false|true
. Enabling it would allow VSCode to call editor.action.formatDocument
on each save. And, if you are lucky (I am not) it ends up being handled by stylish-haskell
:)
This works for me actually:
https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave
{
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.hs$",
"cmd": "stylish-haskell -i ${file}"
}
]
}
}
Thanks, this works for me too :)
Makes stylish-haskell
plugin redundant though ;)
Sorry for the bad release and thank you for the investigation, I will try to find some time and figure out the best way to solve it.
Related issue in HIE plugin: https://github.com/alanz/vscode-hie-server/issues/79
Alternative workaround to one proposed by @newhoggy is to create a task (in tasks.json
)
{
"label": "stylish-haskell",
"type": "shell",
"command": "stylish-haskell -i ${relativeFile}",
"problemMatcher": [],
"presentation": {
"reveal": "never",
}
}
Then one may add a keyboard shortcut to keybindings.json
{
"key": "ctrl-s",
"command": "workbench.action.tasks.runTask",
"args": "stylish-haskell"
}
This is not automatic though.
Last night I was using VSCode and the stylish-haskell extension automatically reformatted my code on save.
This morning there was no automatic code formatting on save. After a bit of troubleshooting I figured out how to downgrade VSCode extensions and installed version 0.0.9 of the extension. Automatic reformatting worked again.
I'm using VSCode 1.26.1 (SHA 493869ee8e8a846b0855873886fc79d480d342de). There was no error output in the developer tools javascript console, so I am unsure of how to proceed in debugging.