nwolverson / purescript-language-server

MIT License
184 stars 42 forks source link

Sort/Clean/Format imports #68

Closed nwolverson closed 4 years ago

nwolverson commented 4 years ago

(Not sure if this can be done without a purs-ide change)

Be nice to have a reformat imports command, currently I can apply import suggestions easily, but to apply the auto ordering, the easiest thing is to tab-complete a new import then remove it.

I don't think this is the same as code formatting necessarily, as this is something already done in purs ide server, though there is certainly overlap if a formatter works on regions rather than whole files

andys8 commented 4 years ago

Now that we have purty as formatting provider: Is this issue actually about sorting? Like sorting the lines alphabetically, or the contents of explicit imports (in parens)?

This is what the emacs plugin is doing: https://github.com/purescript-emacs/purescript-mode/blob/master/purescript-sort-imports.el

kritzcreek commented 4 years ago

This is what the emacs plugin is doing

That's just a leftover copy from haskell-mode. In most files you'll find the formatting is determined by how the IDE server formats on auto-import (all unqualified imports alphabetically, then an empty line, then all the other imports alphabetically).

nwolverson commented 4 years ago

Yes, I meant to invoke the IDE server standard ordering/format/normalisation.

nwolverson commented 4 years ago

Implemented be55250327ca1c881235b6655a2cc3b5481c3d83