Fork me on GitHub
#calva
<
2021-01-01
>
Faris06:01:53

Thank you for all your work @pez and the rest of the Calva team!

❤️ 6
calva 3
practicalli-johnny11:01:47

Happy new year. Is there a list of Calva function names or some API docs? I'd like to add key bindings to VSpaceCode that call Calva functions. For example, defining , e f to evaluate a top level form by calling a function such as calva.evalCurrentTopLevelForm Alternative, I guess I could clone the Calva project and poke around and hopefully use auto-complere to discover function names. Thanks.

pez11:01:43

If you open the Calva extension in the Extensions pane, there is a tab there Feature Contributions and in there you find a section for Commands. Most commands take no arguments.

👍 3
practicalli-johnny00:01:20

This looks really useful, thanks. Is there a way in VS Code command pallet to show all the Calva related functions?

practicalli-johnny03:01:24

I have some of the most useful key bindings added to vspacecode and they seem to work very well. There are lots of useful key bindings in the Evaluation sub-menu There are still quite a few key bindings to add (I had forgotten how tedious and error prone writing json can be). I've only needed to over-ride the Calva escape key binding with space+escape . I've added a , e l key binding to clear all evaluations as well

pez10:01:19

Awesome! Let’s see when you come to paredit. Haha.

practicalli-johnny17:01:03

paredit seems just as straight forward. There seem to be more paredit commands than I am familiar with, so will require a bit of though about the keys to use The rewrap function is part of refactor in Spacemacs, but it makes sense to add it in structured editing using the same key binding as Calva - i.e. using the ({[" pscq keys I believe I can skip the selecting s-expressions of paredit, as VSpaceCode already has the same selection tools that seem to work.

pez11:01:29

I’d be very interested in publishing any bindings you produce that way on http://calva.io somewhere.

pez11:01:33

Some (I guess most) shortcuts are contextual, using the when clause. I don’t know what VSpaceCode allows, but anyway, to find the when clauses, open the Keyboard Shortcuts pane and look for the commands.

👍 3
practicalli-johnny17:01:53

Initially starting with just languageId, adding any when clauses if required

Eugen11:01:08

happy new year !

Eugen11:01:28

is there a way to reload compiled classes in Calva? Right now I just close vscode, open and re-jack-in . I compile java classes with gen-class that I need to reload

Eugen11:01:52

or at least a command to restart and re-jack in without closing vscode ?

roelof11:01:57

@eugen.stan happy new year from the Netherlands

parrot 6
🎆 3
pez12:01:30

Happy New Year, @eugen.stan! I’m not sure what it takes to reload compiled classes. But StackOverflow suggests to leave a (comment (compile ')) in the file. Where the comment hides the compile command from itself. Then you should be able to use Calva’s Evaluate Top Level Form on that.

👍 3
pez12:01:57

To restart the REPL, if it is started with Jack-in, you can use the Disconnect REPL command. I’m not sure that is going to stay like that, because it is a bit weird that disconnect also jacks out, I think. But what you can rely on to remain is that if you jack-in again, the process will start with jacking out. So I change my suggestion to “Just jack in again” 😃 .

👍 3
pez14:01:02

New Year’s release of Calva, v2.0.144, with these changes: • https://github.com/BetterThanTomorrow/calva/issues/915https://github.com/BetterThanTomorrow/calva/issues/910https://github.com/BetterThanTomorrow/calva/issues/904 See these docs for info about loading current namespace in the repl window https://calva.io/output/#load-current-namespace

👍 3
🎆 6
roelof14:01:53

installling right now

calva 6
roelof15:01:16

are there here some people who work in linux ?

Eugen17:01:28

I work on linux

roelof17:01:11

oke, I try to find out if there is a problem wth my setip or a problem in a crux tutorial

roelof17:01:24

are you willing to try some code ?

Eugen17:01:47

let's write here

roelof17:01:04

this works not on my computer and works on the computer of the maker of this tutorial

roelof17:01:28

;; tag::require[]
(ns tutorials.crux.earth
  (:require [crux.api :as crux]))
;; end::require[]
;; tag::node[]
(def node (crux/start-node {}))
;; end::node[]
;; tag::manifest[]
(def manifest
  {:crux.db/id :manifest
   :pilot-name "Johanna"
   :id/rocket "SB002-sol"
   :id/employee "22910x2"
   :badges ["SETUP"]
   :cargo ["stereo" "gold fish" "slippers" "secret note"]})
;; end::manifest[]
;; tag::submit[]
(crux/submit-tx node [[:crux.tx/put manifest]])
;;=>#:crux.tx{:tx-id 0, :tx-time #inst "2020-06-18T13:54:08.375-00:00"}
;; end::submit[]
;; tag::check[]
(crux/entity-history (crux/db node) :manifest :asc)
;;=> {:crux.tx/tx-time #inst "2020-06-18T13:54:08.375-00:00",
;;    :crux.tx/tx-id 0,
;;    :crux.db/valid-time #inst "2020-06-18T13:54:08.375-00:00",
;;    :crux.db/content-hash #crux/id "0ab888b62775eea2eb2fffe10c9f6bfbf661a792"}
;; end::check[]

Eugen17:01:39

are you sure? code samples do not always work

roelof17:01:59

yep, I talked with her the whole afternoon and we cannot solve it

Eugen17:01:41

ok, so i need the dependency and also the runing db?

Eugen17:01:09

please share the crux dependency line

roelof17:01:17

I have this on my project.clj file

:dependencies [[org.clojure/clojure "1.10.0"]
                 [juxt/crux-core "RELEASE"]]

Eugen17:01:07

does this help ?

roelof17:01:04

yep., it also seems to work on your computer

Eugen17:01:18

have you restarted you repl?

roelof17:01:37

several times

Eugen17:01:40

you are using def and from what I kno that is not the best way to handle it

Eugen17:01:46

I'm using clojure 1.10.1

Eugen17:01:10

have you restarted your computer ? 🙂

Eugen17:01:52

java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.275-b01, mixed mode)

Eugen17:01:10

uname -a
Linux daos-495 5.9.0-5-amd64 #1 SMP Debian 5.9.15-1 (2020-12-17) x86_64 GNU/Linux

roelof17:01:30

`

java -version
openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Eugen17:01:36

well, good luck, I hope it helps

roelof17:01:05

roelof@DESKTOP-GKSR5BK:~/banking$ uname -a
Linux DESKTOP-GKSR5BK 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Eugen17:01:14

tried with java 11 also

roelof17:01:43

thanks, im out of ideas

Eugen17:01:17

have you tried to run it from a main (outside of REPL)?

Eugen17:01:41

it does seem to be a setup issue

roelof18:01:10

no, I do not know how I then can run it

Eugen18:01:38

give me a few minutes

roelof18:01:51

take your time

Eugen18:01:01

do you have clojure / clj tools installed?

roelof18:01:41

when I try this :

(defn -main[](
            (crux/entity-history
 (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true})
            ))

(-main)

roelof18:01:52

it stil seems to hang

Eugen18:01:37

you should not call (-main)

roelof18:01:10

I wil not doing anything till you say so

roelof18:01:18

?? I do not have any or only 1 main in this project

Eugen18:01:57

ok, then make leiningen run this main

Eugen18:01:01

(defn -main []
  (let [node (crux/start-node {})
        manifest {:crux.db/id :manifest
                  :pilot-name "Johanna"
                  :id/rocket "SB002-sol"
                  :id/employee "22910x2"
                  :badges ["SETUP"]
                  :cargo ["stereo" "gold fish" "slippers" "secret note"]}]
    (crux/submit-tx node [[:crux.tx/put manifest]])
    (crux/entity-history (crux/db node) :manifest :asc)
    ))

roelof18:01:24

oke, how do I do that

roelof18:01:49

in repl I see this output : #'tutorials.crux.jupiter/-main

Eugen18:01:57

you shuould define a :main https://leiningen.org/

Eugen18:01:07

(defproject  "1.0.0"
  :description "Generate static HTML for "
  :dependencies [[enlive "1.0.1"]
                 [cheshire "4.0.0"]
                 [org.markdownj/markdownj "0.3.0-1.0.2b4"]]
  :main leiningen.web)

Eugen18:01:23

define the ns that contains the -main function

roelof18:01:39

did :

(defproject practicalli/crux-demo "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [juxt/crux-core "RELEASE"]]
  :main tutorials.crux.jupiter
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

roelof18:01:47

hmm, does not work

roelof18:01:24

I have this in my file

(defn -main []
  (let [node (crux/start-node {})
        manifest {:crux.db/id :manifest
                  :pilot-name "Johanna"
                  :id/rocket "SB002-sol"
                  :id/employee "22910x2"
                  :badges ["SETUP"]
                  :cargo ["stereo" "gold fish" "slippers" "secret note"]}]
    (crux/submit-tx node [[:crux.tx/put manifest]])
    (crux/entity-history (crux/db node) :manifest :asc)
    ))
do this in the repl
tutorials.crux.jupiter=> (require 'tutorials.crux.jupiter)
nil
tutorials.crux.jupiter=> (tutorials.crux.jupiter/-main)
Syntax error compiling at (form-init6925765827011711183.clj:1:1).
No such var: tutorials.crux.jupiter/-main

Eugen18:01:25

what does lein run give ? (put a println inside main fn

Eugen18:01:47

defn -main

Eugen18:01:57

I gave you the code above

roelof18:01:44

Gives

Can't find 'tutorials.crux.jupiter' as .class or .clj for lein run: please check the spelling.
Exception in thread "main" Syntax error compiling at (/tmp/form-init17099874963866708404.clj:1:74).

roelof18:01:09

yep, and that one I use. the one you gave me

Eugen18:01:05

once you have that working, you can switch to your crux sample

roelof18:01:23

chips, wrong file

roelof18:01:27

this one works fine

roelof18:01:50

can you try this one

roelof18:01:30

(ns practicalli.earth
  (:require [crux.api :as crux]))
(def node (crux/start-node {}))
(defn easy-ingest
  "Uses Crux put transaction to add a vector of documents to a specified
  node"
  [node docs]
  (crux/submit-tx node (mapv (fn [doc] [:crux.tx/put doc]) docs)))
(crux/submit-tx
 node [[:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:encompass-trade]}
        #inst "2110-01-01T09"
        #inst "2111-01-01T09"]
       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:encompass-trade :blue-energy]}
        #inst "2111-01-01T09"
        #inst "2113-01-01T09"]
       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:blue-energy]}
        #inst "2113-01-01T09"
        #inst "2114-01-01T09"]
       [:crux.tx/put {:crux.db/id :kaarlang/clients
                      :clients [:blue-energy :gold-harmony :tombaugh-resources]}
        #inst "2114-01-01T09"
        #inst "2115-01-01T09"]])
(crux/entity-history
 (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true})

roelof18:01:51

with me it hangs on the entity-history ?

roelof18:01:44

See you did

roelof18:01:52

sorry I lost it

roelof18:01:00

but when I do you main now

roelof18:01:05

I see this :

Caused by: java.lang.Exception: Cannot find anything to run for: practicalli.jupiter

Eugen18:01:40

sorry I don't have time to try out things

Eugen18:01:15

I think the last error is because you don't have a -main fn

roelof18:01:08

oke, it worked now

roelof18:01:11

I see hello

roelof18:01:37

because I added a (print "hello) to the main

roelof18:01:53

bu that on is not the code that fails on my computer

Eugen18:01:09

yeah, sorry I can't help you there

roelof18:01:19

that is this code :

(crux/entity-history 
  (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true})

roelof18:01:48

and with this code ;

(defn -main []
  (print "Hello")
  (crux/db node #inst "2116-01-01T09")
 :kaarlang/clients
 :desc
 {:with-docs? true}) 

roelof18:01:09

I see hello and then a waiting cursor for a vey long time

bringe20:01:35

If you can provide a complete project in a github repo that can be pulled down and the steps you take up until you have an issue, it may be easier for someone to help, so that you can be sure things are the same at least code-wise, and be able to know if it's some external setup issue.

roelof21:01:05

There is a complete github repo and I already noticed that on 2 persons it worked and on my the same code does not work

bringe00:01:22

Ah, yeah definitely seems like some environment issue

roelof10:01:20

yep, and very very difficult to find out what causes the issue

roelof17:01:28

expeciallty the entity-history part

roelof17:01:49

with my it hangs and with the tutorial maker it works