{"id":13681859,"url":"https://github.com/weavejester/cljfmt","last_synced_at":"2025-05-13T15:13:10.882Z","repository":{"id":23420389,"uuid":"26783120","full_name":"weavejester/cljfmt","owner":"weavejester","description":"A tool for formatting Clojure code","archived":false,"fork":false,"pushed_at":"2025-04-11T19:22:45.000Z","size":620,"stargazers_count":1140,"open_issues_count":54,"forks_count":122,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-05-08T12:42:25.405Z","etag":null,"topics":["clojure","code-formatter","leiningen"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weavejester.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-11-17T23:50:14.000Z","updated_at":"2025-05-07T02:39:21.000Z","dependencies_parsed_at":"2023-12-08T14:58:46.979Z","dependency_job_id":"8a6fe8d5-33b1-4563-916f-e197abed353b","html_url":"https://github.com/weavejester/cljfmt","commit_stats":{"total_commits":326,"total_committers":50,"mean_commits":6.52,"dds":0.2852760736196319,"last_synced_commit":"05ee0796ec0913049210639d555014011649d720"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavejester%2Fcljfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavejester%2Fcljfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavejester%2Fcljfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weavejester%2Fcljfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weavejester","download_url":"https://codeload.github.com/weavejester/cljfmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253258714,"owners_count":21879699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","code-formatter","leiningen"],"created_at":"2024-08-02T13:01:36.993Z","updated_at":"2025-05-13T15:13:05.861Z","avatar_url":"https://github.com/weavejester.png","language":"Clojure","funding_links":[],"categories":["Clojure","tools"],"sub_categories":[],"readme":"# cljfmt [![Test Status](https://github.com/weavejester/cljfmt/actions/workflows/test.yml/badge.svg)](https://github.com/weavejester/cljfmt/actions/workflows/test.yml) [![Release Status](https://dl.circleci.com/status-badge/img/gh/weavejester/cljfmt.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/weavejester/cljfmt)\n\ncljfmt is a tool for detecting and fixing formatting errors in\n[Clojure][] code.\n\nIts defaults are based on the [Clojure Style Guide][], but it also has\nmany customization options to suit a particular project or team.\n\nIt is not the goal of the project to provide a one-to-one mapping\nbetween a Clojure syntax tree and formatted text; rather the intent is\nto correct formatting errors with minimal changes to the existing\nstructure of the text.\n\nIf you want format completely unstructured Clojure code, the [zprint][]\nproject may be more suitable.\n\n[clojure]: https://clojure.org/\n[clojure style guide]: https://github.com/bbatsov/clojure-style-guide\n[zprint]: https://github.com/kkinnear/zprint\n\n## Breaking Changes in 0.11.x\n\nThe `--indents` and `--alias-map` keys have been removed from the CLI,\nin favor of using a configuration file instead.\n\nThe `:indents` key has been split into `:indents` and `:extra-indents`.\nThe `:indents` key **replaces** all default indents, while the\n`:extra-indents` key will **append** to the default indents.\n\nIf you need to retain backward compatibility with an older version of\ncljfmt, then you can add the `:legacy/merge-indents?` key to your\nconfiguration:\n\n```edn\n{:legacy/merge-indents? true\n :indents {example.core/foo [[:inner 0]]}}\n```\n\nThis will treat `:indents` as if it were `:extra-indents`. i.e. it is\nequivalent to:\n\n```edn\n{:extra-indents {example.core/foo [[:inner 0]]}}\n```\n\n## Usage\n\ncljfmt integrates with many existing build tools, or can be used as a\nlibrary. As an end user, you have the choice of:\n\n### Standalone\n\nThe fastest way to run cljfmt is via a precompiled binary. If you're using\nLinux or MacOS, you can run the following command to install the binary into\n`/usr/local/bin`:\n\n```bash\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/weavejester/cljfmt/HEAD/install.sh)\"\n```\n\nYou can also run this command to update cljfmt to the latest version.\n\nIf you're using Windows, there's a [zipped up binary][] you can download and\nextract manually.\n\nTo use cljfmt to check for formatting errors in your project, run:\n\n```bash\ncljfmt check\n```\n\nAnd to fix those errors:\n\n```bash\ncljfmt fix\n```\n\nUse `--help` for a list of all the command-line options.\n\nFor persistent configuration, you can use a [configuration file][].\n\n[zipped up binary]: https://github.com/weavejester/cljfmt/releases/download/0.13.1/cljfmt-0.13.1-win-amd64.zip\n[configuration file]: #configuration\n\n### Clojure Tools\n\nThe official Clojure CLI supports installation of thirdparty [tools][].\nTo install cljfmt as a tool, run:\n\n```bash\nclj -Ttools install io.github.weavejester/cljfmt '{:git/tag \"0.13.1\"}' :as cljfmt\n```\n\nTo use the tool to check for formatting errors in your project, run:\n\n```bash\nclj -Tcljfmt check\n```\n\nAnd to fix those errors:\n\n```bash\nclj -Tcljfmt fix\n```\n\n[tools]: https://clojure.org/reference/deps_and_cli#tool_install\n\n### Leiningen\n\n[Leiningen][] is a popular Clojure build tool. To use cljfmt with\nLeiningen, add the following plugin to your `project.clj` file:\n\n```clojure\n:plugins [[dev.weavejester/lein-cljfmt \"0.13.1\"]]\n```\n\nTo use the plugin to check code for formatting errors, run:\n\n```bash\nlein cljfmt check\n```\n\nAnd to fix those errors:\n\n```bash\nlein cljfmt fix\n```\n\nTo configure it, put a `:cljfmt` key and a map of options in your\nproject file. See the [configuration][] section for more details.\n\n[leiningen]: https://github.com/technomancy/leiningen\n[configuration]: #configuration\n\n### Library\n\ncljfmt can be run as a library that formats a string of Clojure code or\nrecursively checks / fixes paths like the CLI tool.\nFirst, add the dependency:\n\n```edn\n{:deps {dev.weavejester/cljfmt {:mvn/version \"0.13.1\"}}}\n```\n\nThen use the library:\n\n#### Checking strings of code:\n\n```clojure\n(require '[cljfmt.core :as fmt])\n\n(fmt/reformat-string \"(defn sum [x y]\\n(+ x y))\")\n;; =\u003e \"(defn sum [x y]\\n  (+ x y))\"\n```\n\nTo load the configuration for the current directory:\n\n```clojure\n(require '[cljfmt.config :as cfg])\n\n(fmt/reformat-string \"(+ x\\ny)\" (cfg/load-config))\n;; =\u003e \"(+ x\\n   y)\"\n```\n\n#### Checking / fixing paths recursively\n\nBe sure to set the report fn to the clojure one as shown below. Otherwise the\n`check` and `fix` fns will assume they're running in console mode and will\ncall `System/exit`, print to stdout, etc.\n\n```clojure\n(require '[cljfmt.tool :as fmt]\n         '[cljfmt.report :as report])\n\n(fmt/check {:paths [\"/path/to/check\"], :report report/clojure})\n```\n\nOr to recursively fix paths:\n\n```clojure\n(require '[cljfmt.tool :as fmt]\n         '[cljfmt.report :as report])\n\n(fmt/fix {:paths [\"/path/to/fix\"], :report report/clojure})\n```\n\n### Editor Integration\n\nYou can also use cljfmt via your editor. Several Clojure editing\nenvironments have support for cljfmt baked in:\n\n* [Calva](https://github.com/BetterThanTomorrow/calva) (Visual Studio Code)\n* [CIDER](https://github.com/clojure-emacs/cider) (Emacs)\n* [clojureVSCode](https://github.com/avli/clojureVSCode) (Visual Studio Code)\n* [vim-cljfmt](https://github.com/venantius/vim-cljfmt) (Vim)\n\n\n## Configuration\n\nIn most environments, cljfmt will look for the following configuration\nfiles in the current and parent directories:\n\n* `.cljfmt.edn`\n* `.cljfmt.clj`\n* `cljfmt.edn`\n* `cljfmt.clj`\n\nThe configuration file should contain a map of options.\n\n### Leiningen\n\nIn Leiningen, the configuration is found in on the `:cljfmt` key in the\nproject map:\n\n```clojure\n:cljfmt {}\n```\n\nIn order to load the standard configuration file from Leiningen, add the\n`:load-config-file?` key to the `:cljfmt` map:\n\n```clojure\n:cljfmt {:load-config-file? true}\n```\n\n### Formatting Options\n\n* `:indentation?` -\n  true if cljfmt should correct the indentation of your code.\n  Defaults to true.\n\n* `:indents` -\n  a map of var symbols to indentation rules, i.e. `{symbol [\u0026 rules]}`.\n  See [INDENTS.md][] for a complete explanation. This will **replace**\n  the default indents.\n\n* `:extra-indents` -\n  the same as `:indents`, except that this will **append** to the\n  default indents.\n\n* `:indent-line-comments?` -\n  true if cljfmt should align whole-line `;;` comments with the code.\n  Defaults to false.\n\n* `:alias-map` -\n  a map of namespace alias to fully qualified namespace names. May be\n  symbols or strings. This option is unnecessary in most cases, because\n  cljfmt will parse the `ns` declaration in each file. See [INDENTS.md][].\n\n* `:remove-surrounding-whitespace?` -\n  true if cljfmt should remove whitespace surrounding inner\n  forms. This will convert \u003ccode\u003e(\u0026nbsp;\u0026nbsp;foo\u0026nbsp;\u0026nbsp;)\u003c/code\u003e to `(foo)`.\n  Defaults to true.\n\n* `:remove-trailing-whitespace?` -\n  true if cljfmt should remove trailing whitespace in lines. This will\n  convert \u003ccode\u003e(foo)\u0026nbsp;\u0026nbsp;\u0026nbsp;\\n\u003c/code\u003e to `(foo)\\n`. Defaults to true.\n\n* `:insert-missing-whitespace?` -\n  true if cljfmt should insert whitespace missing from between\n  elements. This will convert `(foo(bar))` to `(foo (bar))`.\n  Defaults to true.\n\n* `:remove-consecutive-blank-lines?` -\n  true if cljfmt should collapse consecutive blank lines. This will\n  convert `(foo)\\n\\n\\n(bar)` to `(foo)\\n\\n(bar)`. Defaults to true.\n\n* `:remove-multiple-non-indenting-spaces?` -\n  true if cljfmt should remove multiple non indenting spaces. For\n  example, this will convert \u003ccode\u003e{:a 1\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;:b 2}\u003c/code\u003e\n  to `{:a 1 :b 2}`. Defaults to false.\n\n* `:split-keypairs-over-multiple-lines?` -\n  true if cljfmt should break hashmaps onto multiple lines. This will\n  convert `{:a 1 :b 2}` to `{:a 1\\n:b 2}`. Defaults to false.\n\n* `:sort-ns-references?` -\n  true if cljfmt should alphanumerically sort the requires, imports and\n  other references in the `ns` forms at the top of your namespaces.\n  Defaults to false.\n\n* `:function-arguments-indentation` -\n  - `:community` if cljfmt should follow the [community style recommendation][]\n    to indent function/macro arguments by a single space when there\n    are no arguments on the same line as the function name.\n  - `:cursive` if two spaces should be used instead, unless the first\n    thing in the list (not counting metadata) is a data structure\n    literal. This should replicate Cursive's default behaviour.\n  - `:zprint` if two spaces should be used instead if the first thing\n    in the list is a symbol or keyword. This should replicate zprint's\n    default behaviour.\n\n  Defaults to `:community`\n\n[indents.md]: docs/INDENTS.md\n[community style recommendation]: https://guide.clojure.style/#one-space-indent\n\n### Runtime Options\n\n* `:file-pattern` -\n  a regular expression to decide which files to scan. Defaults to\n  `#”\\.clj[csx]?$”`.\n\n* `:parallel?` -\n  true if cljfmt should process files in parallel. Defaults to false.\n\n* `:paths` -\n  determines which files and directories to recursively search for\n  Clojure files. Defaults to checking `src` and `test`, except in\n  Leiningen where the `:source-paths` and `:test-paths` keys are used\n  instead.\n\n  Paths can also be passed as command line arguments. If the path is\n  `-`, then the input is STDIN, and the output STDOUT.\n\n## License\n\nCopyright © 2024 James Reeves\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavejester%2Fcljfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweavejester%2Fcljfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweavejester%2Fcljfmt/lists"}