Fork me on GitHub
#calva
<
2021-01-30
>
grumplet00:01:13

I’d like to automate cljs/figwheel-main/webpack a little better using deps. 1. Using a fig alias I can jack-in with Figwheel Main and compile. 2. With another alias I can then start a figwheel main repl that is connected to the editor. Between (1) and (2) I want to run webpack at least once. It looks like I can get access at this point by adding a :post-build-hooks vector in figwheel-main.edn. I feel it should be possible to supply a clojure function there which shells out to call webpack.

grumplet00:01:36

:post-build-hooks wants a namespaced function to call. However I can’t get this to resolve correctly - e.g. if I give it [user/foo] it can’t resolve namespace user. It would be simple if I understood how the classpath was defined when the :post-build-hooks functions are resolved. This might be a figwheel-main issue, but it may also be a Calva defined classpath. Does anybody have an idea how to put functions on the classpath at that point?

grumplet00:01:18

OK - answering my own question - I guess the classpath there is the one built by Calva Jack-in which is echoed in the terminal.

grumplet00:01:18

Now is there a way to add source paths to that?

pez08:01:51

Calva does not build any classpaths. That will be done by Leiningen or the clojure CLI tool, depending on which one you use. If you define a profile (lein) or an alias (clj) then you can select these at Calva Jack-in and the command line will be built such that it invokes the profile/alias. I tried to explain the Jack-in feature a bit here: https://calva.io/jack-in-guide/

grumplet10:01:53

Sorry - I was thinking out loud there. Yes I agree, but Calva does build the CLI command line and passes it dependencies to go on the classpath using clojure -Sdeps. Maybe this output will clarify the problem I’m trying to solve - I can’t see how to get ‘user’ on the classpath. I have :post-build-hooks [user/foo]in figwheel-main.edn. user/foo is a placeholder for a function that will run webpack. I see this:

> Executing task: clojure -Sdeps '{:deps {nrepl {:mvn/version "0.8.2"} cider/cider-nrepl {:mvn/version "0.23.0"} clj-kondo {:mvn/version "2020.04.05"} cider/piggieback {:mvn/version "0.4.2"}}}' -A:fig:dev <
...

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
2021-01-30 00:21:41.178:INFO::main: Logging initialized @3750ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Validating figwheel-main.edn
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel:WARNING] Compile Exception: Could not locate user__init.class, user.clj or user.cljc on classpath.  
post-build-hook-fn: There was an exception while requiring the namespace 'user while trying to load the var 'user/foo

grumplet10:01:18

There’s probably a simpler way to tackle this 🙂

pez11:01:50

I’m not sure I am following. But I get this to work. 1. Create a directory env as a sibling to src 2. Put a file user.clj there with (ns user) and (defn foo [arg] (println "Hello world, args: " arg)) 3. Add "env" to :extra-paths of the alias I am using 4. Add user/foo to :post-build-hooks

pez11:01:46

I also see that you are using the alias :fig which I think often contains :main-opts . If so that will not chime with jack-in, unless those opts start the nrepl server. Try without selecting that alias. (Even if this should be unrelated to the problem with finding user/foo.)

grumplet10:02:37

Thanks@pez, Stupidly I’d tried that earlier but with source-paths rather than extra-paths. With extra-paths It no longer barfs about the user namespace, but I’m not seeing the println anywhere. And fair point - my fig alias is now misnamed as its :main-opts moved elsewhere.

pez11:02:09

You’re welcome. I’m glad I got to try that out and learn a bit about these settings. As for the printout. Don’t recall where I found them. Maybe in the Jack-in terminal? Maybe in the (wrongly named) Output channel Calva Connection Log

grumplet10:02:20

Don’t spend time on this - but I tried all those. No errors, but nothing in any log as far as I can see.

pez10:02:35

Haha, try to stop me. 😃 But not right now, working for food time.

grumplet18:02:02

Just picked up on this again when I saw that missing Hello World suddenly appear at startup. So the println is working now and outputting to the REPL buffer after the build as it should. 🙂

grumplet18:02:53

When I get some time I’ll see if I can get it to do something sensible with the npx webpack call.

calva 3
Eric Uitbeijerse09:01:05

Hi all, I joined this channel about 2 wks ago and I must say that I'm very impressed by how active and responsive this community is. Already 2 of my issues fixed and I love Calva (and the extensions it uses). You are professionals and make me very happy! 😄 Kudos to all of you!🙌🙏:thumbsup:

❤️ 14
calva 18
Cris B00:01:35

To echo your comment a bit, @eric.uitbeijerse- I started learning Clojure mid last year, then that project fell aside for the usual kinds of reasons, and now I'm having another crack at it. I was a slightly unlikely Calva user. I had once been an Emacs enthusiast, then switched to IntelliJ Idea & Appcode mainly because of the kinds of projects I was working on. I came to really love the Jetbrains platform, and had never thought much of VSCode, so Cursive was a natural fit. I tried it out and found it great (Colin Fleming has done a terrific job with it). I had a nagging feeling though that I would like to be able one day if I had time & ability to to contribute to the clojure IDE I was using. Given VSCode's reach and Calva being open source, I tried the VSCode/Calva solution for a while. Liking IntelliJ so much, I fully expected this to be a bit of a sacrifice. Well it wasn't. Sure, it had some bugs and missing features (what doesn't?), but it was generally pleasant to use and development was proceeding fast. Now coming back to learning Clojure after a few months, I find Calva development still going really strong. Anyway that's a huge preface (sorry if it's a tad indulgent) to thanking @U0ETXRFEW and @U9A1RLFNV (the 2 names I've noticed - I'm sure there are others) for Calva. It must be a ton of work, which we get the benefit of. And VSCode's growing presence in the developer community makes Calva genuinely significant. Thanks! :spock-hand::skin-tone-2:

❤️ 6
bringe00:01:39

Thanks @UUDGHH2J1 and @eric.uitbeijerse! It's a pleasure to be a part of providing a good Clojure experience in VS Code, and a pleasure to be part of this dev community.

pez09:01:02

Wonderful. And super extra great that you both contributed to Calva’s shiny Review section at the marketplace. ❤️ As for who to thank: A lot of people! @bozhidar and his CIDER team comes to mind, of course, since Calvados is distilled from Cider. And now lately we are sourcing the power of #lsp and, by that proxy, also #clj-kondo which brings in all the many hours of hacking and supporting put in by @borkdude, @ericdallo and @snoe to serve the Calva users.

❤️ 6
clojure-lsp 6
calva 9
clj-kondo 3
cider 6
hyper-clap 3
pez09:01:01

Wow, @eric.uitbeijerse It is a pleasure to try to contribute to Clojure success, because the community is so welcoming, helpful, and interested in helping each other succeed. It makes me happy to hear that we Calva peeps are following the example. Thanks for sharing that!

alekszelark18:01:42

Just reported two printing related issues. It would be nice to get them fixed. 🙏

Hagenek20:01:16

Quick question for Vs code and Calva users. How do you stop evaluating when your functions enters an infinite loop?

clyfe20:01:29

What OS you on?

Hagenek20:01:58

https://app.slack.com/team/USMLDU9BR  [9:07 PM] Tried Ctrl-Alt-C Ctrl-Alt-D, but that does not seem to do the trick. (Should stop evaluations). (edited)

clyfe20:01:32

How about: Ctrl+Shift+P -> Calva: Interrupt Running Evaluations ?

clyfe20:01:25

(I'm on Ubuntu/Gnome & Ctrl+Alt+D is show desktop)

Hagenek20:01:37

It might be that there is a sluggishness in the system, that it actually interrupts it but text keeps coming into the REPL

Hagenek20:01:48

I will stop it and wait and see if it stops coming text in the REPL after a while

pez20:01:46

Yes, sluggishness. If you are printing from that loop that will not stop until the print queue use empty.

pez20:01:03

There's a command for that. Iirc somethng like Interrupt running evaluation

clyfe20:01:01

I need a good story for customization; can't do well w/o my nitty gritty keyboard behaviors. a) I'm thinking: Calva to expose pretty much all it can (mirrored doc map, paredit fns, etc) in it's public API. That's the way to allow people to customize to their workflows. We can tag: "API subject to change" and things can break from time to time. That RH "never break API" is not the mother lode of good things, there are cases like here. b) Maintain a series of patches applied on releases from time to time. c) A setting flag "Calva: Natural mode" (killSpace, backspaceNoFormat) but the rabbit hole may be deep here.

clyfe20:01:53

Probably a) with a well thought API is a good plan.

pez09:01:02

Wonderful. And super extra great that you both contributed to Calva’s shiny Review section at the marketplace. ❤️ As for who to thank: A lot of people! @bozhidar and his CIDER team comes to mind, of course, since Calvados is distilled from Cider. And now lately we are sourcing the power of #lsp and, by that proxy, also #clj-kondo which brings in all the many hours of hacking and supporting put in by @borkdude, @ericdallo and @snoe to serve the Calva users.

❤️ 6
clojure-lsp 6
calva 9
clj-kondo 3
cider 6
hyper-clap 3