Fork me on GitHub
#calva
<
2022-02-07
>
mac14:02:59

I have updated my kondo config.edn. Does anyone know how I get Calva to re-lint all the code in my project?

borkdude14:02:45

@mac probably re-opening your project. in emacs you can do lsp-workspace-restart, but don't know how that's done in vscode without closing it

ericdallo14:02:08

Reload Window show do it

☝️ 1
mac14:02:00

@borkdude Hm, I must have made a mistake in my config then.

{:linters
 {:unresolved-symbol
  {:exclude [(meander.epsilon/search)
             (meander.epsilon/$)]}}}
but I still get unresolved symbol for all logic vars inside the call to meander.epsilon/$

borkdude14:02:09

@mac Make a command line repro please, it's easier to exclude editor issues that way

mac14:02:55

@borkdude OK, will give that a shot.

borkdude14:02:17

clj-kondo --lint src/your_file.clj

mac14:02:25

@borkdude Yes, I can reproduce it from the command line using the config above.

mac14:02:17

This is the code.

(defn expr-by-type-and-concerns-interval [contract type interval]
  (me/search
   contract
   (me/$
    {:type (me/pred #(= % type))
     :id ?id
     :concerns-interval (me/pred #(intervals-equal? % interval))
     :as ?goal-expr})
   (assoc ?goal-expr :key ?id)))

borkdude14:02:46

Can you include the ns clause, to make it a standalone repro please?

mac14:02:54

(ns example
  (:require
   [meander.epsilon :as me]))

(defn intervals-equal?
  [{start1 :start end1 :end} {start2 :start end2 :end}]
  (and (= start1 start2) (= end1 end2)))

using [meander/epsilon "0.0.588"]

borkdude15:02:46

I see no errors with:

(ns example
  {:clj-kondo/config '{:linters
                       {:unresolved-symbol
                        {:exclude [(meander.epsilon/search)
                                   (meander.epsilon/$)]}}}}
  (:require
   [meander.epsilon :as me]))

(defn intervals-equal?
  [{start1 :start end1 :end} {start2 :start end2 :end}]
  (and (= start1 start2) (= end1 end2)))

(defn expr-by-type-and-concerns-interval [contract type interval]
  (me/search
   contract
   (me/$
    {:type (me/pred #(= % type))
     :id ?id
     :concerns-interval (me/pred #(intervals-equal? % interval))
     :as ?goal-expr})
   (assoc ?goal-expr :key ?id)))

borkdude15:02:54

Also see:

$ clj-kondo --lint dude.clj
dude.clj:14:10: error: Unresolved symbol: ?id
dude.clj:16:10: error: Unresolved symbol: ?goal-expr
vs
$ clj-kondo --lint dude.clj --config '{:linters
                       {:unresolved-symbol
                        {:exclude [(meander.epsilon/search)
                                   (meander.epsilon/$)]}}}'
linting took 13ms, errors: 0, warnings: 0

borkdude15:02:27

I would in doubt just restart your VSCode and re-open in. Also make sure your .clj-kondo directory is in the root of your project

mac15:02:39

I still get the errors. It is a cljs file, would that make a difference?

sudo clj-kondo --lint reporting.cljs --config '{:linters
                       {:unresolved-symbol
                        {:exclude [(meander.epsilon/search)
                                   (meander.epsilon/$)]}}}'
reporting.cljs:25:5: warning: Unresolved var: me/$
reporting.cljs:26:18: warning: Unresolved var: me/pred
linting took 37ms, errors: 0, warnings: 2

borkdude15:02:55

renaming my file to .cljs doesn't change anything for me

borkdude15:02:39

hmm, why are you using sudo

borkdude15:02:54

not that it changes anything

borkdude15:02:23

oh wait, your errors are "Unresolved var", not "Unresolved symbol"

borkdude15:02:28

that's a completely different issue

borkdude15:02:58

The issue there is that $ is defined using a custom macro:

(defsyntax $ ..)

borkdude15:02:42

You can probably fix this with

{:lint-as {meander.epsilon/defsyntax clojure.core/defn}
 :linters {...}}

borkdude15:02:04

That also needs reloading your workspace once more

borkdude15:02:36

It would be best if meander exported this clj-kondo config so other users can immediately profit from this. cc @U06MDAPTP

borkdude15:02:23

If you aren't interested in clj-kondo resolving vars from other namespaces (so you get a warning when you use a non-existing one), then you can also disable the unresolved-var linter

mac15:02:22

Ah, cool. The lint-as works. Sorry for the confusion.

👍 1
Lukas Domagala19:02:22

The new vscode release has a new https://code.visualstudio.com/updates/v1_64#_new-side-panel. Not sure how hard it is to put stuff in there, but we might think about displaying the repl inside that instead of the split view.

👀 2
🙏 1
pez08:02:52

This is a weak part of VS Code, I think. They have all sorts of different types of panes and containers that need special support to be able to move around. It would be so much easier for them, for extension authors and for users if there was a generic model for panes and the user could host anything, anywhere. Theia has this, so it is not like it isn't possible with a maintained VS Code experience. Yes, I know this is not the right place to complain about this, I'm just venting some frustration. 😃

Lukas Domagala09:02:22

Yeah, I know what you mean. There are a lot of annoying restrictions in vscode for no reason. E.g. you can resize autocompletion tooltips, but not hovers?