Fork me on GitHub
#lsp
<
2022-05-30
>
ribelo18:05:36

today I noticed that there is something wrong with my config and macros that used to be resolved as defn-catch-all now throw errors

ericdallo18:05:04

Could you share the config?

ribelo18:05:37

latest version available for nixos-unstable

ericdallo18:05:42

Yeah, make sure to use latest clojure-lsp

ericdallo18:05:53

Try nixpkgs-unstable instead

ribelo19:05:12

I downloaded the latest binary from github, but it did not help

ericdallo19:05:36

Could you share the config?

ribelo19:05:08

are you asking for emacs config or maybe

.clj-condo/config.edn?

ericdallo19:05:22

Yes, the clj-kondo

ribelo19:05:39

{:lint-as {ribelo.praxis/defeffect clj-kondo.lint-as/def-catch-all}}
🙃

ribelo19:05:55

I dumped everything just in case

ribelo19:05:12

and this is the config from the project directory

ericdallo19:05:15

Looks correct Is it possible to share the project? Or create a tiny sample which I can test it myself

ericdallo19:05:49

I can try it soon One thing I suggest is to use the clj-kondo export feature which you can include in your lib itself and all clients of that would make your config work OOTB. A example of that here: http://github.com/nubank/state-flow

ericdallo13:05:43

@U0BBFDED7 after testing the project, I repro the same issue and it was only fixed after I moved the macro definition outside the :clj reader conditional, so I think it may be expected by clj-kondo or a bug there

❤️ 1
ribelo15:05:14

is it a bug or should it be like that? I can create an issue on GH if needed @U04V15CAJ

borkdude15:05:43

Can you explain the issue once again, now that you have a repro?

ribelo15:05:41

tl;dr

;; don't work
#?(:clj
   (defmacro defeffect ...

;; works
(defmacro defeffect ...

borkdude15:05:15

This is not a repro, this is an incomplete snippet

borkdude15:05:32

I need tp see the full (minimal) code and (minimal) full config

ribelo15:05:52

{:lint-as {ribelo.praxis/defeffect clj-kondo.lint-as/def-catch-all}}

ribelo15:05:41

minimal code

#?(:clj 
   (defmacro defeffect 
     [:id & args]
     nil))

(defeffect :foo 
  [bar baz]
  (+ bar baz))

borkdude15:05:03

ok, I'll try, just a moment

ribelo15:05:02

it's no big deal and if you say it's the way it's supposed to be, I'll learn to live with it 🙃

borkdude15:05:58

This works for me? Minus the weird keyword in the defmacro

borkdude15:05:28

Or is this a .cljc file? Hmm, wait

borkdude15:05:16

Yes, this might be a bug with def-catch-all. This does work:

(ribelo.praxis/defeffect :foo
  [bar baz]
  (+ bar baz))
But I think there's a better way to do this than def-catch-all since that is intended to see the name of the var you are defining and that is not working with keywords

borkdude15:05:33

Let me just give you a better option

ericdallo15:05:46

I tried with clojure.core/defn and it didn't work as well

borkdude16:05:19

Oh I see, the (defeffect :foo) isn't intended to create a var a foo at all, I see

borkdude16:05:44

yeah, this is definitely hook material though

ericdallo16:05:49

So it means to properly lint it will require a custom hook code and not only lint-as right?

ericdallo16:05:12

@U0BBFDED7 so it's not a bug

borkdude16:05:25

@U0BBFDED7 this should work better: https://github.com/ribelo/praxis/pull/1 But it requires the newest lsp which supports the .clj_kondo extension

borkdude16:05:36

which should be out today maybe :)

borkdude20:05:33

@U0BBFDED7 ok, with the upgraded clojure-lsp your macros should now work better

borkdude18:05:18

It's clj-kondo.lint-as/def-catch-all, not defn-catch-all

ribelo18:05:57

possibly, I am writing from memory 😛