calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
ericdallo 2021-02-10T00:43:51.296700Z

For some reason, when linting a single file, clj-kondo is not considering the configs, not sure is something that I'm doing wrong here, but I tried these two ways: from rewrite-clj-repro linked on the issue:

cat /home/greg/dev/rewrite-clj-repro/test/rewrite_clj/zip_test.cljc | clj-kondo --lint -
and informing the filename:
cat /home/greg/dev/rewrite-clj-repro/test/rewrite_clj/zip_test.cljc | clj-kondo --config '{:filename "/home/greg/dev/rewrite-clj-repro/test/rewrite_clj/zip_test.cljc"}' --lint -
both return:
<stdin>:10:27: warning: Unresolved var: z/of-string
<stdin>:10:39: warning: Unresolved var: z/root-string
<stdin>:26:26: warning: Unresolved var: z/find-tag-by-pos
<stdin>:27:26: warning: Unresolved var: z/replace
<stdin>:28:26: warning: Unresolved var: z/append-child
<stdin>:29:25: warning: Unresolved var: z/down
<stdin>:30:25: warning: Unresolved var: z/remove
<stdin>:47:16: warning: Unresolved var: z/rightmost
<stdin>:48:16: warning: Unresolved var: z/child-sexprs
<stdin>:57:16: warning: Unresolved var: z/up
<stdin>:68:16: warning: Unresolved var: z/right
<stdin>:82:17: warning: Unresolved var: z/insert-child
<stdin>:92:28: warning: Unresolved var: n/map-qualifier-node
<stdin>:106:36: warning: Unresolved var: z/node
<stdin>:106:43: warning: Unresolved var: n/map-context-clear
<stdin>:116:18: warning: Unresolved var: z/sexpr
<stdin>:136:18: warning: Unresolved var: z/reapply-context
linting took 226ms, errors: 0, warnings: 17

ericdallo 2021-02-10T02:55:20.296900Z

Sorry, it seems the cache :true was messing up my tests

ericdallo 2021-02-10T03:07:08.297100Z

Fixed removing the manual config that we were configuring before kondo full integration

ericdallo 2021-02-10T03:07:14.297300Z

thanks!

ericdallo 2021-02-10T03:13:19.297900Z

Fixed on latest clojure-lsp release @lee @brandon.ringe 🙂

1
lread 2021-02-10T18:52:34.305800Z

Thanks for the fix @ericdallo and @brandon.ringe! There still might be something amiss though? https://github.com/BetterThanTomorrow/calva/issues/1026#issuecomment-776931914

ericdallo 2021-02-10T18:53:35.306100Z

Yeah, this is odd, there is no cache when linting single files anymore so this should work, I'll test it in Emacs and try to reproduce it

lread 2021-02-10T18:57:53.306300Z

It seems like unresolved vars is not working for my project code but maybe working for external deps? I dunno.

ericdallo 2021-02-10T19:09:35.306500Z

I commented on the issue, but I could not make clj-kondo warn about that unknown function too :thinking_face:

ericdallo 2021-02-10T20:05:31.306800Z

So @borkdude could you help me understand how clj-kondo works for unresolved-var? First, I lint the whole src folder to persist on cache with:

clj -Sdeps '{:deps {clj-kondo {:mvn/version "2021.01.21-20210207.143254-18"}}}' -m clj-kondo.main --lint src 
then I lint a single file (that should use the cache, right?):
cat test/rewrite_clj/zip_test.cljc | clj -Sdeps '{:deps {clj-kondo {:mvn/version "2021.01.21-20210207.143254-18"}}}' -m clj-kondo.main --lint -
But I get:
<stdin>:10:28: warning: Unresolved var: z/of-string
<stdin>:10:40: warning: Unresolved var: z/unknown
<stdin>:26:26: warning: Unresolved var: z/find-tag-by-pos
<stdin>:27:26: warning: Unresolved var: z/replace
<stdin>:28:26: warning: Unresolved var: z/append-child
<stdin>:29:25: warning: Unresolved var: z/down
<stdin>:30:25: warning: Unresolved var: z/remove
<stdin>:31:25: warning: Unresolved var: z/root-string
<stdin>:47:16: warning: Unresolved var: z/rightmost
<stdin>:48:16: warning: Unresolved var: z/child-sexprs
<stdin>:57:16: warning: Unresolved var: z/up
<stdin>:68:16: warning: Unresolved var: z/right
<stdin>:82:17: warning: Unresolved var: z/insert-child
<stdin>:92:28: warning: Unresolved var: n/map-qualifier-node
<stdin>:106:36: warning: Unresolved var: z/node
<stdin>:106:43: warning: Unresolved var: n/map-context-clear
<stdin>:116:18: warning: Unresolved var: z/sexpr
<stdin>:136:18: warning: Unresolved var: z/reapply-context
linting took 493ms, errors: 0, warnings: 18

ericdallo 2021-02-10T20:06:05.307Z

this is basically what clojure-lsp does, first lint whole classpath, then every new open file/new changes, lint the single file

ericdallo 2021-02-10T20:07:53.307200Z

Should I pass manually the :cache-dir and :cache true?

borkdude 2021-02-10T20:09:51.307400Z

no, :cache is true by default and clj-kondo will find the cache on its own

borkdude 2021-02-10T20:10:27.307600Z

let me check the code in zip-test

ericdallo 2021-02-10T20:11:13.307800Z

Ok, that's what I thought

borkdude 2021-02-10T20:12:13.308Z

so e.g. of-string is imported using some potemkin-like macro. this should need a config

borkdude 2021-02-10T20:13:15.308600Z

lemme also try

borkdude 2021-02-10T20:14:41.308900Z

ok, lint src, 0 errors, now the tests.

ericdallo 2021-02-10T20:15:25.309100Z

yes, he has the same config https://github.com/clj-commons/rewrite-clj/blob/v1/.clj-kondo/config.edn (the repro that I'm using)

borkdude 2021-02-10T20:22:19.309500Z

yeah, this is odd

ericdallo 2021-02-10T20:22:40.309700Z

oh, did you confirm the same behavior?

borkdude 2021-02-10T20:23:26.310Z

so when you lint the project as a whole you get 0 errors, but when you lint 1 file you get unresolved warnings. yeah, that's a clj-kondo issue. feel free to post this specific issue at clj-kondo

borkdude 2021-02-10T20:24:13.310200Z

it's related to the support we have for potemkin and when you use 1 file, it should load the other ns transitively I think

borkdude 2021-02-10T20:24:15.310400Z

something like that

borkdude 2021-02-10T20:24:34.310600Z

I'm not sure if this ever used to work, I don't think so

ericdallo 2021-02-10T20:24:45.310800Z

Got it, I spent too much time on that yesterday, glad to hear is not clojure-lsp' fault

ericdallo 2021-02-10T20:24:49.311Z

thanks for the investigation

ericdallo 2021-02-10T20:24:58.311200Z

I'll open a clj-kondo issue with the same repro

borkdude 2021-02-10T20:25:16.311400Z

the unresolved var linter is a new addition and it causes false positives in this case, but that's not a regression or anything

ericdallo 2021-02-10T20:25:34.311700Z

it makes sense

borkdude 2021-02-10T20:25:36.311900Z

it's just a new issue with the unresolved var linter that hasn't been covered yet

👍 1
ericdallo 2021-02-10T20:45:49.312200Z

https://github.com/clj-kondo/clj-kondo/issues/1167

borkdude 2021-02-10T20:46:51.312500Z

yeah, the issue title isn't accurate: the cache is consided for single linted files. it's just something very specific to this potemkin macro

borkdude 2021-02-10T20:48:21.312700Z

updated the title. thanks

ericdallo 2021-02-10T21:00:56.312900Z

Sorry 😅 should have mention the potemkin macro

borkdude 2021-02-10T21:10:37.313100Z

np! :)

lread 2021-02-11T01:45:59.313600Z

Thanks so much for digging into this and figuring it out @ericdallo and @borkdude!

❤️ 1
Bees 2021-02-10T07:04:59.301600Z

Is there a command which moves the cursor to the last position outside the top level form. In other words, if I am in the middle of comment form, I can evaluate a nested form using alt+enter for calva.evaluateCurrentTopLevelForm. I'd like to be able to move the cursor so that it is at the end of that same evaluated form.

pez 2021-02-10T07:39:15.304Z

@slack_clojurians The closest you can get is Select Top Level Form, then arrow key right (or left to get before the start instead). The chord would be ctrl+alt+w space right. Change the select shortcut if you find it awkward.

Bees 2021-02-10T10:57:44.304900Z

Thank you, this works perfect. I'm using this with the MultiCommand extension and so I now have a way to evaluate several forms in a comment form, one after another, running "calva.evaluateCurrentTopLevelForm", "paredit.rangeForDefun", "cursorRight", "paredit.forwardSexp". Tied to a keybinding, this evaluates one Top Level form and then advances to the next Top Level form in the comment form. I currently used Alt+Shift+Enter to accomplish this, but it looks like in another thread, someone is recommended some other use of that keybinding.

pez 2021-02-10T13:45:52.305500Z

Nice! That MultiCommand extension looks really interesting.