Fork me on GitHub

is there a way to set up a more opinionated clojure formatter? I have no idea how to format my code


I mean, I am already using whatever formatter calva is using by default, but this formatter lets you make lots of choices about how to indent / split lines. I'd like something that doesn't let me make any choices and just formats by default

❤️ 1

Calvas formatter just formats with its defaults. I think most people just run with them. Or am I misunderstanding the issue here?


Yeah, I mean for example Prettier splits lines the way it wants to, and doesn't leave you a choice, whereas using the Calva formatter, I can insert line breaks wherever I want and they are respected. As a noob, this means I am formatting my code badly because I don't really know where to put the line breaks


So long as the closing brackets at the end of an expression are all on the same line, I wouldn't worry about anything else. Make it readable for yourself and focus on understand the language and idioms If you work with a Clojure team, they will share there on particularly biases on formatting (and other idioms) If you wish for examples, look at other people's code or take a look at the Clojure style guide. Or use cljfmt with all the options on if you don't want a choice in how your code is formatted (I found cljfmt makes code harder to read and work with untill I switch of most of the options)

👍 1

I see. cljfmt follows community guidelines, and those do not have an opinion on where to break lines. You can run zprint on your files though. It can be configured to break lines and a lot of things. Don't think it has an opinion though, like cljfmt has. But they will be largely compatible around line breaks, since cljfmt never adds any or joins a line with code on it.

👍 2

(Except for folding the paren trail, as @U05254DQM mentions.)

Daniel Shriki16:05:31

my program crashes without errors / logs only when I run it with java -server -jar main.jar but works perfectly when I run it from intellij / repl. any idea how to debug? I know it’s related to one of my states defined with mount/defstate. but it’s hard to know what the source.


To investigate what @U0NCTKEV8 and @U7RJTCH6J said: can you show us the code for: 1. namespace declaration of your entry file 2. declaration of your -main function in that file 3. how you build the jar (shell/build command)

Daniel Shriki07:05:06

@U7RJTCH6J @U0NCTKEV8 @U01EFUL1A8M thnx for the replies, your questions alone helped me to think 🙏 Regarding building jar - I build with a script:

clojure -A:aot

if [[ $? -ne 0 ]]
    echo "Could not compile project."
    exit 1

echo "Project compiled. Creating an uberjar for the project"

clojure -A:uberjar

if [[ $? -ne 0 ]]
    echo "Could not create uberjar for the project."
    exit 1
Regarding the main function, I had it without try/catch block originally:
(defn -main [& _args]
    (catch Exception e
      (log/error "Exception during mounting resources! \n" e))))
after adding the above, he exist with java.lang.RuntimeException: could not start [#'bean-counter.backend.feature-flag.service/appconfigdata] due to It happens only when I run the jar, and in repl/intelij it run smoothly


if there are no errors or logs is it crashing or just exiting?


the jvm has many threads, one of which is the "main" thread, where exceution of your program starts, when the main thread ends, and if there are no other non-daemon threads running, the jvm will just exit


when running in a repl, often the repl is running in the main thread


so that keeps the process running, however if you are running outside the repl, and don't keep the main thread running/don't have non-daemon threads, the process will just exit


How do you build the jar?


🧵 Please people...

👍 3