This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-15
Channels
- # babashka (4)
- # beginners (136)
- # calva (63)
- # clerk (7)
- # clj-kondo (8)
- # clojure (43)
- # clojure-boston (1)
- # clojure-europe (37)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (3)
- # clojurescript (6)
- # clr (1)
- # code-reviews (16)
- # cursive (45)
- # datomic (2)
- # docker (32)
- # emacs (10)
- # events (2)
- # exercism (1)
- # fulcro (3)
- # hugsql (1)
- # hyperfiddle (47)
- # leiningen (3)
- # lsp (30)
- # malli (39)
- # missionary (1)
- # off-topic (24)
- # pathom (2)
- # portal (14)
- # practicalli (5)
- # rdf (13)
- # reagent (18)
- # reitit (18)
- # releases (7)
- # remote-jobs (1)
- # sci (2)
- # shadow-cljs (45)
- # sql (7)
- # tools-build (11)
- # xtdb (13)
@jr0cket what manages the clojure style rules (indentation, etc...)? Is it lsp or clojure or both?
Both CIDER and LSP can control the style rules, another example of cross-over between these two tools. Which tool does what depends how everything is configured... (which I dont fully understand myself)
CIDER uses clojure-mode to manage what seems to be mostly indentation. clojure-mode has its own format engine or https://docs.cider.mx/cider/usage/misc_features.html#formatting-code-with-cljfmt
Clojure LSP uses cljfmt (its fairly hard-wired into clojure-lsp binary at present) and format rules and settings can be defined in .config/clojure-lsp/config.edn
or if :cljfmt-config-path
is set on config.edn then cljfmt rules can be defined in a separate file, e.g. .config/clojure-lsp/cljfmt.edn
cljfmt seems to have https://github.com/weavejester/cljfmt#rulesregarding the overall format of a clojure file, i.e. number of blank lines between code, etc.
Personally I use https://github.com/greglook/cljstyle before finalising a commit to ensure consistency of formatting of all clojure files in the project. I also include cljstyle checks in the continuous integration workflow, using https://github.com/marketplace/actions/setup-clojure I use a https://practical.li/engineering-playbook/continuous-integration/github-workflow/#clojure-quality-check that calls clj-kondo for syntax checks, cljstyle for format and kaocha to run unit tests
I minimise the rules in cljfmt as I prefer a little more flexibility https://github.com/practicalli/clojure-lsp-config I configure cljstyle to be very similar to the cljfmt rules and indentations https://github.com/practicalli/clojure-app-template/blob/main/.cljstyle
@jr0cket i'll take a look tomorrow. Thanks for the suggestion!