Fork me on GitHub

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

clojure-lsp 1

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


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


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


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


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


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


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


let me check the code in zip-test


Ok, that's what I thought


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


lemme also try


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


yeah, this is odd


oh, did you confirm the same behavior?


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


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


something like that


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


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


thanks for the investigation


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


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


it makes sense


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

👍 1

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


updated the title. thanks


Sorry 😅 should have mention the potemkin macro


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

❤️ 2

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.


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


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.


Nice! That MultiCommand extension looks really interesting.