You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Manage? Match?) .cabal info of file to format, from directory path of project, while using --stdin-input-file, when the name of file is not available.
#1055
Closed
0rphee opened this issue
Jul 24, 2023
· 2 comments
(I posted this issue originally in the fourmolu repo: fourmolu/fourmolu#353, but I was redirected here)
In order to auto-format my files with my editor, fourmolu needs to support stdin input, which it does. Nevertheless, to correctly format from stdin, fourmolu needs to be run with the path to the file that is being fed through stdin: fourmolu --stdin-input-file /Main.hs. However, unfortunately my editor doesn't support any means to extract the name of the file to be formatted, and use it with the formatter at the moment (or for that matter, any other command). I tried passing the value of $(pwd) and though fourmolu can find the .cabal file, because in that file it doesn't find the directory as a source file, it fails to account for GHC extensions when formatting from stdin.
Now, because fourmolu knows which extensions are on/off through the cabal info, I thought that perhaps, in cases where the name of the file cannot be given to fourmolu directly, it would be possible to parse the module name, and through it, find a matching source file name in the cabal info. (I understand that it may not be a reasonable option).
A less accurate way to "solve" this issue, could be, enable all extensions mentioned anywhere in the .cabal file...
The text was updated successfully, but these errors were encountered:
0rphee
changed the title
(Manage? Match) .cabal info of file to format, from directory path of project, while using --stdin-input-file, when the name of file is not available.
(Manage? Match?) .cabal info of file to format, from directory path of project, while using --stdin-input-file, when the name of file is not available.
Jul 24, 2023
This seems to be the upstream issue to add the relevant feature to helix: helix-editor/helix#3596
The issue lists other formatters (like prettier) that would also benefit from this feature, so it seems simpler to implement this in helix than to patch all formatters that have a feature like this. We could reconsider this if helix does not want to implement this feature, but right now, it doesn't seem like it, e.g. there already as a PR implementing that feature with recent activity: helix-editor/helix#5626
As another alternative, you could use Ormolu via HLS which should provide Ormolu (≥0.5.3.0) with the relevant context, cf. haskell/haskell-language-server#3449.
(I posted this issue originally in the fourmolu repo: fourmolu/fourmolu#353, but I was redirected here)
In order to auto-format my files with my editor, fourmolu needs to support stdin input, which it does. Nevertheless, to correctly format from stdin, fourmolu needs to be run with the path to the file that is being fed through stdin: fourmolu --stdin-input-file /Main.hs. However, unfortunately my editor doesn't support any means to extract the name of the file to be formatted, and use it with the formatter at the moment (or for that matter, any other command). I tried passing the value of $(pwd) and though fourmolu can find the .cabal file, because in that file it doesn't find the directory as a source file, it fails to account for GHC extensions when formatting from stdin.
Now, because fourmolu knows which extensions are on/off through the cabal info, I thought that perhaps, in cases where the name of the file cannot be given to fourmolu directly, it would be possible to parse the module name, and through it, find a matching source file name in the cabal info. (I understand that it may not be a reasonable option).
A less accurate way to "solve" this issue, could be, enable all extensions mentioned anywhere in the .cabal file...
Here are some (maybe) relevant lines regarding the found .cabal file, but without a valid file name in it.
fourmolu:
https://github.com/fourmolu/fourmolu/blob/47a40bb54f929bdd0fa1dd8d4ff4403bc4c26d72/app/Main.hs#L165C7-L174
ormolu:
https://github.com/tweag/ormolu/blob/cb93ebded6203d7696c080e608d2e6fe48bdac12/app/Main.hs#L92C13-L101C38
Anyways, thank you in advance for any help!
The text was updated successfully, but these errors were encountered: