Fork me on GitHub
#calva
<
2023-04-01
>
orestis13:04:31

An obscure question regarding stdout and stderr in calva.output - I'm converting away from my bespoke bin/dev.sh script to afterCLJReplJackInCode that does two things: 1. Start the web application 2. Shell out to gulp to watch some css When doing the exact same things from the Terminal, (using clojure for the shelling out), I can see output from the CSS build, but when doing the same from Calva I can't see anything. I checked and Calva prints stderr as commented lines, so it might be something in the way that I shell out that works in the Terminal but not in Calva?

orestis13:04:00

I've found it:

(.println (System/out) "foo")
(.println (System/err) "foo")
neither of these produce something in calva.output

pez13:04:00

Are you using JackIn, or are you connecting to a running REPL?

pez13:04:41

Do you see any output in the jack-in terminal?

orestis13:04:47

whereas (println "foo") works

orestis13:04:06

Ah yes, the jack-in terminal shows the output

pez13:04:57

That might be what happens when you do it using clojure. It outputs both to the same terminal.

orestis13:04:55

Hm, then I need to figure out how to send the CSS build output to *out* instead.

pez13:04:54

How do you shell out?

orestis13:04:19

conch - and I'm using stream-to-out, looks like there's alternatives

pez13:04:56

Hopefully some option there to get stdout and stderr from the process returned.

orestis13:04:53

I'm using (stream-to-out p :out) , changing to (stream-to p :out *out*)

pez13:04:44

Never heard of conch, but cool if that works.

orestis13:04:59

doesn't seem to work 😕

orestis13:04:46

There might be some indirection that gets lost if conch is grabbing *out* before calva takes over?

pez13:04:58

clojure.java.shell maybe works for you?

orestis14:04:38

No, it's a background process that needs to stay running and I need to say compilation errors.

pez14:04:37

Tricky. Maybe some nrepl middleware can fix it…

pez14:04:02

All I know is that Calva’s nrepl client never gets it.

orestis14:04:16

Let me try something, could it be that it is affected because the code is launched in the afterCLJReplJackInCode?

orestis14:04:22

No, it's the same. I will ask the nrepl channel.

orestis14:04:44

This is similar in e.g. Java libraries that write to System.out directly.

pez14:04:23

Please let us know what you find out. I remember investigating this a bit long ago. But I didn’t know a thing about Clojure back then, so couldn’t make sense of things.

Dustin Getz14:04:39

How do I turn on highlight matching bracket pair? I found a document about "Clojure Warrior" which appears obselete

Dustin Getz14:04:32

it may have been a bug actually? highlight matching bracket seems to be working suddenly, it definitely was not a few moments ago

Dustin Getz14:04:12

Here - you can see cursor on L18 but L22 is highlighted

Dustin Getz15:04:58

Caught it - it happened immediately after using ctrl-enter to send this form to REPL observe: cursor is at L17, form L7 is highlighted

pez15:04:04

Clojure Warrior has moved into Calva.

pez15:04:16

I can’t reproduce the errr that way. Haven’t tried with a reader conditional, though. And it seems strange that that would have anything to do with it.

👀 2
Dustin Getz20:04:20

I am seeing several bugs, is it possible that electric clojure is confusing something in the stack? here, the codemirrror guarded defn is not resolved (cannot navigate to definition), and the intellisense resolves the parent form instead

pez20:04:12

Is this with default definition lookup priority, or did you change it?

Dustin Getz20:04:26

i will try that now

Dustin Getz20:04:19

hmm it wont accept the setting change, it reverts to repl, lsp. Is something wrong with my machine?

Dustin Getz20:04:50

Oh! I am running {:linters {:clj-kondo {:level :off}}}

pez21:04:18

I doubt it.

pez21:04:28

I don’t know why the settings editor behaves like that. It’s not your machine. Check what the setting looks like in the json file. There’s a command for opening it. Search for JSON in the command palette.

👀 2
pez21:04:05

Also, which repl (clj or cljs) were you connected to when you couldn’t get definitions for codemirror? If you’re using the nrepl provider (default) you probably need to be connected to the cljs repl for it to work. Unless it’s defined in the clj repl too, a bit hard to tell from the screenshot.

👀 2
Dustin Getz21:04:43

Oh, that explains it. I have not tried to use a cljs repl with Calva yet. The symbol is not available in :clj

pez21:04:33

The cljc/clj indicator in the status bar is a button. Clicking it will toggle to the cljs repl.

pez21:04:58

(Assuming you have started the cljs repl, but you probably have, given you are working with Electric Clojure).

Dustin Getz14:04:59

Also, how do I disable rainbow parens? The Calva setttings are already disabled, but my parens are still colored

pez15:04:36

Could be the the built in ones. I think it is “bracket pair color something something”.

Dustin Getz15:04:57

yes thank you, that was it - editor.bracketPairColorization.enabled

🙏 2
Dustin Getz15:04:21

Is java code navigation supported? Searching slack and github, i see several discussions but after a skim it's not clear if this is supposed to work or not. I did find and install the MS Java Extension Pack extension

pez15:04:56

Do you mean navigating to Java sources, or within Java sources?

pez15:04:18

The former works, but only if the stars are aligned… Java sources need to be installed and then some things that I haven’t quite figured out.

👀 2
Dustin Getz15:04:43

traversing from clojure core.clj source into the relevant java source that it calls

Dustin Getz15:04:14

(defn atom ([x] (new clojure.lang.Atom x)) to clojure.lang.Atom

Dustin Getz15:04:14

"Java sources need to be installed" can you elaborate

Dustin Getz15:04:39

oh you mean on the system, not via calva

pez15:04:42

Yes, on the system. You can enable nREPL trace logging and see the traffic between Calva and the nREPL server when you try to navigate to java sources. Maybe that gives some clues.

skylize16:04:43

I think there is work underway for improving interop support in LSP. Perhaps @UKFSJSM38 might fill us in on the current state of things and what we can hope to see soon?

👀 2
Dustin Getz16:04:57

ooh ty for letting me know

Dustin Getz16:04:45

does "java sources installed" just mean system JDK not system JRE?

ericdallo16:04:00

java support is basic but it is improving, navigation to java should work, I'm focusing on other improvements like completion, docs etc

👍 2
Dustin Getz16:04:49

are there any threads or discussions i should read to try to get java nav from clojure working on my machine?

ericdallo16:04:48

It should work OOTB,a way to debug is checking server logs during startup, it should tell if JDK source was downloaded or found in system

👀 2
pez16:04:41

To use clojure-lsp for this, you might need to tell Calva to prioritize lsp over nrepl for definitions, @U09K620SG. Depending on where the nrepl lookup breaks, clojure-lsp might not get asked.

Dustin Getz16:04:12

how do I do that? I don't really understand how the parts fit together, i just know nrepl is a library that you depend on

pez19:04:43

Calva can use both nrepl and clojure-lsp for definition lookups. By default it prioritizes nrepl’s. But it can be configured to prioritize the other way around. It’s supposed to be that the second in priority order is a fallback, but I don’t know if you can trust that for Java definitions. Search for prio in VS Code settings and you should find it.

👀 2
pez19:04:22

It isn’t so much that nrepl is a library. It’s more of a service running in the app under development (or in production). And Calva is an nrepl client. There’s a command for enabling a log of the traffic between the two. You can enable that log for a short while to get a clearer idea about how the pieces fit together.

👍 2
skylize19:04:26

What advantage is there in using Nrepl for lookups over LSP?

pez20:04:57

One is that in CLJC files nrepl knows if it should look for Clojure or ClojureScript sources.

skylize20:04:19

That seems like it would be a useful distinction for LSP to know how to make, too. Is there anything preventing that from being added? I wonder if the LSP team would be interested in shoring up any spots where it is less capable of lookup than Nrepl.

ericdallo20:04:37

If there is any suggestion of improving or something I don't know that doesn't work, please let me know

skylize21:04:47

Well there is apparently that ^. I have no idea what else would be missing or in need of improvement. It never even occurred to me that LSP would not already be the go-to for definition lookup.

pez21:04:06

I don’t think there is a way to statically know this.

ericdallo22:04:27

If I understood correctly OP, already works with clojure-lsp (was recorded on Emacs lsp-mode, but clojure-lsp offers everything calva needs to make it work)

skylize22:04:35

We're on a bit of a tangent from OP. Solution involved changing LSP to default lookup provider. I was asking why LSP was not default already. To which pez offered that nrepl knows whether to look for clj or cljs source files from cljc.

ericdallo22:04:00

I'm ok using lsp as fallback, if repl is connected and evaluated, I suppose finding definition for java would indeed be more precise, but if nothing is found I expect fallback to clojure-lsp to happen

pez22:04:01

Indeed. I’ll make some tests and see if this happens. I suspect the fallback might be broken for Java lookups.