-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#336 extra-configs for importing extra-indents #337
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ pom.xml.asc | |
.nrepl-port | ||
reports | ||
.cpcache | ||
.clj-kondo | ||
.lsp | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,16 @@ In order to load the standard configuration file from Leiningen, add the | |
Paths can also be passed as command line arguments. If the path is | ||
`-`, then the input is STDIN, and the output STDOUT. | ||
|
||
* `:extra-configs` - | ||
additional config files that will also be imported and merged into | ||
the base configuration. Is not recursive, so `:extra-configs` in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably should be recursive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea I could see that; I was worried about how this might be confusing or hard to debug. Some odd corner cases I was thinking about:
If it's not recursive though, I could see inconveniences there as well. Not sure. |
||
imported configs will not be respected. | ||
|
||
File paths are expected to be relative paths from the base config file. | ||
|
||
Only certain keys from other configs will be respected: | ||
* `:extra-indents` | ||
|
||
## License | ||
|
||
Copyright © 2023 James Reeves | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
(ns cljfmt.config-test | ||
(:require [cljfmt.config :as config] | ||
[clojure.test :refer [deftest is]])) | ||
[clojure.test :refer [deftest is testing]] | ||
[clojure.java.io :as io])) | ||
|
||
(deftest test-convert-legacy-keys | ||
(is (= {:indents {'foo [[:inner 0]]}} | ||
(config/convert-legacy-keys {:indents {'foo [[:inner 0]]}}))) | ||
(is (= {:extra-indents {'foo [[:inner 0]]}} | ||
(config/convert-legacy-keys {:legacy/merge-indents? true | ||
:indents {'foo [[:inner 0]]}})))) | ||
|
||
(deftest test-load-config-extra-configs | ||
(testing ":extra-configs allows you to import :extra-indents" | ||
(is (= (config/load-config | ||
(io/resource "cljfmt/config_test/empty-cljfmt.edn")) | ||
(-> (config/load-config | ||
(io/resource "cljfmt/config_test/cljfmt.edn")) | ||
(dissoc :extra-configs) | ||
(assoc :extra-indents {}))) | ||
(str "should only differ by :extra-indents (via :extra-configs)." | ||
" All other keys are ignored.")) | ||
(is (= '{;; exists only in base config `test_resources/cljfmt.edn` | ||
com.unrelated/a [[:inner 0]] | ||
com.foo/a [[:inner 0]], | ||
;; exists only in `test_resources/extra1-cljfmt.edn` | ||
com.foo/b [[:inner 1]], | ||
;; overwritten in `test_resources/extra2-cljfmt.edn` | ||
com.foo/c [[:inner 2]], | ||
com.foo/d [[:inner 2]], | ||
;; exists only in `test_resources/extra2-cljfmt.edn` | ||
com.foo/e [[:inner 2]]} | ||
(:extra-indents (config/load-config | ||
(io/resource "cljfmt/config_test/cljfmt.edn")))) | ||
(str "should respect :extra-configs in order (later is higher-prio)," | ||
" with base highest prio.")))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{:extra-indents {com.foo/a [[:inner 0]] | ||
com.unrelated/a [[:inner 0]]} | ||
:extra-configs ["extra1-cljfmt.edn" | ||
"extra2-cljfmt.edn"]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{:parallel? true | ||
:paths ["x"] | ||
:sort-ns-references? true | ||
:extra-indents {;; exists in base | ||
com.foo/a [[:inner 1]] | ||
;; not included in later config | ||
com.foo/b [[:inner 1]] | ||
;; overridden in later configs | ||
com.foo/c [[:inner 1]] | ||
com.foo/d [[:inner 1]]} | ||
:extra-configs []} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{:parallel? false | ||
:paths ["y"] | ||
:sort-ns-references? false | ||
:extra-indents {com.foo/c [[:inner 2]] | ||
com.foo/d [[:inner 2]] | ||
com.foo/e [[:inner 2]]} | ||
:extra-configs []} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{:extra-configs ["config.edn"]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes that aren't relevant to the PR should ideally be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are both standard things that clojure-lsp/IDE's might pull in, so figured they might be useful to add. I can yank it though if you really don't want them included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are useful, but they're just not relevant to the current PR. A PR should only contain code to implement the feature/fix described.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I can yoink them then if them's the rules.