Fork me on GitHub
#clj-kondo
<
2021-09-15
>
borkdude12:09:56

@suskeyhose it's been released

seancorfield18:09:21

Q: so I'm using http-kit.client and it uses a macro to define a bunch of functions like put, get, post, etc in terms of a generic request function -- and clj-kondo is reporting http/post etc in my code as unresolved. Is there a way to tell it about those vars defined via macros?

nate19:09:20

I've run into the same issue with http kit, and with an internal library that creates functions in a macro.

nate19:09:44

I wonder if it would be possible to an analyze-call for the creating macro and turn it into a bunch of defns

borkdude19:09:15

Usually you can solve this using :lint-as

seancorfield18:09:58

(this seems to be the first time I've managed to get LSP/clj-kondo to fully rescan our source code in a long while -- see my struggles in #lsp for that)

borkdude19:09:48

@seancorfield Yeah, you can use {:lint-as {org.httpkit.client/defreq clojure.core/declare}} and then re-scan your project

borkdude19:09:03

This config can also be contributed back to the library using config exports/imports

borkdude19:09:51

@seancorfield You can force re-scanning your project by removing .lsp/.cache and then re-opening your editor, or does clojure-lsp automatically re-scan your project upon config changes @ericdallo?

seancorfield20:09:03

I thought I could just change deps.edn to force a rescan but that doesn't seem to have done it (I temporarily added the http-kit dep directly to the project deps.edn file -- it's just a transitive dep via :local/root otherwise) but I suspect LSP thinks it has already scanned http-kit...?

seancorfield20:09:54

That seems unfortunately brutal but I guess it'll work 🙂

borkdude20:09:21

@seancorfield Perhaps @ericdallo has a less brutal way ;)

seancorfield20:09:03

Yeah. Rebuilding the entire cache worked. It would be unfortunate if that's the only option after updating clj-kondo's config.

ericdallo20:09:32

If you change your deps file, clojure-lsp should certainly scan the project but only in the next startup, not automatic

ericdallo20:09:08

about updating the clj-kondo config there is this issue: https://github.com/clojure-lsp/clojure-lsp/issues/331

borkdude20:09:45

@ericdallo clj-kondo already has a hashing function for internal use to ignore already linted deps when the config has changed

ericdallo13:09:47

Would you mind sharing the function on the issue please? https://github.com/clojure-lsp/clojure-lsp/issues/331

borkdude20:09:17

perhaps you can use it for inspiration

seancorfield21:09:00

Oh, nice! Glad to know there's an issue. Also, good to know that if deps.edn changes, clojure-lsp will rescan at next startup -- I had hoped it would kick off a scan once the file changed... is there a way to "force" (encourage) clojure-lsp to rescan without restarting/reloading the editor? (I'm using VS Code/Calva if it makes a difference)

borkdude21:09:37

I would also like to have this in emacs

borkdude21:09:27

@seancorfield fwiw, a lot of libs are already providing config for clj-kondo. these are some examples: https://github.com/clj-kondo/clj-kondo/issues/1383 these configs are automatically imported by clj-kondo into the .clj-kondo directory when lsp indexes your deps, but you should still "opt in" to them by editing your deps.edn . if you have any libraries with macros that need config, you can consider doing the same and it will just work for anyone who uses your libraries.

ericdallo22:09:20

there is lsp-workspace-restart for emacs, but for vscode I think only the reload window is available

borkdude22:09:46

ah is that it, yeah I've been using that, thanks

seancorfield22:09:49

@borkdude Thanks. I probably ought to look at how clj-kondo views my various libraries and go ahead and do that "properly" for them...