Fork me on GitHub

That's good stuff. Will there also be an option to add a linebreaks after :require and :import? Or is there one already?


There isn’t at the moment, no - currently Cursive never touches linebreaks. I’m planning to revamp all the formatting shortly which will make all that more configurable. What exactly do you want to happen there, just to be clear?


my preference is exactly how it's in the summary at - one linebreak after :require and :import


That also seems to be the direction cider's refactor-nrepl adopted in 3.x:


Having this formatting/organization happen automatically on requiring/importing something would also be good to have


However, for me it would be important to be able to turn auto-formatting and adding newlines off for specific projects. Normally when I submit a patch to a 3rd party project, I want to make the least amount of changes. However for our internal ones where I'm (partially) in control of formatting I'll want to clean stuff up as I go.


Sure, when adding new namespaces and imports, Cursive always adds a newline at the moment. If you have two in the same line though, it won’t insert a newline when formatting.


Right now there isn’t a global “don’t do anything” switch, I’ll add one for that use case.


And yes, once this is all done and working, it will allow me to finally add things like moving stuff between namespaces, proper namespace renames, etc.


keep going Colin


I was thinking about the global disable switch, and I don’t think it’s actually required. Right now, the ns will only be modified when you invoke the Optimise Imports action. The only place that would happen automatically is if you had configured it to happen on format, on commit, or maybe some other places that IntelliJ lets you invoke it automatically. So I’m assuming that for other people’s projects, you just wouldn’t configure that, and wouldn’t invoke the action.


What I’m planning to do for the require insertion on completion is to scan through the requires, and insert the new clause before the first one that is lexicographically greater than the new one. So if your clauses are in order that should be maintained, and if they’re not you’re no worse off than you are now.


For some operations like moving things from one namespace to another, the Optimise operation will probably be invoked automatically by default on the namespace you’re moving things from, to tidy it up, and at that point it will probably make sense to have a “don’t do that” switch, even though I suspect that you will still want it in most cases anyway.