-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formatting ns forms #13
Comments
I don't see why not. cljfmt can already correct the indentation of an ns form, but doesn't currently order the namespaces or insert linebreaks when necessary. However, both those things would come under formatting in my book. |
Glad to hear you consider this in-scope for Here's what the
In the interest of not duplication any code I researched the following solutions when I needed to format the ns. Some of this might interest to you:
fipp which is a pretty-printer construction kit didn't work out of the box, but I now regret trying to hack my own code instead of relying on this lib. slamhound has its code for pretty-printing the ns form here. The rewriting to use prefix form drove some of these issues I had. I find the prefix form easier to read, but it's a pain to manage manually (which is why I think it isn't used more widely). I'd like libspecs that aren't vectors to be printed on their own line(s), but breaking at line 80: (:require [clojure data edn xml
[instant :as inst]
[pprint :refer [pprint]]]) I'll likely write an op for clj-refactor to call out to |
I'm not sure how much of that is in scope for cljfmt. Currently it just affects whitespace, and doesn't change the meaning of the source code. If cljfmt were to affect more, I think it would have to be controlled by an optional flag. |
Perhaps I was unclear: I just want |
Oh I see. Yes, that's perfectly within scope of cljfmt. |
Actually we might add this directly to CIDER (I can imaged commands like |
👍 |
And now we have cider commands for The initial support is pretty basic, but will cover the needs of most people. |
Very cool! |
@expez Is your issue still open? Or has it been resolved? |
@xpe this issue is still open I've written some refactorings for moving files and directories of clj files for Needless to say I'd be quite happy to skip that last step. Not only because it makes it easier but because the op becomes slow when a large amount of files are affected. |
@weavejester is this likely to get solved? I realize this isn't the most sexy problem to spend limited time on :/ |
When someone submits a pull request for it. It's not something I personally need, and isn't a bug but a new feature, so it's fairly far down my list of priorities. |
Hi, I see this was closed in a commit that mentions ns sorting. Has the formatting / pretty-printing (proper indentation, breaking of long lines in sensible places etc) been solved previously? Many thanks for your tireless and consistent maintenance of you open source projects @weavejester 🙇 |
For refactor-nrepl I made the terrible mistake of trying to write my own pretty-printing code to output the newly-cleaned ns form. This started out as just a few lines of code which worked in 95% of cases, but has now grown to a a huge mess which badly needs to be rewritten, or preferably thrown out altogether.
Will it ever be in the scope of
cljfmt
to format an ns form nicely?The text was updated successfully, but these errors were encountered: