About https://github.com/clj-kondo/clj-kondo/issues/1281 ๐งต
@borkdude should we create a new flag since if we change the --copy-configs
to accept a file, the old empty --copy-configs
will stop working, right?
without anything or nil
we just use the previous stategy, I'd say: the local .clj-kondo dir
Got it, I'll follow with that so
@borkdude it seems there is a place that still treat the ~/.clj-kondo as a global config dir: https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/core.clj#L102
If we change here to check the XDG/.config dir as well, it would behave the same and fix the issue, right?
so the ~/.clj-kondo has indeed a special handling, I thought clj-kondo was using it because of a recursive call from the project dir
oh damn, I don't know where that comes from
I found that checking why it needs to cfg-dir be non-nil: https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/core.clj#L241
Oh btw, that line is correct
It just means it searches from the current directory upwards
I misread it for user.home
if we add the home-config dir as a fallback there, I'm not sure what consequences that has...
that's why I would prefer to have an explicit copy-configs
destination instead (and use the local dir as the default one)
else it would populate .config/clj-kondo/.cache
with data which is probably against the rules of XDG_CONFIG, etc
Alright, but that is exactly what I intend to have after I pass the --copy-configs .config/clj-kondo
, the cache properly added to that dir, right?
configs = stuff exported by libraries, cache = transit files in .cache
, those are two totally different things
I see, so I think there are 2 issues here haha
because without a clj-kondo .cache folder, things like refered midje macros and things like that doesn't work
because there is no .cache
and clj-kondo doesn't persists it on .config/clj-kondo
only if threre is a ~/.clj-kondo
you can control the cache dir with --cache-dir
hum, so I can --copy-configs ~/.config/clj-kondo --cache-dir ~/.config/clj-kondo
on clojure-lsp?
you could, but I would not do this by default for all users of course
why? otherwise only if users manually create local .clj-kondo dir or on home things will work like refered symbols
yes, they should create that then. or lsp should create it, I have suggested this before
user should just read the manual how clj-kondo works, it's all documented pretty well
it is, my point is just that is not IDEish, imagine cursive ask for users create a .cursive
dir for things work ๐
I just wanna make most things work by default and leave the corner cases optional for users configure it
yeah, so because clojure-lsp is an IDEish thing, it could make that decision I guess. clj-kondo doesn't know where the root of your project is because all it sees is a filename
yeah, that's I agree ๐
alright, I already implemented on clj-kondo that support as we discussed, I'll make some tests with clojure-lsp to make sure it makes sense
thanks for the help ๐
:)
maybe clj-kondo could borrow some of the IDE-ish stuff from lsp in the future, e.g. how to decide where the root of a project is, but so far clojure-lsp is doing a great job of lifting this burden from clj-kondo itself ;)
hahah yeah, that could make things easier for clojure-lsp and maybe open doors for other libs that use clj-kondo
the reason I've refrained from this so far is that I don't like tools that automatically create garbage on my machine
yeah, it's sounds good to avoid those things, but as we need a .cache somewhere for things work, we need to choose create a .clj-kondo for the project or a global one (which seems less intrusive as it's one time for all projects?)
I'm not a big fan of a global caching dir that multiple projects together use, as this can give clashes with namespaces from different projects
adding to the confusion. I think people should just invest 5 minutes to see how it works. this saves everybody time and headaches
clojure-lsp could create a .clj-kondo
in the project root, but it would not be enough since the :config-paths
config are on ~/.config/clj-kondo
and it expects that lib configs would be copied to there, not to the local clj-kondo dir
I don't think it makes sense to copy the "configs" to ~/.config/clj-kondo
either, since they are specific to the project's dependencies. Just check them into the project's git repo
Note that one giant blob of global configs will make clj-kondo slower as well, as it has to parse all these configs every time it's started
the issue is that we would need to add :config-paths
for every project manually, but yeah seems more specific
I think that is the better thing to do
what happens with lib hook updates? they would be replaced on local clj-kondo as well?
yes
alright, I'll give a try to check how it works!
so different projects can use different versions
with a global config that wouldn't work anymore
so, I seems to work if the project has a .clj-kondo with the config-paths, and it sounds the cacnonical way to do that, I'll let you know if works for eveybody, thanks!
:thumbsup: