Fork me on GitHub
#cursive
<
2015-12-25
>
polymeris02:12:51

Why does cursive say a (in both cases) cannot be resolved here:

(defn f []
  (def a 1)
  a)
Is it a bug or is it really not resolved? (I am relatively new to clojure)

polymeris02:12:41

If I replace defn f [] with do, cursive does not complain. I thought defns had an implicit do?

cfleming05:12:37

@polymeris: Cursive is technically incorrect here (since the language does support what you’re doing) but it’s strongly discouraged.

cfleming05:12:12

def always creates a new top-level var in the namespace, which is almost certainly not what you want.

cfleming05:12:49

You probably want:

(defn f []
  (let [a 1]
    a))

cfleming05:12:06

let creates local bindings, def creates global ones.

cfleming05:12:59

Note that the var for a will be created when f is called, not compiled.

jaen11:12:53

Hmm, is there any way to tell Cursive that I want completion in my build.boot file? It complains it's outside source root, but I would have to make my whole project a source root so it would be under one, and that's not really an option. Is there something that could be done, or is it a limitation of Cursive and/or IntelliJ?

onetom15:12:02

@jaen: im just learning intellij (by going thru all the video tutorials under https://www.jetbrains.com/idea/documentation/), but i also hit this issue... 😕 i guess the best u can do is to move out the logic from build.boot under you source path, but if u r just writing some #!/usr/bin/env boot script then it's not an option...

onetom16:12:01

I was reading these issues but it's still not very clear what is the current recommendation to deal with symbols defined by macros? https://github.com/cursive-ide/cursive/issues/1058 https://github.com/cursive-ide/cursive/issues/147 https://github.com/cursive-ide/cursive/labels/Macros One of the commenters mentioned that he is maintaining a gigantic (declare) somewhere in their source to deal with this but im not sure what does he mean by it. Where should I put that declare? Does he actually means multiple declares across various files? Can I somewhere specify which macros are defining symbols? (in a language facet maybe?) https://github.com/cursive-ide/cursive/issues/147#issuecomment-54643461

onetom17:12:49

Can I at least have tab completion for words which are already in the file/project? For example I've already have adi/insert! and adi/select all over my code base... I feel like Sublimes hyper-dumb auto-completion is more practical 😕

jaen17:12:21

Doesn't the usual completion (it should show by default, if not then try ctrl+space) work?

polymeris17:12:13

Thanks, @cfleming... I was trying to have a local binding that is resolved at compile time (a "constant").

onetom18:12:55

@jaen: nope... it doesnt suggest me unresolved symbols 😞

jaen18:12:21

Ah, yeah, I can see how that could be annoying

onetom18:12:37

neither datomic.api/q, nor adi/select are resolvable. that's kindof the meat of the application... 😕

onetom18:12:14

having so many positives renders this whole "highlight unresolvable symbols" functionality useless... i hope it wont interfere too much with other functionality based on static analysis

onetom18:12:39

ah and of course the => of midje are also highlighted...

cfleming19:12:22

@onetom: What’s the adi namespace you’re referencing there?

cfleming19:12:32

@jaen: I’ll add a fix for the build.boot file, so at least Cursive doesn’t complain about it being outside source roots.

jaen19:12:07

@cfleming: would completion work then or would that only hide the warning?

cfleming19:12:55

@jaen: That would only hide the warning. I need to investigate what’s required for proper boot file support.

onetom19:12:51

@cfleming: https://github.com/zcaudate/adi but it has the usual issue; generates a bunch of similar functions with macros...

jaen19:12:19

I see. I thought there would be some way to let it resolve the vars as if was a normal Clojure source.

onetom19:12:40

@cfleming: I found the 1st link about datomic but not the 2nd. thx, looking into it.

onetom19:12:12

+1 for boot support simple_smile

cfleming19:12:13

@jaen: I hope there will be, but I’m not sure how the indexing will work for files which are not under source roots.

cfleming19:12:37

Yeah, I want to get it in there because I’d like to try building Cursive with boot.

cfleming19:12:47

It’s a big job though probably.

jaen19:12:16

Right, I imagine getting it right is a bigger undertaking and the "generate project.clj" hack works more than well enough.

onetom19:12:31

what's your main motivation for switching to boot?

jaen19:12:48

I just hoped there would be some relatively easy way into ticking IntelliJ that build.boot is a Clojure source.

jaen19:12:14

But if it requires more proper work, then I'll just have to wait

onetom19:12:01

@jaen:

cd src; ln -s ../build.boot
and edit it from there 😉 seems to work for me

jaen19:12:08

Okay, that's one way to do it xD

onetom19:12:39

though set-env! deftask with-pre-wrap are all not resolvable. how would u solve that?

jaen19:12:56

I guess that makes sense, since boot.core is use 'd by boot when evaluating that file (or at least, it does something equivalent to that)

jaen19:12:06

So Cursive would have to be aware of that.

jaen19:12:36

Since requires are idempotent in Clojure then maybe (require 'boot.core) would work, but that sounds iffy.

cfleming20:12:12

@onetom: Currently I use Ant, and I don’t want to switch to lein. I’d like to use boot for Cursive because I like it conceptually and I’d like to understand how it works better in order to implement good support for it.