Fork me on GitHub
#calva
<
2022-05-15
>
pez11:05:15

Dear Calva friends. Joyride lets you do stuff like add a Restart clojure-lsp command to VS Code using a keybinding definition like this one:

{
        "key": "",
        "command": "joyride.runCode",
        "args": "(require '[promesa.core :as p]) (p/do (vscode/commands.executeCommand \"calva.clojureLsp.stop\") (vscode/commands.executeCommand \"calva.clojureLsp.start\"))"
    },
Come on, join the #joyride!

pinkfrog13:05:35

It seems Calva breaks the disable wordwrap option in vscode. After I evaluate some code that has a long output, line is not wrapped.

pez14:05:48

Output results are never wrapped, if that is what you mean.

pinkfrog14:05:05

Yes. And that breaks the vscode wrap setting.

pinkfrog14:05:27

Even if we go on to edit the files, The wrap is not restored.

pez15:05:18

However, it also seems we can mitigate it, by truncating inline results. Please file an issue.

pinkfrog00:05:12

Great. Will do.

Erich Wolodzko23:05:32

Hey Calva community! This is certainly a beginner's question, but it seemed more related to Calva. Let me know if there is a better place to post. Is there a place in the getting started or on the website that explains the correct workflow for updating an existing REPL session after adding a new dependency to a project? I haven't managed to find anything yet — although admittedly I probably don't know the right thing to search for. The situation is that I just switched from the https://calva.io/getting-started/ to creating my first Hello World lein app project. Everything was working great until I tried to add a dependency to my project.clj file, and now my REPL evaluations are failing with Syntax error compiling at... No such namespace: io. It makes sense that my REPL session would be stale, but what I've tried so far to update it — evaluating the updated (ns... ) form at the top of my file, selecting Calva: Load Current File and Dependencies — both fail with a different compiler FileNotFoundException exception. The confusing thing is that I've done lein deps on the command line, and I also checked that lein run works on the command line, so I don't know why my REPL in VS Code is failing to evaluate. I'm not sure what else is relevant to share at this point. I figured maybe there is part of the guide that I've missed that I can read up on. Probably I could just restart VS Code, but hoping to learn a better way. 🙂

seancorfield00:05:22

There are ways to add dependencies to a running REPL but they're not widely used -- most folks tend to just restart their REPL.

seancorfield00:05:13

Personally, I use a branch of tools.deps.alpha so that I can call add-libs on that branch and load additional dependencies without restarting my REPL. That's with the Clojure CLI.

seancorfield00:05:02

I haven't used Leiningen for years for projects but I believe it bundles Pomegranate so you can use that from the REPL to load additional libraries. Maybe the Pomegranate docs have examples?

seancorfield00:05:22

Here we go, based on what's in the Pomegranate README:

(! 521)-> lein repl
nREPL server started on port 61507 on host 127.0.0.1 - 
...
user=> (require 'hiccup.core) ; fails: Hiccup is not in project.clj
Execution error (FileNotFoundException) at user/eval2043 (REPL:1).
Could not locate hiccup/core__init.class, hiccup/core.clj or hiccup/core.cljc on classpath.
user=> (require '[cemerick.pomegranate :refer [add-dependencies]])
nil
user=> (add-dependencies :coordinates '[[hiccup "RELEASE"]]
  #_=>                   :repositories (merge cemerick.pomegranate.aether/maven-central
  #_=>                                        {"clojars" ""}))
{[hiccup "2.0.0-alpha2"] #{[org.clojure/clojure "1.5.1"]}, [org.clojure/clojure "1.5.1"] nil}
user=> (require 'hiccup.core)
nil
user=> 

Erich Wolodzko01:05:11

Thank you Sean! The add-dependencies functionality looks interesting. Honestly I'm perfectly happy starting my REPL if that's the common workflow. It just wasn't obvious to me if I should be able to do it, and I was trying to figure out if I was doing something wrong. By the way, separately in response to you side comment, I don’t have any particular affinity toward Leiningen, but after becoming somewhat confused or daunted trying to figure out what it would look like to use more recent tolls on Windows, I ended up concluding that lein might be a safer and easier way to get started on Windows as of now for a newcomer.

seancorfield01:05:19

If you're comfortable with the command line, my recommendation on Windows is to use WSL2 - that's how I do all my work on Windows. VS Code, Calva, Remote extension. Then all code and REPLs on Ubuntu via WSL2

Erich Wolodzko01:05:32

Ah ok, I’ll give that a try at some point. I do use WSL2/Ubuntu for other stuff.

seancorfield19:05:00

@U02F6BHUZH9 Feel free to DM me if you get stuck with the Clojure CLI etc on WSL2/Ubuntu.

Erich Wolodzko00:05:18

Thank you! Will do. Unfortunately I'm currently limited to doing this in my leisure time, but if/when I get a good enough chunk of time to give it a real attempt I will.