Fork me on GitHub
#calva
<
2023-10-10
>
henrik09:10:44

How’s Parinfer doing nowadays? @avocade mentioned that VS Code was now more amenable to the types of manipulations that Parinfer wants to do.

pez09:10:53

I wasn’t aware of this change in VS Code. Sounds interesting. My last attempt was very close, but the last 5% almost finished me, and I didn’t even succeed. But it was me, not VS Code, I think. (Even if VS Code made me have to do things in roundabout ways, which I then failed to fully manage.) A factor here is that I am not a Parinfer user myself, so I don’t have those incentives to spend the amount of time it demands.

henrik09:10:11

Gotcha, a pure good-will effort on your part. For my part, I have the incentive, but I’m absolutely clueless when it comes to VSC internals (or Parinfer internals, for that matter).

pez09:10:34

Here’s a thread about it: https://twitter.com/pappapez/status/1461018167002734592 In hindsight, I regret blaming VS Code so much for my failings. I am pretty sure it was rather technical debt in Calva holding me back. + not having the sense to secure the foundation I was building on. I think that if I do things in smaller steps, and in the right order, we would have Parinfer in Calva. I do have the incentives to have a look at the technical debt tripping me up in my last attempt. Might start there.

👍 1
🙏 1
henrik10:10:48

As I’m starting with zero understanding here: does a Parinfer implementation need to be aware of Calva at all, or could it be orthogonal? Would it collide with Calva assumptions?

henrik10:10:00

This is just from remembering that back when I used Atom, Parinfer was a separate package to Proto-Repl, which took care of most of the rest that you want from a Clojure IDE.

pez10:10:19

It’s entirely possible to build a separate extension for this. That’s not how I would do it, though. I would build it into Calva and use the infrastructure it provides. Similar to how ParEdit is an integral part of Calva. But for someone else, building a separate extension might make sense.

pez10:10:19

I just noticed that @U061E2UBT had commented, long ago, on my latest Parinfer PR. I added a comment there as well, for completeness. Here’s the PR https://github.com/BetterThanTomorrow/calva/pull/1429

pez10:10:31

On the subject of separate extension. Such an extension already exists. But I think it’s abandoned by its creator.

henrik10:10:08

I’ve tried some (a couple?) and they seem to have issues, possibly due to limitations in the API exposed. Yeah, if Calva provides good abstractions, it certainly makes sense to build it within its purview. If I’m using VSC, I’m going to be using Calva.

pez10:10:02

Depending on what has changed in the VS Code API, it could also be about how we hack around things. It was a while ago since I worked on this, but as I recall, I needed to make it play well with other Calva editing of the document, and all I had was some event handler for when the document changes, and that event handler didn’t even get to know enough about the source of the changes, so it got to be guesses and synchronization…

henrik10:10:20

As far as I’ve gathered, Parinfer works best where you can insert middleware into document updates. I.e., event -> [middleware] -> editor update. When you can only react to a change after the fact, things become dicey. I bet this is true for more things than Parinfer.

henrik10:10:11

Very easy to end up with weird race conditions if updates can’t be atomic.

henrik10:10:37

Plus, weird a undo history, potentially.

henrik11:10:24

@avocade What was the nature of the change that would make things easier for Parinfer?

shaunlebron14:10:58

@U06B8J0AJ any details on the new VS code api?

henrik14:10:36

This is pure hearsay, I’m reacting to what @avocade told as a by-the-way. I glanced at the VSC docs, and as far as I can tell, I can’t see the scaffolding needed to work around the problems I listed above at least. The only thing that I’m spotting that might be powerful enough is this: https://code.visualstudio.com/api/extension-guides/custom-editors Seems like something that would yield a lot of power, at the expense of probably being quite a bit of work.

henrik15:10:57

Btw @U061E2UBT @U0ETXRFEW, have we had almost this exact conversation before, or am I just having massive deja vu?

pez15:10:32

We had a similar discussion in #C0F2A0MJN way back. It was about someone else attempting to implement full Parinfer on VS Code, and failing.

shaunlebron23:10:43

vscode parinfer can be its own thing, but I see the benefit of packaging it like Cursive does.

shaunlebron00:10:47

Let me know if avocade ever elaborates. I suppose you could build your own text editor with CustomEditor if it’s not politically possible to submit a PR for synchronous change interception.

👍 1
henrik04:10:59

I was lobbying Panic Nova (https://nova.app/) about edit event middleware for a while, because it’s a fast, native editor, and I thought I might use it if it had Parinfer and a REPL at minimum. I made a working plugin with the limited API they had exposed, and explained what I needed from them to make it good. They have so far not created the necessary hooks, because they’re worried about editing performance. Maybe the VSC crew has similar concerns, with the difference that with CustomEditor, you’re in charge of the UX, not them.

👍 1
pez07:10:22

I think a CustomEditor is unfeasible, because users will expect that the editor works exactly as a regular editor and that is a mix of tons of work + things not possible to implement.

👍 1
henrik06:10:58

I don’t know enough about CustomEditor to determine if this is true or not. Is it forcibly custom? Or can you start with a clone of a standard editor and tweak it?

pez08:10:00

There is no way to tell VS Code that it is the regular editor + something. It is fully custom. You can build it on the same tech, like Monaco and what have you. And you can make it look very similar to the regular editor. I think the problems might start at theming. There are some ways to get some of the theme in there, but the API is not meant for it, so it will get tricky. We used to build the Calva REPL window with a custom Webview (which is somewhat similar in this regard) and never could meet the user’s expectations. (We should have made it look totally different, probably, rather than go for mimicry). We had code for code completion UI and some more, but the regular editors are super rich… With CustomEditor you get help with editor things like life cycle and change events. I imagine that utilizing that will quickly land you in the same spot regarding the lack in these APIs, as we have with the regular editors. Granted, it would be in our power to add our own API, at which point, maybe a regular WebView would make more sense to begin with. All this should be labeled AFAIK. I haven’t explored this much, beyond the struggles with maintaining that custom WebView editor, which is now several years ago.

henrik08:10:27

For sure, that doesn’t sound promising. I was hopeful that https://code.visualstudio.com/api/references/vscode-api#CustomTextEditorProvider meant that ~most of the normal stuff was in there already.

pez08:10:19

Yeah, it helps with the state management, for sure. In the editor we maintained we had to do keep track of undo and things, that a CustomEditor would have provided for us. CustomEditor didn’t exist when we added that editor, so it was never an option then. Another thing with CustomEditor and Webviews is that the VS Code team do not really prioritize bugs that you run into because you are trying to mimic the regular editors. We had troubles with keyboard strokes not being registered as they should, and my issue reporting it didn’t exactly get the attention I thought it deserved. I take it that they think that extending the regular editor should be done with the API:s for that, not going fully custom.

avocade13:10:51

Sorry, been sick for 2 weeks in a bad case of the covids. If I had some more insights than this they were burned away, but most probably it was a case of reading too much into a comment – I'm just aching (ACHING) to get away from IntelliJ 😄 Always found Calva more compelling, but I've become a bit addicted to Parinfer these days. I guess there's always rehab.

🍀 1
pez13:10:45

Paredit rehab! 😃

avocade13:10:08

Oh noez…

shaunlebron14:10:04

We can always go back to parinfer modes. At its roots, the separate modes are very stable and easy to implement.

shaunlebron14:10:17

I explored Smart mode out of duty to see what parinfer should become, after feedback that modes were asking too much of the user. I wonder now if the user's intention is best left unsystematized. "Inferring" one thing was fine— but inferring what the user wanted to be inferred was a bit much.

1
shaunlebron14:10:51

(Smart mode is the only thing problematic to VS code. Smart mode being the meta rules for inferring from an edit which of the two modes to apply: indent or paren)

pez14:10:00

For the record, my attempts where not even trying to implement smart mode. I was always inferring parens, and used the Calva formatter aggressively to keep things indented correctly. While things where not glitching out, it seemed to be enough to make things “always” work.

frankiesardo12:10:54

Hello dear friends. I'm trying to use github codespaces for my clojure dev environment. I've successfully added the https://github.com/devcontainers-contrib/features/tree/main/src/clojure-asdf. Running $ clojure in the integrated terminal works as expected. But after installing Calva I see the error > LSP classpath lookup failed when running clojure -A:test:dev -Spath Anyone managed to use Calva with github codespaces in the past?

ericdallo12:10:30

is clojure installed there? otherwise that will indeed fail

frankiesardo12:10:07

Yes it is installed, I can run clojure from the integrated terminal

ericdallo12:10:03

that happens when the terminal that launched vscode doesn't have clojure on the $PATH

frankiesardo12:10:09

Yeah that I figured, but it seems like the devcontainer should have added that to the $PATH, and I can run it from the integrated terminal, that's why I'm puzzled

ericdallo12:10:49

Interesting, maybe try configure .lsp/config.edn configuring a :project-specs of:

{:project-specs [{:classpath-cmd "/path/to/clojure" "-A:dev:test" "-Spath"
                  :project-file "deps.edn"}]}

👍 1