I did some work recently to make clj-kondo recognise some things in the scicloj datascience world (specifically tablecloth). This has allowed me to suppress clj-kondo warnings in tablecloth by using lint-as, but I'd expected I'd get clojure-lsp help as well. Are there some docs I'm missing or do I need to do more than just a lint-as? eldoc seems to work if I'm jacked into cider
clojure-lsp should pick up on the same clj-kondo config, if not, then something is wrong
@otfrom I just see unused-public-var warnings there that are from clojure-lsp: https://clojure-lsp.github.io/clojure-lsp/settings/#clojure-lsp
my, hopefully basic, lint-as https://gist.github.com/otfrom/ab558c8dc40b613b474ce4702abe1695
is this because of some potemkin-like macro that imports vars?
I don't know how tablecloth macro works @otfrom, could you please share how clj-kondo lint that? or a sample tiny repro?
@borkdude yeah, it is that export that tablecloth.api uses that I was trying to sort out with the lint-as in my config.edn
@ericdallo is this ^^ what you mean?
btw, sending me back to say, "look again at hooks" is a perfectly reasonable response if lint-as isn't sufficient
@otfrom I think a hook could save you some time here but if you're happy with manually writing the lint-as config that's perfectly fine too
yes, if work with clj-kondo, it should work with clojure-lsp, at least from you print I can't see nothing wrong
maybe @otfrom can you explain what is the unexpected bit?
sorry, it has been tricky to capture I think this is it:
eldoc shows what I'd expect in the lsp-ui tooltip
I see now, so yeah, only with lint-as will not capture the definition to render correctly the eldoc
you will need a hook probably to make that work
cool, that gives me a place to go then. At least it is behaving as expected, so I've not got that bit wrong.
yes, it's tricky but with a hook should work as expected
clj-kondo lint-as just really fixes the lint for those cases
@ericdallo how would a hook fix this?
e.g. the hook that expands into (def x the-other-x)
that would still not fix the eldoc I think?
the eldoc will work as soon clojure-lsp find correctly the definition of a var, using lint-as will just tell clj-kondo how to lint, but not how to make clojure-lsp find the definition
if the hook expands to (def x the-other-x)
, the clj-kondo analysis will find that and then clojure-lsp will get the definition correctly, right?
there are no docstrings in this namespace: https://github.com/scicloj/tablecloth/blob/master/src/tablecloth/api.clj
@otfrom could you please move your cursor to the separate column and call lsp-clojure-cursor-info
?
this will help understand how kondo is analysing that
I have a very old issue here that is probably relevant: https://github.com/clj-kondo/clj-kondo/issues/412
currently (def x the-other-x)
does not make an automatic connection between those vars, but clj-kondo could do this if that issue got implemented
and how that affect kondo analysis?
then x would just be a proxy to the-other-x, similar to how analysis for potemkin works
so I think @otfrom that a hook won't help you until 412 is implemented
or... you could transform the call into a potemkin call, which clj-kondo knows about
oh, it makes sense @borkdude, checking the function https://github.com/scicloj/tablecloth/blob/924d0c10c1862b03a9c18da289151f77a9889653/src/tablecloth/api/join_separate.clj#L82-L86 It seems to be the exactly issue from 412, I imagine that the analysis considering the first export instead of that function
yes, we can see clojure-lsp is not finding the :definition
of that var, probably because of https://github.com/clj-kondo/clj-kondo/issues/412
no, the definition is not there because clj-kondo doesn't understand the custom import logic in tablecloth.api
but the docstring of tablecloth.foo.bar isn't automatically connected with tablecloth.api
if you do (def x foo.bar/x)
, which is 412
hum, I see, so there are 2 issues there, right?
so these are two separate issues
yes. the first one can be solved using a hook. if you write the hook such that it expands into potemkin-like code, it also solved the second issue.
I imagine it should be hard to clj-kondo support tech.v3.datatype.export-symbols
like it does for potemkin?
not hard, but this can be accomplished using a hook, so I'd rather not stick code for every other macro out in the wild into clj-kondo
yes, it makes sense
so instead of (def x the-other-x)
it would be something like (import-vars [other.ns foo-fn])
?
yes
also with the right require
clause prepended so it knows import-vars is from potemkin
@otfrom you can implement the hook to fix your issue and if you want to solve this problem to everyone else that uses this lib, you can use https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration and add the hook to the tablecloth
lib itself 🙂
this way any user from tablecloth
will just need to add something like :config-paths ["scicloj/tableclothe"]
and the hook will just work
but first you need to make the hook work, then you can start thinking in migrate it to the tablecloth lib 😄
yeah, getting it working locally is definitely step 0
or rather 0+n
I think n is about 6 or 7 atm
i'm not seeing an .lsp
folder being created in my project. this indicates that lsp is not working correctly, right?
i'm not seeing any logging anywhere either to indicate what's going on
thx @borkdude & @ericdallo
and i'm not seeing any /tmp/clojure-lsp.*.out files created
interestingly, i reenabled the file watchers thing and it told me there are 48,000 files to be watched. it seems to think that the root of the project is my projects dir that contains all of the projects, rather than this project
yes, maybe
you can check with lsp-workspace-folders-remove
and then lsp
again, then lsp-mode should ask what is the project root
also you can get the log of your current session with lsp-clojure-server-info
there was a recent change on lsp-mode to print the project root @dpsutton maybe it could be related
ah nice, i think this is going to work. it asked me if i wanted to import the correct mode
not mode, project
and now have an .lsp folder. thanks so much @ericdallo
Also, I suggest you add to your clojure-lso config, :log-path /tmp/clojure-lsp.out
to use the same file for any project log
somewhere along the line the parent folder got marked as the parent, even though there was no .lsp folder in there
i'm wondering where they are by default
i'm not seeing any clojure-lsp type files in tmp
yeah, it's lsp-mode using projectile/project.el that decides the project root
are you a mac user?
I think for some OSs JVM use the /var/log/hash folder
that's why I suggest you use a :log-path /tmp/clojure-lsp.out
ah i see
thank you
we can't set that as default for all users as there are users that don't have write access to /tmp folder
you re welcome 🙂