Fork me on GitHub
#calva
<
2023-03-21
>
orestis07:03:09

I'm having trouble getting the new connect sequences to work. It seems like when the CLJS repl starts something goes wrong and the REPL disconnects entirely.

orestis07:03:19

{
  "calva.replConnectSequences": [

    {
      "name": "backend + frontend",
      "projectType": "shadow-cljs",
      "cljsType": "shadow-cljs",
      "menuSelections": {
        "cljsLaunchBuilds": [
          ":main",
        ],
        "cljsDefaultBuild": ":main"
      }
    }
  ],
  "calva.autoSelectNReplPortFromPortFile": true
}
Here's my workspace settings

orestis07:03:29

; Connecting using "backend + frontend" project type.
; You can make Calva auto-select this.
;   - See 
;
; Connecting ...
; Reading port file: file:///Users/orestis/dev/nosco/nosco-gamma/.shadow-cljs/nrepl.port ...
; Using host:port localhost:64022 ...
; Hooking up nREPL sessions ...
; Connected session: clj
; TIPS:
;   - You can edit the contents here. Use it as a REPL if you like.
;   - `alt+enter` evaluates the current top level form.
;   - `ctrl+enter` evaluates the current form.
;   - `alt+up` and `alt+down` traverse up and down the REPL command history
;      when the cursor is after the last contents at the prompt
;   - Clojure lines in stack traces are peekable and clickable.
clj꞉shadow.user꞉>
; Creating cljs repl session...
; Connecting cljs repl: backend + frontend...
;   The Calva Connection Log might have more connection progress information.
; Connected session: cljs, repl: :main
; TIPS: You can choose which REPL to use (clj or cljs):
;    *Calva: Toggle REPL connection*
;    (There is a button in the status bar for this)
calva.output

orestis07:03:42

To quit, type: :cljs/quit
Socket closed
And Calva connection log

orestis07:03:30

In fact invoking this custom sequence brings Calva into a weird state and I cannot connect normally any more

orestis07:03:12

Hm, there must be some lingering global state. After a reload, the custom repl sequence works.

pez07:03:47

Could be a Calva. The connection is a very stateful affair.

mattias13:03:48

Not sure if this is the right place to ask, but has anyone been able to use Calva + remote nREPL along with clojure-lsp ("Go to definition")? I have a Clojure process in a container that starts an nREPL server with nrepl.server/start-server, and I use Calva on my Mac to "Connect to a running REPL server, not in project". There are two separate issues: • If start-server is called without :handler cider.nrepl/cider-nrepl-handler then I don't get "Show stacktrace" button in output.calva-repl window when exceptions are raised. "Go to definition/declaration" navigation works fine. • If start-server is called with :handler cider.nrepl/cider-nrepl-handler then I do get "Show stacktrace" button in output.calva-repl, but "Go to definition/declaration" navigation does not work (error is sth like "file not found"). Presumably because cider-nrepl-handler provides paths which are relative to the container's filesystem, and clojure-lsp runs on my Mac, or sth along those lines. Any idea how to solve this? https://github.com/clojure-emacs/cider/issues/2148.

pez13:03:44

Hi! For now there's a workaround to do exactly what you suggest: nREPL along with clojure-lsp's "Go to definition". There's a setting in Calva for prioritizing clojure-lsp's definitions over nREPL's. See if that works for you.

mattias13:03:08

Oh, it does! That was easier than I thought. Thanks for the response and all the amazing work on Calva!

🙏 2
bobcalco13:03:40

Trying to use Calva on Windoze I have a paredit/parinfer problem someone here may know how to solve. I don't often use VS Code but its integration with various shells, yea even on Windoze, has some advantages during dev vs eshell in Emacs. Anyway, the problem I have is barf/slurp forward commands as described in the Calva Paredit documentation don't work. That is, the bindings Ctrl-Alt-[left|right] do split screens instead of barf/slurp forward. It's quite awkward to deal with only being able to barf/slup backward (i.e., Ctrl-Alt-Shift-[left|right] work fine). Probably some other extension is globbering the barf/slurp forward bindings. Another, separate issue is the fact in strict mode it won't let me hit enter in between parens at the end of a defn form (say I want to supply an else clause in an if statement). My curser just ends up at the beginning of the next line like it jumped out of the place. That is very annoying. Probably a matter of configuring the pretty printing engine. But not being able to barf/slurp forward is almost paralyzing.

pez14:03:56

Hi! As for slurp/barf you have two options: • Remove/rebind split screen to something else (wherever that is bound, in the OS or if you have something installed that does that) • Rebind Calva's slurp/barf to something else

pez14:03:40

It's Paredit, btw. Calva does not provide Parinfer.

pez14:03:31

The cursor displacement on enter sounds wrong. Maybe we have a bug. Is it for all forms? Are you using some other extension that might cause it? I know the VIM extension has been in conflict with Calva in the past, but we should have sorted that, i think.

bobcalco14:03:38

@pez Aha, disabling parinfer made the cursor behavior stop. Looking into keybindings now.

pez14:03:53

Cool. I guess that if you still lacked slurp/barf despite having parinfer installed, you actually don't need parinfer. 😃

bobcalco14:03:32

@pez OK, it looks like VS Code uses Ctrl-Alt-Left|Right to move tabs to different split screen groups. It looks moreover like the settings on Windows are Ctrl-Alt-. for slurp forward and Ctrl-Alt-, for barf forward. So maybe just updating the documentation for windows?

bobcalco14:03:22

I don't really like those bindings. But I can live with them I guess till I come up with better ones.

pez14:03:31

Yes, PR welcome for the documentation.

Michael W15:03:13

I use ; b for barf forward, and ; B for barf backwards. For forward slurp I use ; s and for slurp backwards ; S Semicolon, comma, backtick are good chord keys because they are used so rarely in clojure, imo so I use them to get short 2 key chords instead of most of the 3 key chords from the default keybinds.

pez16:03:38

Way cool. I should try ; and , for chording too. Do you type ;; to get an actual semicolon?

Michael W19:03:28

Yes you have to set that up but yes I use the double key to get a real semi colon, or whichever key I am using for a chord.

{
        "key": "; ;",
        "command": "type",
        "args": {"text": ";"},
        "when": "editorTextFocus"
    },

🙏 4
pez20:03:38

Thanks! FYI, Calva provides some when contexts for checking if you are in a line comment or a string, that might come in handy. It's nice to slurp and barf from a string, but also might be nice to be able to type , and ; without repeating them. And in line comments slurp and barf maybe makes no sense anyway.

pez20:03:45

calva:cursorInString and calva:cursorInComment are the most useful ones I think.

bobcalco14:03:10

OK now that Calva is usable on Windoze for me (thanks @pez!) another question: is there a way to turn clojure-lsp off for specific file extensions? clojure-lsp works with Java and JavaScript but I'm also running on the CLR, and have associated *.cljr files with clojure, which tries (with most unfortunate results) to understand ClojureCLR specific code. I have turned clojure-lsp off altogether as a result; but really I only want to turn it off for cljr files (till I can udpate clojure-lsp to ClojureCLR, in my copious free time, which is probably not soon). I'm happy for now with highlighting and formatting assistance in the case of cljr files but really want clojure-lsp on for the better supported platforms.

pez14:03:53

Oh, I was completely unaware of this problem. Please file an issue about it. Not sure what you can do other than just disabling clojure-lsp... Pinging in <!subteam^S03BGSAUPTQ> and @UKFSJSM38

ericdallo14:03:42

I never tested how good is ClojureCLR support so I guess it's pretty bad, the best would be for client (Calva) don't send didOpen or other requests for .cljr

ericdallo14:03:05

would be nice to detail what kind of issues you are facing with clr, maybe there are quick wins on clojure-lsp or clj-kondo

bobcalco14:03:31

Not many people yet use Clojure on the CLR, but I and a hearty band at the #C060SFCPR channel are trying to change that! In any case, I have to work on it, so I want to use Clojure as much as possible. Aside from tooling (ahem) it's quite usable thanks to the work of @U45FQSBF1 to keep it current with latest-greatest mainline Clojure.

metal 6
Lukas Domagala14:03:12

We could do it on the Calva side by being more specific with the documentSelector in LanguageClientOptions but we need to be careful to not disable repl interaction

pez14:03:14

And a lot of other stuff. Seems best to try deal with this in the lsp client code only.

bobcalco14:03:15

@UKFSJSM38 There are some extra gen-* methods like gen-delegate that are CLR specific. Also, some (currently hideous) conventions when specifying generic types (since the CLR takes them more seriously/strictly than the JVM cuz JVM does type erasure).

ericdallo14:03:31

I see, probably those would need to be handled by clj-kondo if not already, @U04V15CAJ does clj-kondo has support for cljr? would be hard to support it?

bobcalco14:03:56

@U02EMBDU2JU REPL is going to be important for the CLR soon. Though @U45FQSBF1 has taken a needed sabbatical from the nREPL project, he's almost got nREPL working for the CLR.

pez14:03:06

Isn't @U04V15CAJ all elisp these days? 😃

😂 2
bobcalco14:03:30

@pez no and believe it or not he's even visited #clr recently! I'm hopeful he can help. 🙂

borkdude15:03:41

sorry, moved on to .el

😂 2
emacs-spin 2
borkdude15:03:10

hehehe kidding, yeah, we should support cljr, feel free to post issues with repros

clojure-spin 2
ericdallo15:03:53

We should have some changes on clojure-lsp #lsp as well, but I believe they should be easier, clj-kondo probably will need more changes

elena.poot02:03:11

I made a few very light hacks to clojure-lsp and clj-kondo so it would treat them the same as .clj files. It isn't "support", but I get a surprising amount of utility from them as it is. I would be sad if calva broke that by not firing events on .cljr files.

👍 4
ericdallo12:03:22

@U4LCNMMGS me and borkdude want to improve cljr experience, would help a lot if one of you open issues detailing what doesn't work or what you do to workaround that

elena.poot14:03:14

Really glad to hear that! I haven't looked at my hacks in a few weeks, but I'll be revisiting that today. They don't constitute real support though, mostly they just make cljr files be treated just like clj files. .cljc files don't get anything at all, and calls to cljr-specific functions for assembly loading cause the whole file to not be processed. I'm not sure how to frame the issues though, because it's always that all or nothing behavior (and I don't know to what extent that is lsp vs kondo). Any syntax error, really, causes the entire file to not be processed. clj-kondo especially needs much more than a quick hack, as it basically treats each platform version as a separate language. cljr would have to be added throughout. I just hacked it to think they're clj files. And so it thinks cljc conditionals are selecting between clj and clj and gets very confused lol. It's a busy time at work right now (mid-acquisition), but I would LOVE to have better tool support, so I'll try to come up with some specifics and create some issues. It'll probably take a few days though.

👍 4
zimablue15:03:22

I've been having some problems with my workaround, iirc calva does not support two running repl connections concurrently, also shadow-cljs also only starts one by default. I have this important-to-me hack where I run shadow-cljs watch on the frontend and the backend at the same time, shadow-cljs creates two repl connections, then I open two vscode windows and connect seperately from each. Since the latest update it freaks out a bit and says "watch is not running" and an error related to search, I think it happens when both watches are running, maybe because calva is auto selecting the wrong port now? not sure

zimablue15:03:34

replying to self: thinking about it having written out my problem long-form, I'll try running the shadow-cljs watches in seperate vscode (terminals from) windows, see if that helps

pez16:03:03

Not sure I completely follow, but indeed, new Calva doesn't show the connect prompt asking for the port by default. But you can re-enable that in settings. If this proves to be the culprit.

zimablue22:03:53

sorry, I'll try the fix that occurs to me on writing it out in full and come back if neither that nor as you suggest disabling port inference work

bobcalco19:03:34

Trying to move sexp up and down in the text with Alt+UpArrow or Alt+DownArrow, am getting a popup error: command 'paredit.dragSexprBackward' not found. Why might that be? Maybe cuz I turned lsp off (cuz it doesn't really work on cljr files)?

pez20:03:46

It shouldn't have anything to do with clojure-lsp... I don't quite understand why the command wouldn't be found. Sometimes with these really strange errors it has been about VS Code accruing some funny state. Try restarting it , maybe... Or maybe it is more civilized to start with checking for errors in the dev console (VS Code's Help menu).

bobcalco12:03:04

I'm seeing lots of errors like this:

mainThreadExtensionService.ts:79 [[object Object]]Cannot read properties of undefined (reading 'document')
$onExtensionRuntimeError	@	mainThreadExtensionService.ts:79
N	@	rpcProtocol.ts:455
M	@	rpcProtocol.ts:440
H	@	rpcProtocol.ts:370
G	@	rpcProtocol.ts:296
(anonymous)	@	rpcProtocol.ts:161
invoke	@	event.ts:718
deliver	@	event.ts:926
fire	@	event.ts:887
fire	@	ipc.net.ts:671
ne.onmessage	@	localProcessExtensionHost.ts:615
mainThreadExtensionService.ts:80 TypeError: Cannot read properties of undefined (reading 'document')
	at c:\Users\bcalc\.vscode\extensions\clptn.code-paredit-0.1.1\out\src\extension.js:79:243
	at f.invoke (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
	at m.deliver (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2066)
	at d.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1704)
	at c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:154048
	at f.invoke (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
	at m.deliver (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2066)
	at d.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1704)
	at m.acceptDocumentsAndEditorsDelta (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:13934)
	at m.$acceptDocumentsAndEditorsDelta (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:98:12249)
	at a.N (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:106:11223)
	at a.M (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:106:10941)
	at a.H (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:106:10034)
	at a.G (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:106:9015)
	at c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:106:7803
	at f.invoke (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
	at m.deliver (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2066)
	at d.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1704)
	at p.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:72:14907)
	at c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:122:16556
	at f.invoke (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:145)
	at m.deliver (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:2066)
	at d.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:63:1704)
	at p.fire (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:72:14907)
	at MessagePortMain.<anonymous> (c:\Users\bcalc\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:122:14682)
	at MessagePortMain.emit (node:events:526:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:5:364)

pez12:03:23

That's from some other Paredit extension. Could be the reason things don't work.

pez12:03:05

The conflict, I mean.

bobcalco12:03:11

OK let me see if I can switch to a saner paredit.

pez12:03:55

Just let Calva handle it is the safest bet. I don't think using several Paredits is going to give a smooth experience.

bobcalco12:03:17

OK... after uninstalling the extraneous paredit, you'll never guess what works now!

bobcalco12:03:40

I installed those before I installed Calva. Good to know they're best to uninstall first.

pez12:03:45

Calva used to check for them at startup and warn. That also caused confusion. 😃

bobcalco13:03:18

Well for now at least I seem to be in good shape. I just wish I could turn LSP on conditionally based on platform target (inferred by the file extension), or otherwise clojure-lsp and clj-kondo support for CLR is implemented sooner rather than later.

bobcalco13:03:47

But for now if I know I'm going to work on the JVM/JS side of things I can turn it on, then when I am expressly working on CLR I can turn it off. Need to look into how clj-kondo and clojure-lsp actually work.

pez13:03:05

Did you see that @U4LCNMMGS has made patches for clojure-lsp and clj-kondo that makes it work somewhat with CLR?

bobcalco13:03:59

I did not. thanks for pointing it out. will ask her about that over there.

bobcalco19:03:55

They are defined as paredit commands in the Keyboard Shortcuts tab

🧵 2
seancorfield22:03:44

Spritz/VS Code 1.75.1 incompatibility -- is this known/intentional?

seancorfield22:03:22

I've had to stay on 1.75.1 because 1.76 breaks the Atlassian plugin and I have to have that working (for work).

pez22:03:03

Not intentional. There's no reason at all it should be more picky than Calva. Issue, please. 🙏

pez23:03:17

Doubly sorry for about the Atlassian thing. (Breaking VS Code 1.76 and also I am a bit allergic against most things Atlassian 😃 )

seancorfield00:03:47

Hahaha... I live and die in the Atlassian extension all day long, every day. Saves me dealing with their web sites!

phill16:03:26

I ran into this issue too. What Calva version is recommended for VS Code 1.74.1?

pez16:03:52

@U0HG4EHMH, Calva has the minimum set to 1.67.0. I changed that in the Spritz extension to now and published. You should be able to install it since you can install Calva.

seancorfield17:03:57

Confirmed that I can update Calva & install Spritz on 1.75.1. Thanks!