This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-11
Channels
- # announcements (7)
- # babashka (125)
- # beginners (45)
- # calva (2)
- # cider (25)
- # clj-kondo (8)
- # clojure (123)
- # clojure-australia (4)
- # clojure-nl (5)
- # clojure-spec (3)
- # clojurescript (15)
- # community-development (6)
- # conjure (3)
- # datomic (6)
- # depstar (1)
- # exercism (1)
- # figwheel-main (5)
- # fulcro (37)
- # honeysql (3)
- # jobs-discuss (1)
- # lsp (79)
- # off-topic (24)
- # pathom (6)
- # schema (1)
- # shadow-cljs (35)
- # spacemacs (9)
- # sql (8)
- # tools-deps (6)
- # vim (9)
- # vrac (1)
- # xtdb (5)
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
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
I see now, so yeah, only with lint-as will not capture the definition to render correctly the eldoc
cool, that gives me a place to go then. At least it is behaving as expected, so I've not got that bit wrong.
@ericdallo how would a hook fix this?
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
?
LSP :: {:element
{:name-end-col 20,
:name-end-row 9,
:name-row 9,
:name separate-column,
:filename "/home/bld/wip/kixi.large/src/kixi/large.clj",
:alias tc,
:from kixi.large,
:col 2,
:name-col 2,
:arity 1,
:bucket :var-usages,
:row 9,
:to tablecloth.api},
:definition nil}
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
then x would just be a proxy to the-other-x, similar to how analysis for potemkin works
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
LSP :: {:element
{:name-end-col 20,
:name-end-row 9,
:name-row 9,
:name separate-column,
:filename "/home/bld/wip/kixi.large/src/kixi/large.clj",
:alias tc,
:from kixi.large,
:col 2,
:name-col 2,
:arity 1,
:bucket :var-usages,
:row 9,
:to tablecloth.api},
:definition nil}
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
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
so instead of (def x the-other-x)
it would be something like (import-vars [other.ns foo-fn])
?
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 😄
i'm not seeing an .lsp
folder being created in my project. this indicates that lsp is not working correctly, right?
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
there was a recent change on lsp-mode to print the project root @U11BV7MTK 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
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