Fork me on GitHub
#calva
<
2021-02-10
>
ericdallo03:02:19

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

clojure-lsp 3
ericdallo18:02:35

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

lread18:02:53

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

ericdallo19:02:35

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

ericdallo20:02:31

So @U04V15CAJ 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

ericdallo20:02:05

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

ericdallo20:02:53

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

borkdude20:02:51

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

borkdude20:02:27

let me check the code in zip-test

ericdallo20:02:13

Ok, that's what I thought

borkdude20:02:13

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

borkdude20:02:15

lemme also try

borkdude20:02:41

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

borkdude20:02:19

yeah, this is odd

ericdallo20:02:40

oh, did you confirm the same behavior?

borkdude20:02:26

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

borkdude20:02:13

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

borkdude20:02:15

something like that

borkdude20:02:34

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

ericdallo20:02:45

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

ericdallo20:02:49

thanks for the investigation

ericdallo20:02:58

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

borkdude20:02:16

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

ericdallo20:02:34

it makes sense

borkdude20:02:36

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

👍 3
borkdude20:02:51

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

borkdude20:02:21

updated the title. thanks

ericdallo21:02:56

Sorry 😅 should have mention the potemkin macro

lread01:02:59

Thanks so much for digging into this and figuring it out @UKFSJSM38 and @U04V15CAJ!

❤️ 4
Bees07:02:59

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.

pez07:02:15

@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.

Bees10:02:44

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.

pez13:02:52

Nice! That MultiCommand extension looks really interesting.