cljfmt icon indicating copy to clipboard operation
cljfmt copied to clipboard

Feature request: a configuration file

Open or opened this issue 2 years ago • 6 comments

Having the aliases, indents, and formatting options passed as CLI arguments is not ideal for editor integration and using cljfmt in multiple projects.

It'd be awesome if cljfmt could read all options from a single file, which can be specified. By default it could look for .cljfmt.edn (or similar) in the current directory and each directory up to HOME. It should use the first file it finds, without any attempt to merge with files higher up the directory tree, so there aren't any surprises due to a user's personal preferences.

This would allow per-project configuration for projects that don't use Leiningen and simplify editor/workflow integration.

or avatar May 02 '22 15:05 or

I believe you can configure using a file. We have .cljfmt.edn in our project. Its the default file for clojure-lsp and works without set up in emacs. In vscode, you have to tell calva where the file is, but you can also set it to the generic CLOJURE_LSP and it will pick up from clojure-lsp which pick up from .cljfmt.edn.

sirmspencer avatar Jun 23 '22 22:06 sirmspencer

Thanks, that's good to know. Unfortunately that won't help me, because I use the cljfmt binary for formatting, which also can check/fix whole directories.

I think it would be better if cljfmt read its own configuration file, then LSP probably wouldn't have to implement it.

or avatar Jun 24 '22 08:06 or

I'd be open to a PR that would look for a configuration file in the current directory. I'm less sure about looking in HOME or checking parent directories.

weavejester avatar Jun 24 '22 13:06 weavejester

Using the command line tool for linting in Emacs will run it in the file's directory, not the project root, so it needs to find the configuration.

And having a global default in one place (HOME) is incredibly useful as well. It would be painful to have to copy (and maintain) files in various project directories.

or avatar Jun 24 '22 14:06 or

Would this extend to the lein-cljfmt plugin, or would that need to be a seperate change on that side?

sirmspencer avatar Jun 24 '22 16:06 sirmspencer

Would this extend to the lein-cljfmt plugin, or would that need to be a seperate change on that side?

No, because Leiningen already has per-project and per-user configurations.

weavejester avatar Jun 24 '22 17:06 weavejester