Fork me on GitHub

Hi! Could you help me please to start with calva? I already have project with next strings in the profiles.clj

{:profiles/dev  {:env {:database-url "jdbc:h2:./guestbook_dev.db"}}
 :profiles/test {:env {:database-url "jdbc:h2:./guestbook_test.db"}}}
where I have to add repl dependencies? like this?
{:profiles/dev  {:env {:database-url "jdbc:h2:./guestbook_dev.db"}}
 :profiles/test {:env {:database-url "jdbc:h2:./guestbook_test.db"}}
 :profiles/repl {:plugins [[cider/cider-nrepl "0.19.0"]]
                 :dependencies [[nrepl "0.5.3"]]}}


Thanks, I've found right way to do it

{:profiles/dev  {:env {:database-url "jdbc:h2:./guestbook_dev.db"}
                 :plugins [[cider/cider-nrepl "0.21.1"]]
                 :dependencies [[nrepl "0.6.0"]]}
 :profiles/test {:env {:database-url "jdbc:h2:./guestbook_test.db"}}}


Yes, that looks right, @maximtop. Check that stuff like Go to definition works. It's the litmus test for if the dependencies are correctly set.


Unfortunately Go to definition doesn't find anything


Have you loaded the file?


where I should load it?


nREPL seems to be connected


With the file active run the command Calva: Evaluate current file, (`ctrl+alt+v enter`).


May be I didn't start project correctly? Instead of lein run I should execute lein repl


but lein run launches repl and I can connect to it from cider in emacs


Yes. But nREPL seems to connect, so you probably have a project that includes the nrepl server also for the run.


What happened when you evaluated the file?


You might want to open the output panel and select Calva says from the drop down.


So you can see if something happens.


I can't find how to open Calva says


To remove the possible source of error with lein run try with lein repl instead.


It's in the View menu: Output.


Also I use cider/cider-nrepl 0.21.2-SNAPSHOT , might be worth trying.


No nrepl port file found. (Calva does not start the nrepl for you, yet.) You might need to adjust "calva.projectRootDirectory" in Workspace Settings.
Hooking up nREPL sessions...
Connected session: clj
Terminal created for: Clojure REPL
Figwheel not started:
  If you want a cljs repl, start Figwheel from the cljs REPL using: 
    (require '[figwheel-sidecar.repl-api :as fw])(fw/start-figwheel!)(fw/cljs-repl)
  and connect to the app with the browser. Then reconnect Calva.
cljc files will use the clj REPL.


I think that if you start with lein repl the port file will be created.


Evaluating file: /Users/maximtop/Documents/projects/guestbook/src/clj/guestbook/core.clj
=> #'guestbook.core/-main


Evaluating file: /Users/maximtop/Documents/projects/guestbook/project.clj
CompilerException java.lang.RuntimeException: Unable to resolve symbol: defproject in this context, compiling:(/Users/maximtop/Documents/projects/guestbook/project.clj:1:1) 


I don't know what should happen when you evaluate project.clj. You don't need to do that anyway.


But it seems evaluating core.clj didn't work either.


with lein repl connection established


So, if you bump that cider-nrepl dependency and start the repl with lein repl, then try evaluate core.clj again.


and Go to definition works as well


I'll try to bump up the version of nrepl


and lein run again


Help Calva by using lein repl.


Ok, thank you


> @bozhidar: does CIDER inject any tools.namespace dependencies, or how does that cider-refresh get powered? I have pointed @sasho.popov at remove-ns and feel a bit bad about that. A proper refresh is what Calva needs.


On a general note - cider-nrepl is the only thing that CIDER injects itself (+ the newest version of nREPL). Other plugins might inject extra middleware themselves, using the generic middleware injection mechanism provided by CIDER. I guess Calva should do something similar for VS Code plugins (in case someone wants to build something on top of Calva).


Does this answer the question you had about adding ops, @UHS6PHL31 ?


@maximtop , did you get things working?


Yes, with lein repl calva works basically. I don't have time to check thoroughly now how smooth is work with clojure in vscode. Thank you for help

metal 4

To anyone who is contributing, or considering that, I have pushed a dev branch where the latest Calva 2 stuff now lives. Unless it is an urgent bug fix for the currently released Calva, please base your contributions off of this branch. I have updated the dev instructions as well, please try the new instructions and let me know if I have gotten them right:

👍 4

@pez What are the big changes coming in Calva 2?


@bozhidar There are two major changes, somewhat connected. 1. A REPL window. 2. Jack-in for Leiningen, clj/deps and shadow-cljs. Anyone reading this channel can note that the Jack-in is the most important one for newcomers to Clojure and Calva. But for everyday use the REPL window creates a much better workflow than what we can create with those Terminals that are used today. Both features are highly CIDER inspired, btw. The REPL window is created by @mseddon, and I hope he will be writing about its making, because it is quite the achievement. VS Code has only one integration point for adding such a UI, and that is a WebView. So a LISP lexer and a Clojure editor has been written from scratch. It has enabled a new Paredit as well, which will, in time, make many other Calva features work much more reliably.


Sounds pretty cool!


😄 Right now everything is very unstable, though. It looked like almost ready to ship a week ago, but now I wonder. The optimist in me (which is impossible to kill) says we’ll soon find just one or two reasons causing the trouble.


Is Calva go to/peak at definition supposed to work with external libraries now? For example I am using Compojure (clean install) and it connects to REPL correctly, when I evaluate handler_test.clj, for example, the linter says Parse error: Unable to resolve symbol: deftest and Parse error: Unable to resolve symbol: is and when I choose go to definition I get No definition found for is


Have you required/referred those symbols?


Yes, it is supposed to work. Even some java symbols work.


I am testing on the automatically generated file:

(ns myproj.handler-test
  (:require [clojure.test :refer :all]
            [ring.mock.request :as mock]
            [myproj.handler :refer :all]))

(deftest test-app
  (testing "main route"
    (let [response (app (mock/request :get "/"))]
      (is (= (:status response) 200))
      (is (= (:body response) "Hello World"))))

  (testing "not-found route"
    (let [response (app (mock/request :get "/invalid"))]
      (is (= (:status response) 404)))))


Maybe I am missing some settings in my project.clj?

(defproject myproj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]]
  :plugins [[lein-ring "0.12.5"]]
  :ring {:handler myproj.handler/app}
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})


Hmm, it depends on what you have in your profiles.clj, because that project file does not contain the dependencies needed.


I still don't have profiles.clj. Are the needed dependencies documented somewhere?


Try starting the repl with this command and see if that works:

lein update-in :dependencies conj "[nrepl \"0.6.0\"]" -- update-in :plugins conj "[cider/cider-nrepl \"0.21.2-SNAPSHOT\"]" -- update-in "[:repl-options :nrepl-middleware]" conj "[\"cider.nrepl/cider-middleware\"]" -- repl


There is this: but I think there is some updating needed there.


Thank you @pez, that worked! I will try putting them in my profiles.clj


This might be enough:

{:repl {:plugins [[cider/cider-nrepl "0.21.2-SNAPSHOT"]]
        :dependencies [[nrepl "0.6.0"]]}}




Yep, working 😍

aw_yeah 4

Sat with a student trying to get her workflow going, using the "Calva says" evaluation commands rather than "Run selected text" (which goes to the terminal REPL and would be fine if it just didn't echo all of the evaluated code), and couldn't get it working... so I tried to show her on mine and now it doesn't work there either, even in a project for which it did previously. When I "Calva: Evaluate current file" it prints a message to Calva says, saying it's doing it, but then I get a popup that says "Cannot read property 'loadFile' of null". No other "Calva: Evaluate..." commands seem to do anything. Has an update broken this? For the time being we're back to evaluating everything outside of VSCode in terminal repls and the like


That's awful, @lspector . I'll have a look first thing tomorrow. Too tired right now.


Didn't mean to make you feel bad! But thanks for taking a look when you're up to it


Saved me the trouble of posting this 🙂

🙂 8

Better apply for 50% tjänstledighet :)

❤️ 4
👍 4