### Configuration Example with Legacy Merge Source: https://github.com/weavejester/cljfmt/blob/master/README.md An example EDN configuration snippet for cljfmt demonstrating how to enable legacy merging of indents using the `:legacy/merge-indents?` key. This is useful for maintaining backward compatibility. ```edn { :legacy/merge-indents? true :indents {example.core/foo [[:inner 0]]} } ``` -------------------------------- ### Install cljfmt Standalone Binary (Linux/MacOS) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Installs or updates the cljfmt standalone binary to /usr/local/bin for Linux and MacOS users. This provides the fastest way to run cljfmt from the command line. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/weavejester/cljfmt/HEAD/install.sh)" ``` -------------------------------- ### Install cljfmt as Clojure CLI Tool Source: https://github.com/weavejester/cljfmt/blob/master/README.md Installs cljfmt as a third-party tool for the official Clojure CLI. This allows easy invocation of cljfmt commands using the `clj -Tcljfmt` prefix. ```bash clj -Ttools install io.github.weavejester/cljfmt '{:git/tag "0.16.3"}' :as cljfmt ``` -------------------------------- ### Configuration Example with Extra Indents Source: https://github.com/weavejester/cljfmt/blob/master/README.md An example EDN configuration snippet for cljfmt showing how to append custom indents to the default settings using the `:extra-indents` key. This is equivalent to the legacy merge behavior when `:legacy/merge-indents?` is true. ```edn { :extra-indents {example.core/foo [[:inner 0]]} } ``` -------------------------------- ### Define cljfmt Configuration Options Source: https://context7.com/weavejester/cljfmt/llms.txt Provides examples of defining basic formatting options, custom indentation rules, and experimental column alignment settings within a .cljfmt.edn configuration file. ```edn {:paths ["src" "test"] :file-pattern #re "\.clj[csx]?$" :indentation? true :sort-ns-references? true :parallel? true} ``` ```edn {:extra-indents {com.example/with-transaction [[:block 0]] com.example/with-context [[:block 1]] #re "-let$" [[:block 1]] #re "^with-" [[:inner 0]]} :alias-map {ex com.example} :refer-map {my-macro com.example}} ``` ```edn {:align-map-columns? true :align-form-columns? true :max-column-alignment-gap 10 :aligned-forms {let #{0} binding #{0}}} ``` -------------------------------- ### Configure Block Indentation Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Illustrates block indentation, which switches between default and inner indentation based on whether the target argument starts a new line. ```edn {do [[:block 0]]} ``` -------------------------------- ### Install cljfmt via Homebrew Source: https://github.com/weavejester/cljfmt/blob/master/README.md Installs cljfmt using Homebrew on MacOS. It is recommended to use the 'weavejester/brew' tap for better performance compared to the core Homebrew package. ```bash brew install weavejester/brew/cljfmt ``` -------------------------------- ### Clojure CLI Tool Integration Source: https://context7.com/weavejester/cljfmt/llms.txt Install cljfmt as a Clojure CLI tool to manage project-wide formatting. This allows for parallel processing and path-specific execution. ```bash clj -Ttools install io.github.weavejester/cljfmt '{:git/tag "0.16.3"}' :as cljfmt clj -Tcljfmt check clj -Tcljfmt fix :parallel? true ``` -------------------------------- ### Check and Fix Paths with cljfmt Source: https://context7.com/weavejester/cljfmt/llms.txt Demonstrates how to programmatically check or fix formatting across directories using the cljfmt.tool namespace. It includes examples for recursive fixing and applying custom options like parallel processing. ```clojure (require '[cljfmt.tool :as fmt] '[cljfmt.report :as report]) (fmt/check {:paths ["src" "test"] :report report/clojure}) (fmt/fix {:paths ["src"] :report report/clojure}) (fmt/check {:paths ["src"] :report report/clojure :parallel? true :file-pattern #"\.clj$" :indentation? true :remove-consecutive-blank-lines? true}) ``` -------------------------------- ### Define Inner Indentation Rules Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Examples of how to define inner indentation rules for macros like defn and reify. These rules use depth levels to determine when to apply a constant two-space indentation. ```edn {defn [[:inner 0]]} {reify [[:inner 0] [:inner 1]]} ``` -------------------------------- ### Check Clojure Code Formatting (Clojure CLI Tool) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Checks Clojure code formatting using the cljfmt tool installed via the Clojure CLI. This command verifies code style consistency across the project. ```bash clj -Tcljfmt check ``` -------------------------------- ### Fix Clojure Code Formatting (Clojure CLI Tool) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Fixes Clojure code formatting errors using the cljfmt tool installed via the Clojure CLI. This command applies automatic corrections to the project's code. ```bash clj -Tcljfmt fix ``` -------------------------------- ### Load and Manage cljfmt Configuration Source: https://context7.com/weavejester/cljfmt/llms.txt Shows how to load configuration from files, find the project configuration file, and apply loaded settings to reformat strings. ```clojure (require '[cljfmt.config :as cfg] '[cljfmt.core :as fmt]) (cfg/load-config) (cfg/load-config "/path/to/project") (cfg/find-config-file) (fmt/reformat-string "(+ x\ny)" (cfg/load-config)) (cfg/read-config ".cljfmt.edn") ``` -------------------------------- ### Configuration File - Basic Options Source: https://context7.com/weavejester/cljfmt/llms.txt Defines basic formatting options configurable via a `.cljfmt.edn` file. ```APIDOC ## Configuration File - Basic Options Create a `.cljfmt.edn` or `cljfmt.edn` file in your project root with formatting options. ```edn ;; .cljfmt.edn { ;; Paths to format :paths ["src" "test"] ;; File pattern to match :file-pattern #re "\\.clj[csx]?$" ;; Core formatting options :indentation? true :remove-surrounding-whitespace? true :remove-trailing-whitespace? true :remove-consecutive-blank-lines? true :insert-missing-whitespace? true ;; Namespace sorting :sort-ns-references? true ;; Indentation style for function arguments ;; Options: :community (default), :cursive, :zprint :function-arguments-indentation :community ;; Process files in parallel :parallel? true} ``` ``` -------------------------------- ### Load Configuration Source: https://context7.com/weavejester/cljfmt/llms.txt API functions for loading cljfmt configuration from files. ```APIDOC ## Load Configuration Load configuration from config files with sensible defaults. ### Load config from current directory ```clojure (require '[cljfmt.config :as cfg]) (cfg/load-config) ``` ### Load config from specific path ```clojure (require '[cljfmt.config :as cfg]) (cfg/load-config "/path/to/project") ``` ### Find config file ```clojure (require '[cljfmt.config :as cfg]) (cfg/find-config-file) ``` ### Use loaded config with reformat-string ```clojure (require '[cljfmt.config :as cfg] '[cljfmt.core :as fmt]) (fmt/reformat-string "(+ x\ny)" (cfg/load-config)) ``` ### Read config file directly ```clojure (require '[cljfmt.config :as cfg]) (cfg/read-config ".cljfmt.edn") ``` ``` -------------------------------- ### Clojure Runtime Configuration Options Source: https://github.com/weavejester/cljfmt/blob/master/README.md These options configure the runtime behavior of cljfmt, including which files to process, whether to use parallel execution, and how to handle configuration files and paths. The file pattern can be specified as a regular expression. ```clojure { :file-pattern #"\.clj[csx]?$" :parallel? false :read-clj-config-files? false :paths ["src" "test"] } ``` ```clojure { :file-pattern #re "\\.clj[csx]?$" ; Example for edn config :paths ["-"] ; STDIN/STDOUT } ``` -------------------------------- ### Babashka Integration Source: https://context7.com/weavejester/cljfmt/llms.txt Instructions for using cljfmt with Babashka, including defining tasks. ```APIDOC ## Babashka Integration Use cljfmt from Babashka as a library or define tasks in `bb.edn`. ```edn ;; bb.edn {:deps {dev.weavejester/cljfmt {:mvn/version "0.16.3"}} :tasks { fmt:check {:doc "Check code formatting" :requires ([cljfmt.tool :as fmt]) :task (fmt/check {})} fmt:fix {:doc "Fix code formatting" :requires ([cljfmt.tool :as fmt]) :task (fmt/fix {})} fmt:check-ci {:doc "Check formatting for CI (fails on error)" :requires ([cljfmt.tool :as fmt] [cljfmt.report :as report]) :task (let [result (fmt/check {:report report/clojure})] (when (pos? (get-in result [:results :counts :incorrect] 0)) (System/exit 1)))} }} ``` ``` -------------------------------- ### cljfmt.config/load-config Source: https://github.com/weavejester/cljfmt/blob/master/README.md Loads the cljfmt configuration from the current working directory. ```APIDOC ## cljfmt.config/load-config ### Description Reads the local project configuration file to determine indentation and formatting preferences. ### Method Function Call ### Parameters None ### Request Example (cfg/load-config) ### Response #### Success Response - **config** (map) - A map containing indentation rules and other formatting options. #### Response Example {:indents {example.core/foo [[:inner 0]]}} ``` -------------------------------- ### Configure Extra Indentation Rules Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Demonstrates how to add custom indentation rules using the :extra-indents option with symbols and regular expressions. ```clojure {:extra-indents {when [[:block 1]]}} ``` ```clojure {:extra-indents {#"^with-" [[:inner 0]]}} ``` ```edn {:extra-indents {#re "^with-" [[:inner 0]]}} ``` -------------------------------- ### Configuration File - Custom Indentation Rules Source: https://context7.com/weavejester/cljfmt/llms.txt Defines custom indentation rules for macros and functions using `:extra-indents`. ```APIDOC ## Configuration File - Custom Indentation Rules Define custom indentation rules for macros and functions using `:extra-indents`. ```edn ;; .cljfmt.edn { ;; Add to default indents (recommended) :extra-indents { ;; Macro with body (like do) com.example/with-transaction [[:block 0]] ;; Macro with bindings and body (like let) com.example/with-context [[:block 1]] ;; Match any symbol ending with -let #re "-let$" [[:block 1]] ;; Match any symbol starting with with- #re "^with-" [[:inner 0]] ;; Qualified symbol matching myapp.db/with-connection [[:block 1]] ;; Vector key for namespace + name matching [com.example #re "^def"] [[:inner 0]]} ;; Map namespace aliases for qualified matching :alias-map {ex com.example db myapp.db} ;; Map referred symbols to namespaces :refer-map {my-macro com.example}} ``` ``` -------------------------------- ### Replace Default Indentation Rules Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Demonstrates how to use the :indents option to completely replace existing indentation logic with custom rules. ```clojure {:indents {#".*" [[:inner 0]]}} ``` -------------------------------- ### Aligning Map Columns with cljfmt Source: https://github.com/weavejester/cljfmt/blob/master/README.md Demonstrates how to use `:align-map-columns?` and `:max-column-alignment-gap` to align map keys and values. The `:max-column-alignment-gap` option prevents excessive horizontal padding by falling back to a single space when alignment exceeds the specified limit. ```clojure ;; Input: {{:keys [several things here]} :sub-map {:keys [several things]} :sub-map2 :keys [direct values] :as everything} ;; With :align-map-columns? true and :max-column-alignment-gap 10: {{:keys [several things here]} :sub-map ;; 1 space, aligned {:keys [several things]} :sub-map2 ;; 6 spaces, still aligned (6 <= 10) :keys [direct values] ;; 25 spaces, falls back to 1 space :as everything} ;; 27 spaces, falls back to 1 space ``` -------------------------------- ### Configure cljfmt in Leiningen Source: https://github.com/weavejester/cljfmt/blob/master/README.md Configures cljfmt within the project.clj file, including options to load external configuration files. ```clojure :cljfmt {} ``` ```clojure :cljfmt {:load-config-file? true} ``` -------------------------------- ### Configuration File - Column Alignment Source: https://context7.com/weavejester/cljfmt/llms.txt Configures experimental column alignment features for maps and binding forms. ```APIDOC ## Configuration File - Column Alignment (Experimental) Configure experimental column alignment features for maps and binding forms. ```edn { ;; Align map keys and values into columns :align-map-columns? true ;; Align binding forms (let, loop, etc.) :align-form-columns? true ;; Include single-column lines in alignment calculation :align-single-column-lines? false ;; Maximum spaces allowed between key and aligned value :max-column-alignment-gap 10 ;; Treat blank lines as alignment separators :blank-lines-separate-alignment? true ;; Custom forms to align (replaces defaults) :aligned-forms {let #{0} binding #{0} loop #{0}} ;; Add to default aligned forms :extra-aligned-forms {my-let #{0}}} ``` Example of aligned output: ```clojure ;; Input: {:short 1 :medium-key 2 :very-long-key 3} ;; Output with :align-map-columns? true: {:short 1 :medium-key 2 :very-long-key 3} ``` ``` -------------------------------- ### Define Indentation for Macro Patterns Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Provides common recipes for defining indentation rules for macros with bodies or binding vectors. ```edn {:extra-indents {com.example/foo [[:block 0]]}} ``` ```edn {:extra-indents {com.example/bar [[:block 1]]}} ``` -------------------------------- ### Check and Fix Formatting via CLI Source: https://context7.com/weavejester/cljfmt/llms.txt Use the standalone cljfmt binary to check for formatting violations or automatically apply fixes. It supports file paths, patterns, and STDIN/STDOUT streams. ```bash cljfmt check cljfmt check src/my_ns.clj test/ cljfmt fix echo "(defn foo[x](+ x 1))" | cljfmt fix - ``` -------------------------------- ### Handle Qualified Symbols with Alias and Refer Maps Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Shows how to map namespaces and referred symbols to ensure cljfmt correctly identifies and applies indentation rules to qualified symbols. ```clojure {:extra-indents {com.example/foo [[:inner 0]]} :alias-map {ex com.example}} ``` ```clojure {:extra-indents {com.example/foo [[:inner 0]]} :refer-map {foo com.example}} ``` -------------------------------- ### Leiningen Plugin Configuration Source: https://context7.com/weavejester/cljfmt/llms.txt Integrate cljfmt into a Leiningen project by adding it to the plugins list in project.clj. This enables standard lein commands for formatting. ```clojure (defproject my-project "0.1.0" :plugins [[dev.weavejester/lein-cljfmt "0.16.3"]] :cljfmt {:indentation? true :remove-consecutive-blank-lines? true}) ``` -------------------------------- ### cljfmt.core/reformat-string Source: https://github.com/weavejester/cljfmt/blob/master/README.md Formats a string of Clojure code based on default or provided configuration. ```APIDOC ## cljfmt.core/reformat-string ### Description Formats a given string of Clojure code, applying indentation and spacing rules to match the Clojure Style Guide. ### Method Function Call ### Parameters - **code** (string) - Required - The raw Clojure source code string. - **options** (map) - Optional - Configuration map loaded via cljfmt.config/load-config. ### Request Example (fmt/reformat-string "(defn sum [x y]\n(+ x y))") ### Response #### Success Response - **result** (string) - The formatted Clojure code string. #### Response Example "(defn sum [x y]\n (+ x y))" ``` -------------------------------- ### Check Clojure Code Formatting (Standalone CLI) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Checks the current project's Clojure code for formatting errors using the standalone cljfmt binary. This command reports any detected inconsistencies without modifying the files. ```bash cljfmt check ``` -------------------------------- ### Reformat Clojure String with Configuration (Library) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Reformats a Clojure code string using cljfmt, applying a specific configuration loaded from the current directory. This allows for project-specific formatting rules to be used. ```clojure (require '[cljfmt.config :as cfg]) (require '[cljfmt.core :as fmt]) (fmt/reformat-string "(+ x\ny)" (cfg/load-config)) ;; => "(+ x\n y)" ``` -------------------------------- ### Integrate cljfmt with Babashka Source: https://context7.com/weavejester/cljfmt/llms.txt Configures cljfmt as a task runner within a bb.edn file, allowing for easy formatting checks and fixes in CI/CD pipelines or local development. ```clojure {:deps {dev.weavejester/cljfmt {:mvn/version "0.16.3"}} :tasks {fmt:check {:task (fmt/check {})} fmt:fix {:task (fmt/fix {})} fmt:check-ci {:task (let [result (fmt/check {:report report/clojure})] (when (pos? (get-in result [:results :counts :incorrect] 0)) (System/exit 1)))}}} ``` -------------------------------- ### Add cljfmt Leiningen Plugin Source: https://github.com/weavejester/cljfmt/blob/master/README.md Configures the cljfmt formatter as a Leiningen plugin by adding it to the `:plugins` list in the `project.clj` file. This enables cljfmt commands within the Leiningen build process. ```clojure :plugins [[dev.weavejester/lein-cljfmt "0.16.3"]] ``` -------------------------------- ### Configure cljfmt in Babashka Source: https://github.com/weavejester/cljfmt/blob/master/README.md Defines a cljfmt task within a bb.edn file to allow formatting checks via the Babashka tool chain. ```edn {:deps {dev.weavejester/cljfmt {:mvn/version "0.16.3"}} :tasks {fmt {:doc "Check formatting with cljfmt" :requires ([cljfmt.tool :as fmt]) :task (fmt/check {})}}} ``` -------------------------------- ### Check Clojure Code Formatting (Leiningen Plugin) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Checks Clojure code for formatting errors using the cljfmt Leiningen plugin. This command is executed within a Leiningen project context. ```bash lein cljfmt check ``` -------------------------------- ### Clojure: Core Code Transformation Functions Source: https://context7.com/weavejester/cljfmt/llms.txt Demonstrates low-level cljfmt functions for granular code formatting. These functions operate on parsed Clojure code, allowing for precise manipulation such as removing whitespace, reindenting, and sorting namespace references. They require rewrite-clj for parsing and node manipulation. ```clojure (require '[cljfmt.core :as fmt] '[rewrite-clj.parser :as p] '[rewrite-clj.node :as n]) ;; Remove surrounding whitespace (-> "( foo )" p/parse-string-all fmt/remove-surrounding-whitespace n/string) ;; => "(foo)" ;; Insert missing whitespace (-> "(foo(bar))" p/parse-string-all fmt/insert-missing-whitespace n/string) ;; => "(foo (bar))" ;; Remove consecutive blank lines (-> "(foo)\n\n\n(bar)" p/parse-string-all fmt/remove-consecutive-blank-lines n/string) ;; => "(foo)\n\n(bar)" ;; Remove trailing whitespace (-> "(foo) \n" p/parse-string-all fmt/remove-trailing-whitespace n/string) ;; => "(foo)\n" ;; Sort namespace references (-> "(ns foo (:require [z] [a]))" p/parse-string-all fmt/sort-ns-references n/string) ;; => "(ns foo (:require [a] [z]))" ;; Reindent code (-> "(defn foo [x] x)" p/parse-string-all fmt/reindent n/string) ;; => "(defn foo [x] x)" ;; Normalize newlines at file end (fmt/normalize-newlines-at-file-end "(foo)\n\n\n") ;; => "(foo)\n" ``` -------------------------------- ### Clojure Code Formatting Options Source: https://github.com/weavejester/cljfmt/blob/master/README.md These options control how cljfmt formats Clojure code. They cover indentation, newline normalization, blank line handling, and whitespace removal. Some options are experimental and may have specific configuration requirements. ```clojure { :indentation? true :indents {my-var [& rules]} :normalize-newlines-at-file-end? true :remove-blank-lines-in-forms? false :remove-consecutive-blank-lines? true :insert-missing-whitespace? true :remove-multiple-non-indenting-spaces? false :remove-surrounding-whitespace? true :remove-trailing-whitespace? true :sort-ns-references? false :split-keypairs-over-multiple-lines? false } ``` -------------------------------- ### Add cljfmt Dependency as Library Source: https://github.com/weavejester/cljfmt/blob/master/README.md Adds the cljfmt library as a dependency to a Clojure project using EDN format, typically for use with tools like `deps.edn`. This allows programmatic access to cljfmt's formatting capabilities. ```edn {:deps {dev.weavejester/cljfmt {:mvn/version "0.16.3"}}} ``` -------------------------------- ### Restrict Inner Indentation by Index Source: https://github.com/weavejester/cljfmt/blob/master/docs/INDENTS.md Demonstrates restricting inner indentation rules to specific argument indices using the letfn macro. This ensures indentation is only applied to relevant code blocks. ```edn {letfn [[:block 1] [:inner 2 0]]} ``` -------------------------------- ### Programmatic String Reformatting Source: https://context7.com/weavejester/cljfmt/llms.txt Use the cljfmt.core library to reformat Clojure source code strings. This is useful for building custom tooling or automated code generation pipelines. ```clojure (require '[cljfmt.core :as fmt]) (fmt/reformat-string "(defn sum [x y]\n(+ x y))") (fmt/reformat-string "(ns foo\n (:require [z] [a] [m]))" {:sort-ns-references? true}) ``` -------------------------------- ### Check and Fix Paths Source: https://context7.com/weavejester/cljfmt/llms.txt API functions to check and fix code formatting across specified paths. ```APIDOC ## Check and Fix Paths Check or fix formatting across entire directories using the tool namespace. ### Check paths with Clojure-friendly reporting ```clojure (require '[cljfmt.tool :as fmt] '[cljfmt.report :as report]) (fmt/check {:paths ["src" "test"] :report report/clojure}) ``` ### Fix paths recursively ```clojure (require '[cljfmt.tool :as fmt]) (fmt/fix {:paths ["src"] :report report/clojure}) ``` ### With custom options ```clojure (require '[cljfmt.tool :as fmt]) (fmt/check {:paths ["src"] :report report/clojure :parallel? true :file-pattern #"\.clj$" :indentation? true :remove-consecutive-blank-lines? true}) ``` ``` -------------------------------- ### Reformat Clojure String (Library) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Reformats a given string of Clojure code using the cljfmt library. This function takes a code string as input and returns the formatted version. ```clojure (require '[cljfmt.core :as fmt]) (fmt/reformat-string "(defn sum [x y]\n(+ x y))") ;; => "(defn sum [x y]\n (+ x y))" ``` -------------------------------- ### Clojure: Indentation Rules Reference Source: https://context7.com/weavejester/cljfmt/llms.txt Explains the three types of indentation rules in cljfmt: :default, :inner, and :block. These rules control how code elements are indented based on their position and nesting level, ensuring consistent code structure. ```clojure ;; DEFAULT indentation - aligns with first argument or indents by 1 space ;; Used when no rule is specified (println "hello" ; more than one element on first line "world") ; aligns with "hello" (println ; one element on first line "hello" ; indents by 1 space "world") ;; INNER indentation [[:inner depth]] - always indents by 2 spaces ;; Depth indicates nesting level (0 = direct children) {defn [[:inner 0]]} (defn greet [name] (println "Hello" name)) ; 2-space indent at depth 0 ;; BLOCK indentation [[:block index]] - switches to inner after index ;; Uses default indent before index, inner indent at/after index {let [[:block 1]]} (let [x 1 ; argument 0 - uses default indent y 2] ; still argument 0 (+ x y)) ; argument 1+ - uses inner (2-space) indent ;; Combined rules for complex macros {letfn [[:block 1] [:inner 2 0]]} ; block at 1, inner at depth 2 for arg 0 (letfn [(square [x] ; arg 0, depth 1 (* x x)) ; arg 0, depth 2 - inner indent (sum [x y] (+ x y))] (sum (square 3) ; arg 1 - block indent (square 4))) ``` -------------------------------- ### Check and Fix Clojure Code Recursively Source: https://github.com/weavejester/cljfmt/blob/master/README.md Uses the cljfmt.tool library to check or fix formatting across specified paths. It requires setting the report function to the Clojure-specific reporter to avoid default console-based exit behaviors. ```clojure (require '[cljfmt.tool :as fmt] '[cljfmt.report :as report]) (fmt/check {:paths ["/path/to/check"], :report report/clojure}) ``` ```clojure (require '[cljfmt.tool :as fmt] '[cljfmt.report :as report]) (fmt/fix {:paths ["/path/to/fix"], :report report/clojure}) ``` -------------------------------- ### Advanced Form Manipulation Source: https://context7.com/weavejester/cljfmt/llms.txt Reformat rewrite-clj data structures programmatically. This allows for advanced manipulation of Clojure forms with custom indentation rules and alignment options. ```clojure (require '[cljfmt.core :as fmt] '[rewrite-clj.parser :as p]) (let [form (p/parse-string-all "(defn foo\n[x]\n(+ x 1))") reformatted (fmt/reformat-form form)] (n/string reformatted)) ``` -------------------------------- ### Fix Clojure Code Formatting (Leiningen Plugin) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Fixes Clojure code formatting errors using the cljfmt Leiningen plugin. This command automatically applies formatting corrections to the project's files. ```bash lein cljfmt fix ``` -------------------------------- ### Fix Clojure Code Formatting (Standalone CLI) Source: https://github.com/weavejester/cljfmt/blob/master/README.md Automatically fixes formatting errors in the current project's Clojure code using the standalone cljfmt binary. This command modifies files in place to adhere to the configured formatting rules. ```bash cljfmt fix ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.