This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-19
Channels
- # announcements (1)
- # asami (75)
- # beginners (16)
- # calva (14)
- # cider (4)
- # clj-kondo (11)
- # cljs-dev (3)
- # clojure (110)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (38)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-sg (1)
- # clojure-spec (1)
- # clojure-taiwan (1)
- # clojure-uk (2)
- # clojurescript (34)
- # conjure (1)
- # data-science (9)
- # datahike (7)
- # datalevin (1)
- # datascript (1)
- # datomic (5)
- # etaoin (1)
- # fulcro (23)
- # graalvm (50)
- # helix (4)
- # hyperfiddle (8)
- # introduce-yourself (1)
- # jobs (3)
- # kaocha (10)
- # malli (8)
- # mid-cities-meetup (1)
- # minecraft (1)
- # off-topic (13)
- # pathom (14)
- # polylith (38)
- # reitit (1)
- # releases (1)
- # sci (65)
- # shadow-cljs (28)
- # specter (12)
- # tools-deps (8)
- # vim (1)
- # vscode (11)
- # xtdb (31)
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
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. https://guide.clojure.style/ 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)
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.
(Except for folding the paren trail, as @U05254DQM mentions.)
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)
@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 ]]
then
echo "Could not compile project."
exit 1
fi
echo "Project compiled. Creating an uberjar for the project"
clojure -A:uberjar
if [[ $? -ne 0 ]]
then
echo "Could not create uberjar for the project."
exit 1
fi
Regarding the main function, I had it without try/catch block originally:
(defn -main [& _args]
(try
(mount/start)
(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 smoothlythe 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
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?