Fork me on GitHub
#calva
<
2022-08-10
>
Bart Kleijngeld08:08:11

Alright, so I'm giving Kaocha a try and so far it seems promising. However, in the Calva REPL buffer I see some formatting issues that a lein repl does not have

Bart Kleijngeld08:08:40

When I evaluate (k/run :unit) in a lein REPL, I get:

metamorph.core=> (k/run :unit)

;; stuff ...

Ran 1 tests containing 1 assertions.
0 failures, 0 errors.
[(F)(FFF)(.)]
Randomized with --seed 391347173

FAIL in metamorph.core-test/a-test (core_test.clj:11)
FIXME, I fail.
Expected:
  0
Actual:
  -0 +1
However, in the Calva REPL, this happens:
(k/run :unit)
[
(
F
)
(
.
)
(
F
F
F
)
]

Randomized with --seed 1752511405

FAIL in metamorph.core-test/a-test (core_test.clj:11)
FIXME, I fail.
Expected:
  0
Actual:
  -0 +1

Bart Kleijngeld08:08:11

For some reason, everything is the same except for the [(F)(FFF)(.)] summary, which in Calva gets split over newlines. Given that the rest looks fine it doesn't seem newline encoding related? I was wondering if people who use Kaocha with Calva have seen this issue and hopefully fixed it.

pez08:08:40

Could it be a pretty printing issue? What does it look like with pretty printing disabled? That said, it does look like there is more to it than this...

Bart Kleijngeld08:08:27

Turning the pretty print toggle on or off doesn't change the output here (I tried per your suggestion)

pez08:08:23

Thanks for testing that! Can you check the nREPL message log and see what's coming back there?

Bart Kleijngeld08:08:55

Do you mean the terminal output of the jacked in REPL?

Bart Kleijngeld08:08:14

(I'm only vaguely familiar with the underlying technology)

pez08:08:57

There is a command in Calva that turns on nREPL message logging. It will open a VS Code Output channel and show what's going back and forth between Calva and the nREPL server.

Bart Kleijngeld08:08:05

Ahh, nice, I see it 🙂. This is sent:

-> sent
{
  id: '136',
  op: 'eval',
  session: 'abc677b9-dbad-4955-b137-7e4c12c174a7',
  code: '(k/run :unit)',
  'nrepl.middleware.print/options': { 'right-margin': 120, length: 50 },
  'nrepl.middleware.print/print': 'cider.nrepl.pprint/pprint',
  file: '/home/bartkl/Programming/alliander-opensource/metamorph/.calva/output-window/output.calva-repl',
  line: 191,
  column: 1,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: true
}

Bart Kleijngeld08:08:26

And then I receive those characters one by one (I can cite some or all of those if you want as well)

Bart Kleijngeld08:08:25

(and of course, pprint: false in case I disable that)

pez08:08:48

Receiving the characters one by one will result in them being printed on separate lines, for sure.

pez08:08:27

Did you say you've tested this in emacs?

Bart Kleijngeld08:08:56

Yes indeed. I guess the question is why we do receive them one by one then. No, not in Emacs, although I can try (I have an Emacs installation here). I did try in a lein REPL from a Bash shell (same project), and there this issue doesn't occur.

pez08:08:19

I know Emacs has an nREPL message log (that's where Calva's log is inspired from). Maybe line has one as well.

pez08:08:36

I'm just trying to understand what's going on.

Bart Kleijngeld08:08:25

I appreciate it! I'm going to try and see how I can see the nREPL log from lein

Noah Bogart14:08:28

at the command line, print doesn't include a newline, but it looks like calva might be adding the newline to all new calls to stdout?

pez14:08:28

Not to stdout, it shouldn't add this:

(doseq [x (range 10)]
  (print x))
Prints:
0123456789
nil
But if it is coming in as separate results then I think a newline will be added. Can you paste the whole nREPL log from a run here, @U03BYUDJLJF? Seems we need it now. 😃

👍 1
pez14:08:29

And actually my test wasn't all that useful:

{
  id: '85',
  out: '0123456789',
  session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf'
}
Meaning it is the REPL server that collates it.

Noah Bogart14:08:57

What if you do (doseq [x (range 10)] (print x) (flush))?

pez14:08:05

Thanks. That exposes the problem.

0
1
2
3
4
5
6
7
8
9
nil
The log:
-> sent
{
  id: '94',
  op: 'eval',
  session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf',
  code: '(doseq [x (range 10)] (print x) (flush))',
  file: 'Untitled-2',
  line: 8,
  column: 1,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: true
}

<- received
{ id: '94', out: '0', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '1', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '2', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '3', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '4', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '5', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '6', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '7', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '8', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{ id: '94', out: '9', session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf' }

<- received
{
  id: '94',
  ns: 'user',
  session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf',
  value: 'nil'
}

<- received
{
  id: '94',
  session: 'c60041db-6d03-4be6-8d47-4f4bc78b0fdf',
  status: [ 'done' ]
}

pez14:08:19

I think that could be fixed in Calva. Just need to figure about some implications. When should we be adding the newline and when shouldn't we...

Bart Kleijngeld14:08:21

Good progress! Is the log still desired?

Bart Kleijngeld14:08:55

Ah, I get it now. That's subtle

pez14:08:11

I now want an issue on Calva. 😃 You can include the log there. Perhaps use a <detail><summary>.

👍 1
Bart Kleijngeld14:08:55

I'm going to submit it right away, thanks all for helping out

Bart Kleijngeld14:08:25

Not sure what you mean by <detail><summary> . Are those each HTML tags I can use for markup in the GitHub issue?

pez14:08:40

Yes, and I might remember the HTML wrongly. 😃 But I know Github Markdown does not strip it.

Bart Kleijngeld14:08:16

Found it (https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2)! You were close 🙂. Didn't know about this. Nice.

😂 1
metal 1
pez15:08:16

Wanna hava a go at the issue, @U03BYUDJLJF? It'll take you to fun and slightly messy parts of the Calva code base, 😃

Bart Kleijngeld15:08:19

Not sure if I'm up for that job (I'm still a novice), but perhaps I can try 🙂. If I can get some guidance here and there

Bart Kleijngeld15:08:16

At the very least I can promise you to follow the code guidelines neatly 😉, I'm somewhat of a perfectionist. But again, my Clojure XP level might be a little sub-par for this

Bart Kleijngeld15:08:57

(I'll continue the discussion on GitHub)

pez11:08:14

Dear Calva and clojure-lsp friends. The #lsp team needs our help testing a super important change in clojure-lsp. (See @jacob.maine’s latest update in #announcements for more details.) The change is under the hood so you shouldn't see any new behaviour, iiuc. The team has also been testing it a while so you should expect it to mostly work. Please consider installing! ❤️ • If you're not an Mac M1 user it is as easy as setting calva.clojureLspVersion to nightly. • If you are an M1 user, that won't work, so instead download this https://nightly.link/clojure-lsp/clojure-lsp/workflows/nightly/master/clojure-lsp-native-macos-amd64.zip, unzip at a location of your choice and point calva.clojureLspPath to that location. In both cases, follow up with: Calva: Restart the Clojure LSP Server. Please report back about your experience, good or bad, here or in #lsp, whichever makes most sense to you. https://clojurians.slack.com/archives/CPABC1H61/p1660090888390669

👍 2
gratitude 2
jacob.maine15:08:35

Thanks @U0ETXRFEW and all you Calva users for doing some additional testing. It really helps make sure clojure-lsp is solid. gratitude calva

jacob.maine21:08:30

Known issue with this build of clojure-lsp: documentation is missing from completion items. https://github.com/clojure-lsp/clojure-lsp/issues/1181

zakkor21:08:26

Quick question: it seems like this indent behaviour is a bit weird when pressing enter. Should we not be able to figure out the correct indentation in this scenario? :thinking_face:

pez14:08:42

Thanks for reporting. FYI, while gifs and videos are great, it would have been great with the text as well. It's much easier to paste it and reproduce, than having to re-type and possible do it wrong and such.

zakkor14:08:27

Oops! Sorry 😄

zakkor14:08:29

(comment
  (zip-walk (fn [zl zr] 
              (let [nl (z/node zl)
                    nr (z/node zr)]
                (if (plain? nl)
                  (prn "self:" (= nl nr))
                  (prn "tag:" (= (:tag nl) (:tag nr))))
                zl))
            (xml-zip (transform [:div "hello" {:el :some-el}]))
            (xml-zip (transform [:div "world"]))))

🙏 1
❤️ 1
zakkor14:08:56

seems like it happens pretty much in any place, though. Weirdly enough, when you backspace, it puts the cursor on the previous line correctly :thinking_face:

pez14:08:40

I can't immediately reproduce:

zakkor14:08:29

weird, will check my Calva settings in a bit and see if it's anything I might have tweaked

zakkor14:08:46

in your GIF though, shouldn't there be 1 extra space to match the next line's indentation?

pez14:08:04

Yeah, that's weird. I can't repro that either now...

zakkor14:08:33

Hahah, the logical conclusion is that every time I ask about a problem, it gets fixed automatically

😂 1
pez14:08:22

For the record: The indentation does not work by matching the indent of the next line. I guess you didn't mean it that way, but just to be clear.

pez14:08:34

What's your setting for calva.fmt.newIndentEngine?

zakkor14:08:35

tried with both "calva.fmt.newIndentEngine": true, and "calva.fmt.newIndentEngine": false, but no difference, same issue with both

pez14:08:15

That's super extra interesting.

zakkor14:08:13

here is another problem area:

(defn html-zip
  "Returns a zipper for HTML DOM elements, given a root element."
  [root]
  (z/zipper #(= (.-nodeType %) html-node-type-element) 
            #(array-seq (.-childNodes %)) 
            (fn [node children]
              (throw (js/Error. "html-zip: don't know how to create new nodes")))
            root))

pez14:08:32

Maybe you have some other extension that interferes? Can you try with only Calva active?

pez14:08:23

What's the problem you're experiencing with the second text?

zakkor14:08:26

yeah, trying now 😄

zakkor14:08:34

let me remove my entire settings file too

zakkor14:08:52

AHA, that fixes it

zakkor14:08:54

let me find the setting now

zakkor14:08:25

"calva.fmt.formatAsYouType": false, :man-facepalming:

pez15:08:20

I feel like I have tripped you up! I wonder when you would ever not want format as you type... Especially since there is already a VS Code setting for that. Can you file an issue about this?

zakkor15:08:40

"[clojure]": {
    "editor.formatOnType": false,
  },
yeah, actually I also had this in my settings

zakkor15:08:44

they both seem to do the same thing

zakkor15:08:11

I can't exactly remember what behaviour I encountered that caused me to turn these off

pez15:08:51

Does the calva.fmt one switch off formatting if the other one is enabled?

pez15:08:42

I remember vaguely to have removed that setting, but maybe that was in a branch never released....

zakkor15:08:20

yes, it does override the VSCode one

pez15:08:54

The only reason I can see is if you have some other Clojure formatter. But the setting is not worth the confusion it causes (even if you had disabled it twice, haha).