Closed carymrobbins closed 9 years ago
Tab characters in the source are generally messy. The standard specifies a tab to be (up to) 8 characters wide.
I don't think we should pay too much attention to tabs for the first release. The layout aspect of Haskell also makes automatic formatting of code difficult, so let's not aim too high with this. Dynamic tabbing for automatic indentation with the layout rule (http://dl.acm.org/citation.cfm?id=969588) documents what haskell-mode.el implemented in 1998, and I think it's still roughly the same. The manual today explicitly tells you to not use indent-region.
Sorry, I probably wasn't very clear. If someone has their General tab settings set to 2 spaces, pressing the tab key will insert two spaces. You can set it to use a tab character, but that's not what I'm referring to (because, well, that's disgusting). To have Haskell use a default of 4 spaces, regardless of the General setting, requires an entry in the Code Style section.
Would this also hook the stylish-haskell formatter to the usual "Reformat Code..." command, as opposed to the custom "Reformat Code with Stylish-Haskell"?
We're mirroring the Erlang-plugin with respect to the formatting from stylish-haskell. I don't think the idea of piping out results and repopulating the editor with the response will work very well for technical reasons. There's also the UI aspect since stylish-haskell is optional--the plugin needs to work even if it's not installed.
I don't think the idea of piping out results and repopulating the editor with the response will work very well for technical reasons.
I'm not sure I understand what you mean?
Just something to think about, since it is generally possible to switch and have multiple formatters configured; at work I have to use Eclipse formatter for my Java work, because the rest of the team have setup rules for that and it works out pretty well.
So maybe a workflow where if the user enables stylish-haskell you only then hook it up to the normal "Reformat Code..."?
Here's the link to Eclipse formatter plugin: https://github.com/krasa/EclipseCodeFormatter. I don't have a screenshot sadly, but in terms of UI, once you have multiple formatters enabled, it pops a small icon on the toolbar which allows you to switch between them.
It's probably possible to hook it as long as it's a user initiated action. Stylish-haskell operates on a temporary file that we create based on the current buffer contents, so it's not something you want to run too frequently.
Looks like pull request #87 should take care of this core issue. However, I see that @jkozlowski has brought up something slightly unrelated that should probably be broken out into its own issue.
This issue has been resolved per the mentioned pull request. Issue #88, once addressed, should provide the hooks needed to get a Reformat Code action going.
Under Preferences > Code Style we should have a Haskell section. At the very least we should have a tab setting so the user can control the behavior of the tab key (4 spaces, 2 spaces, etc.).