This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-11
Channels
- # announcements (3)
- # babashka (62)
- # beginners (58)
- # calva (40)
- # cider (3)
- # clj-kondo (75)
- # cljdoc (14)
- # clojars (8)
- # clojure (110)
- # clojure-australia (6)
- # clojure-europe (38)
- # clojure-hungary (1)
- # clojure-india (4)
- # clojure-italy (1)
- # clojure-nl (3)
- # clojure-spec (4)
- # clojure-uk (3)
- # clojurescript (45)
- # conjure (4)
- # cursive (35)
- # data-science (1)
- # datomic (11)
- # events (2)
- # exercism (4)
- # figwheel-main (4)
- # fulcro (103)
- # graphql (16)
- # helix (1)
- # holy-lambda (16)
- # honeysql (1)
- # introduce-yourself (3)
- # jobs (1)
- # keyboards (2)
- # lsp (4)
- # malli (11)
- # membrane-term (3)
- # mount (2)
- # nextjournal (2)
- # off-topic (53)
- # pathom (30)
- # pedestal (2)
- # portal (22)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # reitit (5)
- # remote-jobs (6)
- # shadow-cljs (20)
- # sql (8)
- # tools-build (10)
- # vim (4)
- # xtdb (12)
hey! we're using cljfmt through tools.deps, which means we use an indentation.edn
file containing what would be inside :indents
here: https://github.com/weavejester/cljfmt#configuration
is there any way to make calva read this instead of the entire :cljfmt map?
clojure-lsp has a standard of readding a .cljfmt.edn
(https://clojure-lsp.io/settings/#all-settings), Since Calva uses clojure-lsp, it could do the same.
c/c @U0ETXRFEW
hmm, isn't that for the lein-cljfmt style map instead of just the :indents?
Hum, not sure I understood, for clojure-lsp you could configure any cljfmt config on that file, including :indents
yeah, but the tools.deps version uses command line arguments, like
clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.8.0"}}}' \
-m cljfmt.main check \
--indents indentation.clj
where indentation.clj contains just the contents that would be inside :indents
. I'll probably just use the .cljfmt.edn
format and add a babashka task to convert the map to command line argsBTW, any reason why not use clojure-lsp format
instead of manually using cljfmt? (https://clojure-lsp.io/api/)
oh, this is much better
perfect!
very nice!
for linting (clj-kondo under the hood), formatting (cljfmt under the hood) and clean-ns (clojure-lsp itself)
with that you could have a common library like codestyle
and all services/libs of yours could use the same codestyle configuration
we run multiple jobs like
kondo-check:
image: "cljkondo/clj-kondo"
script:
- clj-kondo --lint src $([ -d test ] && echo "test")
fmt-check:
image: clojure:openjdk-11-tools-deps-buster
script:
- clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main --indents indentation.edn check
but that does seem better 😄the issue when you run clj-kondo to lint only src and test is that it makes kondo doesn't know the whole classpath and know hooks and custom things for other macros, this issue is fixed with clojure-lsp since it scans the classpath with kondo already
wow, clj-kondo can look for dependencies' configs?
yep :) for example, this library: https://github.com/nubank/state-flow/blob/master/resources/clj-kondo.exports/nubank/state-flow/config.edn
amazing
we just have this on our common codestyle library at nubank:
{:config-paths ["nubank/stateflow" ...]}
then clojure-lsp will already tell to kondo copy the hook and use it, understand this library macros that were configured on the library itself!
the same for midje for example: https://github.com/marick/Midje/blob/master/test-resources/clj-kondo.exports/marick/midje/config.edn
curiously enough the last piece of code I wrote at Nubank was another version of this https://github.com/nubank/state-flow/blob/master/resources/clj-kondo.exports/nubank/state-flow/nubank/state_flow.clj
In case you want to understand how this works: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration
this is awesome
yeah, I can say after we introduced codestyle
common library using all those configurations in one single place, we stopped having issues like missing lint config
all services now just use this on .clj-kondo/config.edn:
{:config-paths ["nubank/codestyle"]}
which that lib has more kondo config-paths and custom kondo config for all services and libs :)and nubank/codestyle is a lib? config-paths looks for stuff in the classpath?
yes, is just a common lib that in resources has all clj-kondo exports + clojure-lsp exports
the kondo one, search not on classpath, it search on folders :config-paths
, but it turns out that you can think on classpath since clojure-lsp will send that to be linted and clj-kondo will copy that config for your service folder
when I created that on clojure-lsp I just added support for classpath only instead of all folder support like kondo has
very very nice
I'll definitely let you know when setting this up!
Calva doesn’t use clojure-lsp for formatting, anyway, so the question in TS still is relevant. And the answer is no, Calva only knows about one cljfmt config file. You could tell it to read indentation.edn
, but then Calva wouldn’t know about your other cljfmt options. It should be quite simple to add this support though. An issue on the repo is welcome!
actually, it seems like defining all the cljfmt options in the leiningen format as it is today should be the way to go. I can then write a workaround or start using clojure-lsp to do my CI checks instead. what do you think?