Fork me on GitHub
#calva
<
2021-12-23
>
orestis08:12:54

Good morning, I'm trying "Evaluate form and replace result" but in my case I want to avoid the *print-length* limitation. I tried binding it to false but it doesn't work for Calva.

pez08:12:14

Not sure, but we could be using the calva.prettyPrintingOptions: maxLength option for this. There is no separate setting for that for the eval-replace case at least…

orestis08:12:54

Thanks! The pretty-printing is nice otherwise it ends up in a huge line. I will try disabled it temporarily.

orestis09:12:24

It worked 🙂

pez09:12:54

Setting maxLength to null should give you all the elements, but otherwise keep pretty printing things. Was that what you tried?

orestis08:12:22

(That is, the form I'm trying to evaluate results in a big list, and I want that entire list printed out)

zeitstein10:12:30

In attached image, I evaluate a form first in a clj repl, then I switch to a cljs repl and evaluate the same form again. The image features two unexpected things I regularly come across: 1. The prompt still says clj:... even though I switched to a cljs repl. I see this is actually the case even if I evaluate a purely cljs file (so can only connect to a cljs repl). 2. The result does not pretty print in the cljs repl. Are these issues or are my expectations wrong or I'm doing something wrong? Thanks!

pez10:12:27

Howe do you switch to a cljs repl?

zeitstein10:12:08

Clicking on the switcher in the status bar.

pez10:12:26

I merged a PR that might fix that some days ago. We should release that fix.

pez10:12:00

About the pretty printing. I'm not sure if it is supposed to work. But if you switch to client side pretty printing, that should work. (The calva pretty print engine.)

zeitstein10:12:12

> I merged a PR that might fix that some days ago. We should release that fix. Sorry, was running a previous version. Updating to the latest, don't have that problem anymore.

pez10:12:53

Ah, so maybe we have released it. 😂

zeitstein10:12:37

> But if you switch to client side pretty printing, that should work. (The `calva` pretty print engine.) It does, thanks. So, when working in cljs I should manually change the setting to calva. When working in clj I switch back to pprint?

pez10:12:56

I use calva all the time.

zeitstein10:12:24

Right, sorry. What I'm really asking is: is that the only way to switch back and forth between them?

pez10:12:48

But I actually don't know if the server side engines should work.

pez10:12:38

If it is something we can't expect to work we could make Calva always use client side for cljs.

pez10:12:35

The only way to switch engines is through settings. I think there are extension that make toggling settings convenient.

👍 1
zeitstein10:12:37

Well, pprint works for me sometimes on the client side, but not always.

pez10:12:35

You could check the nrepl log and see if it has any clues.

zeitstein10:12:35

I think it usually fails when there are tagged literals? Like in the image above.

zeitstein10:12:42

Anyway, thanks for your kind and quick help!

pez12:12:49

Ah, yes, maybe when the data readers are not available to the JVM repl (where the nREPL server runs) it doesn’t work. On the Calva side of things that doesn’t matter, because it is all static.

Gerome11:12:37

Hey everyone! I'm wondering about repl-driven development in the frontend. I'm working with re-frame a lot and I was wondering how to integrate the repl here. Could you share some insight into your workflow?

bringe01:12:26

Hello! I work with re-frame frequently lately. Can you describe what you mean by “integrate the repl”? What’s your JS/CLJS target? Is it a browser app, a nodejs app, a react-native app, something else (if there is)? In my case, with a react-native app, using shadow-cljs, I run Calva’s jack-in command and select shadow-cljs and the build I want to connect to. Once the repl starts, in order to evaluate code in the repl, your runtime needs to be connected. In my case, my runtime is my react-native app, running in an emulator (for example). Once the app is running, I can evaluate code from my editor, or from the repl prompt in the Calva output window.

Gerome11:12:45

Yes! This is exactly what I'm asking for. More specifically though, I'd like to know how you use the repl in actual development. I went through the calve hello_repl tutorial a couple of weeks ago and the stuff I learned seems cool. But I'm wondering if people actually use these things when hot reloading is already pretty immediate interaction.

bringe22:12:54

Yes, it depends on what you’re trying to do perhaps, but the repl is still valuable even when using hot reloading. For example, I might pull in a library and want to test some calls using that library from the repl, without integrating the code into my app first.

bringe22:12:23

Maybe I want to make direct http calls to some service to inpect the data I get back using the repl.

bringe22:12:04

Or, I want to test a transformation with the repl before adding the transformation to my app code. For example:

(-> http-response
    :data
    (do-something))

bringe22:12:21

And then once I have the final form I want the data in for my app, I copy the code into some function used by the app.

Gerome05:12:30

That makes total sense, thank you!

bringe21:12:46

You’re welcome!

bortexz15:12:13

Not sure if this is a question here or #clj-kondo, I have imported a lib (https://github.com/Engelberg/better-cond) that has a clj-kondo options for how to lint the macros, but when I use those macros they are not properly linted and clj-kondo report errors. Is there something I need to do/add for this to work?

borkdude15:12:40

@bertofer are you using the newest version of better-cond?

bortexz15:12:52

yes, 2.1.2

borkdude15:12:37

what is the code that doesn't work for you?

bortexz15:12:03

something like this:

borkdude15:12:36

hmm, is this better-cond.core/when-let?

borkdude15:12:00

can you paste a repro of this so I can try it locally?

bortexz15:12:07

yes, this is my import

(:refer-clojure :exclude [sorted-map sorted-map-by sorted-set sorted-set-by first last when-let])
  (:require [clojure.data.avl :as avl]
            [better-cond.core :refer [when-let]])

borkdude15:12:38

have you upgraded clojure-lsp to the most recent one?

borkdude15:12:50

or: can you paste the clojure-lsp and clj-kondo versions?

bortexz15:12:43

How can I know them from calva/vscode?

borkdude15:12:47

also, check if there is .clj-kondo/better-cond/better-cond

borkdude15:12:56

if not, then the config isn't imported

borkdude15:12:08

This is something that @U0ETXRFEW might now (the versions)

bortexz15:12:01

also, check if there is .clj-kondo/better-cond/better-cond
if it should be inside my project’s clj-kondo, it isn’t

borkdude15:12:28

have you tried restarting your vscode?

bortexz15:12:25

well, that worked 😄

bortexz16:12:37

I am having another problem now, it seems it’s linting it as a normal when-let now:

(ns volus.dev
  (:refer-clojure :exclude [when-let])
  (:require [better-cond.core :refer [when-let]]))

(when-let [a 1
           b 2]
  (println (+ a b)))
this tells me when-let should have exactly 2 forms

borkdude16:12:45

hmm, can you try {:lint-as {better-cond.core/when-let clojure.core/let}

borkdude16:12:48

in your own config

borkdude16:12:59

if that works, then this should be improved in better-cond

bortexz16:12:39

yes, that works

bortexz16:12:04

It seems better-cond config has a bug, here:

better-cond.core/when-let clojure.core/when-let

bortexz16:12:25

I can open an issue/pr if needed

bortexz16:12:25

done, was a bit delayed by my mess on local git credentials https://github.com/Engelberg/better-cond/pull/21

Brian Alexander19:12:05

I'm new to Calva, fresh Vscode install, fresh Calva, fresh MacOS and I'm getting this weird bug where syntax highlighting doesn't update unless I close the file and reopen. Essentially the syntax highlighting is fixed to the line number and doesn't follow the actual code it refers to. Anyone seen this before?

Brian Alexander19:12:33

For example in this photo str has three different colors..

Brian Alexander20:12:19

If I open a directory with less files, it seems to work. Could be a file watcher issue? Coworker in same folder doesn't have the issue though

pez20:12:52

Could this be a semantic tokens issue, @UKFSJSM38 ?

ericdallo20:12:42

yeah, sounds like a conflict of semantic highlighting and maybe some other plugin

JR21:12:58

Not sure it’s related, but you might see if it helps

Brian Alexander22:12:48

I rolled back the versions and 2.0.201 (6months ago) is working as expected. I also tested 2.0.211 (3 months) and it still had the issue. I'll try the above fix this later tonight and report back. Thanks!