Fork me on GitHub
#calva
<
2019-04-10
>
maximtop08:04:53

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"]]}}

maximtop08:04:53

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"}}}

pez09:04:25

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.

maximtop09:04:54

Unfortunately Go to definition doesn't find anything

pez09:04:18

Have you loaded the file?

maximtop09:04:43

where I should load it?

maximtop09:04:09

nREPL seems to be connected

pez09:04:10

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

maximtop09:04:20

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

maximtop09:04:03

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

pez09:04:56

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

pez09:04:34

What happened when you evaluated the file?

pez09:04:19

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

pez09:04:38

So you can see if something happens.

maximtop09:04:09

I can't find how to open Calva says

pez09:04:22

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

pez09:04:39

It's in the View menu: Output.

pez09:04:44

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

maximtop09:04:16

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.

pez09:04:56

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

maximtop09:04:49

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

maximtop09:04:19

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) 

pez09:04:05

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

pez09:04:48

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

maximtop09:04:18

with lein repl connection established

pez09:04:21

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

maximtop09:04:52

and Go to definition works as well

maximtop09:04:53

I'll try to bump up the version of nrepl

maximtop09:04:01

and lein run again

pez09:04:16

Help Calva by using lein repl.

maximtop09:04:14

Ok, thank you

bozhidar09:04:26

> @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.

bozhidar09:04:06

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).

pez10:04:09

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

pez10:04:25

@maximtop , did you get things working?

maximtop10:04:30

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
pez11:04:26

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: https://github.com/BetterThanTomorrow/calva/wiki/How-to-Contribute

👍 4
bozhidar16:04:28

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

pez16:04:05

@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.

bozhidar16:04:24

Sounds pretty cool!

pez16:04:35

😄 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.

adam18:04:23

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

pez18:04:07

Have you required/referred those symbols?

pez18:04:49

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

adam18:04:10

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)))))

adam18:04:43

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}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}})

pez18:04:59

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

adam18:04:11

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

pez18:04:31

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

pez18:04:48

There is this: https://github.com/BetterThanTomorrow/calva/wiki but I think there is some updating needed there.

adam18:04:36

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

pez18:04:15

This might be enough:

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

pez18:04:45

^edited^

adam18:04:16

Yep, working 😍

aw_yeah 4
lspector20:04:39

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

pez20:04:49

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

lspector20:04:25

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

orestis10:04:35

Saved me the trouble of posting this 🙂

🙂 8
slipset20:04:16

Better apply for 50% tjänstledighet :)

❤️ 4
👍 4