Fork me on GitHub
#practicalli
<
2023-03-15
>
Drew Verlee22:03:22

@jr0cket what manages the clojure style rules (indentation, etc...)? Is it lsp or clojure or both?

practicalli-johnny11:03:10

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.

practicalli-johnny11:03:33

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

practicalli-johnny11:03:35

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

Drew Verlee02:03:52

@jr0cket i'll take a look tomorrow. Thanks for the suggestion!