Fork me on GitHub

Please help me resolve some warnings that I don’t think I should be seeing 🧵


Calva v2.0.286 Mac OS VSCode 1.68.0 I’ve deleted .lsp/.cache and .clj-kondo/.cache and restarted VSCode


Obs: this is in a cljc file.


Oddly, the other warning I was going to post is no longer happening ¯\(ツ)


Since this is a cljc file you need to put those in a :clj reader conditional since slurp doesn't exist in cljs


D’oh! Of course.


I've begun seeing a .clj-kondo/babashka start appearing in projects when I use Calva ... do I need to add it to my .gitignore? Its appearance is a surprise because I'm not using babashka.


Perhaps your project has a bb.edn?


I'm seeing something strange lately with Calva/LSP: if I add a new namespace to the :require in an ns, e.g., [ :as bar], and then in code I type (bar/ I am no longer seeing code completion for vars from that namespace. Sometimes, it'll suggest something like ' instead of bar/some-func which is what I'd expect. Any suggestions for debugging why it isn't working?


I've tried restarting LSP to trigger reanalysis. The namespace that I'm requiring is one I've just been editing in Calva, and have eval'd it into the REPL.


Note: I only have nREPL on the classpath, not CIDER, but this used to work just fine so I don't think that's it.


Is the parens balanced correctly in that file? If not, that is probably the issue


Yes, the files are all syntactically valid and balanced. This happens in all files as far as I can tell.


Could you provide a simple repro where I can try?


I'll try but this is all work code.


It produces the correct suggestions for clojure.string etc, but not our own code.


Só maybe the source-paths are not being found or set properly


Do you have any suggestions for debugging that?


It's possible, since this is Windows/WSL2, and it's a new machine. I was previously working on a Mac.


Yes, there is a LSP command to retrieve server info, I think calva has a command for that


Clojure-lsp server info


There should print the source-paths


OK, will take a look (of course that's on my work machine, where I don't have Slack for Clojurians!).

👍 1

Trying to run LSP Server Info failed "(command 'clojureLsp.disgnostics.clojureLspServerInfo' not found)"


I don't think it has diagnostics on the name Maybe @U0ETXRFEW knows how to run that?


Looking at the LSP server log, it seems all the paths are relative to a subdirectory in the repo, not the root of the repo, so I bet that has something to do with it...?


Yes, maybe the project root is wrong


In the repo, all the Clojure code is under the clojure folder, and the main deps.edn is there. But I have had to add a script to run clojure -Spath ... with all the right aliases...


I think calva/vscode use the root of the folder opened


Right, but I should be able to tell it to use a different folder for LSP analysis, yes?


Probably you could just use the :source-aliases setting


No, the client send the project root and I don't think calva has a setting for that


OK, I think I've fixed it. My had a cd command in it because I thought it needed it, but that caused the paths to be relative instead of absolute.


Now I'm getting the correct code suggestions.


Maybe you can add a root deps.edn with a specific alias that uses a local root of the subdirectory


Then you wouldn't need that classpath script


Check the clojure-lsp repo itself, it's similar


I notice that the LSP logs complains there's no nREPL on the classpath so it doesn't start an nREPL Server -- what functionality am I missing out on?


Well, the clojure folder is a Polylith mono-project so LSP needs to be told about the aliases to use to compute the classpath -- by default, the root deps.edn brings in no code.


That for debugging only


I think you are using the JVM clojure-lsp, not the Graal one


@U04V70XH6 thats why I suggested using source-aliases setting


Ah, I didn't know about that. I have :project-path set to clojure/deps.edn. Are you saying I just need :source-aliases instead of the :classpath-cmd and the shell script?

👍 1

As for JVM vs Graal version, it's running whatever version of LSP Calva figures out -- I haven't done anything with that stuff.


OK, got :source-aliases working, thank you!


What about the nREPL server thing?


Oh, forget about that, it's a debug log that nrepl is not available because it's a Graal binary. It's expected, we use the nrepl just to debug clojure-lsp code while developing

Sohang Chopra07:06:16

Hi everyone! I just joined this Slack channel. 🙂 I have been using Calva (with VS Code) for learning Clojure - it's quite good! I am starting to make a TUI program - but I can't figure out how to show the running TUI app in a seperate terminal from the Calva Output REPL. Basically, I want to run a TUI program, while still being able to eval expressions in Calva Output REPL. I checked out this page: , but I didn't really understand it. Can anyone help me out with this? Any pointers?

👋 1
calva 1

Hi. Let's see. What is your program going to do? Is it also a Clojure REPL?

Sohang Chopra10:06:51

Hi @U0ETXRFEW I am planning to make a TUI library. I am sure that similar libraries already exist, but this is mainly for my own learning.


I guess my problem here is that I don’t know what a TUI library is.

Sohang Chopra12:06:07

@U0ETXRFEW TUI = Terminal User Interface - it basically imitates GUI on the command line with boxes, alignment, etc. For example, Lynx - a terminal browser. My idea was to try to render a subset of HTML in the command line.


So that's what I thought a TUI was as well. But somehow you are reading Embedded nREPL docs, so it seems there is more to your TUI and that it has to do with the REPL?


I might be completely misunderstanding. In any case, if you elaborate more in detail what it is you want to achieve, then maybe I can see some way to do it. (Or anyone. I saw @U07FP7QJ0 seemed to understand where you where going in the other thread you started.)

Sohang Chopra13:06:43

@U0ETXRFEW I want to output rendered HTML in a terminal (which may include animations), and be able to interact with it using Calva's Output REPL. That is, actual program output and REPL interaction output are in two seperate windows / terminals.

Sohang Chopra13:06:53

The REPL is able to eval expressions in the context of the running program.

Sohang Chopra13:06:58

This is similar to Debug terminal in various languages - however I want to be able to eval expressions directly from my input code file (as we can do usually with Calva).


I see. Since your TUI will be written in Clojure, it should have a REPL you can connect to, right? Want to chat via the voice huddle here a bit? Then we can screen share too and maybe things get clearer for me.


Huddle opened. Just holler if you join. (You might need to remind me I am muted.)

Sohang Chopra13:06:04

Maybe later? Traveling right now, lots of noise here.

Sohang Chopra13:06:29

Also, my spoken English isn't that great - be warned 😀


Haha, we will be two speaking broken English.


If you can create an example project and share, I can have a look and see if I understand how to get it working.

Sohang Chopra13:06:23

I'll voice call (huddle?) you in an hour (as I said, I am traveling right now)

Sohang Chopra13:06:07

BTW I'm from India? Where are you from?


I'm from many different places. 😃 (Sorry, old Highlander joke). Anyway, I am a Swede, living in Sweden, speaking English broken in Swedish. (But originally I am from Colombia.)

👍 1
Sohang Chopra15:06:39

@U0ETXRFEW Um.. can't figure out how to start a voice call or huddle with you. Huddle seems to be a paid feature - I'm currently using the free web version of Slack.


It's the server that needs to be pro, which we actually have. Can you see the huddle opened in the #calva channel? (Down to the left I see it).


Like so:


What tech are you using for the TUI?

Sohang Chopra16:06:30

@U04V15CAJ Not using any tech for the TUI - haven't actually started it yet 🙂. It's just in thinking / planning phase right now.


@U03L31E1Y1F Cool. Maybe nbb + ink is something worth trying

👍 1
👋 1
Sohang Chopra16:06:36

@U0ETXRFEW Do you think it would be useful to also post my issue in other channels?


@U03L31E1Y1F I think it's best to set up an example project that exposes the problem. It's easier to reason about it and alternatives/workarounds then.

Sohang Chopra06:06:47

@U0ETXRFEW How about this - a word is stored in a mutable variable (maybe an atom?) Then it's simply printed in an infinite loop. We would like to modify the word being printed by mutating the word variable from REPL. (Of course, the new word value should also show in REPL. Also, we should be able to modify word by evaluating expression from either input file or directly from REPL)


You mean as an example app? That'd work. Maybe it should have some function which prints ”in-band” (in the same eval ) as well. I know some nREPL servers has been known to treat out-of-band and in-band output differently.

Sohang Chopra07:06:11

Sorry - didn't understand what you meant by in-band. Did you mean using eval somewhere in the code?

Sohang Chopra07:06:43

And print inside eval?


I meant, if the print is done in the code being evaluated, that's in-band. If it is done in some other thread, it is out-of-band. I might be using the wrong terminology.

Sohang Chopra07:06:00

Got it - that sounds like a good idea!


If you enable the nrepl message log in Calva, you should be able to see the difference in the messages received.

👍 1
Sohang Chopra08:06:40

@U0ETXRFEW Would this example project ( be ok? It's just the lein new app template, with my modifications in core.clj. Please create a pull request if you think some changes are required in it.


I wouldn't even dare start an app with a loop like that 😃 Will try to find some time to provide more constructive feedback.

Sohang Chopra12:06:23

@U0ETXRFEW please do send more constructive feedback when you have time


To my experience, programs that have a while true loop where nothing really happens often heat up my CPU until I find a way to stop them. And I don't think you would be able to interact with the REPL after evaluating it, so it is not supporting the experiment very well.


I've filed a PR with some changes. Now what's lacking is a README that tells what the project is about.

👍 1
Sohang Chopra14:06:13

@U0ETXRFEW I have merged your PR. I have a question regarding your PR - in src/exampleclojure_app/core.clj_, you have written near the end of the file (in a rich comment) that wierd stuff happens on evaluating @f. What do you mean by that?


Yeah, I don't think that should be kept in the example. It was more something I noticed, and that you might be interested in. Dereferencing the future that is still executing seems to spawn off new threads or something. I haven't investigated, but at some point I couldn't interrupt the heartbeat, neither by swapping in :quit in the !state atom or by interrupting the evaluation (via Calva's command for that).

Sohang Chopra14:06:37

@U0ETXRFEW Were you able to verify (via something like htop) that multiple threads are actually being spawned?


Not investigated it at all. Just noticed it got weird and left that comment. 😃

🙂 1
Sohang Chopra14:06:39

@U04V15CAJ Your suggestion (nbb + ink) seems interesting - it seems to do exactly what I wanted! Since I'm a beginner, the fact that it's ClojureScript instead of Clojure shouldn't make much difference. Thanks!

Sohang Chopra14:06:03

@U0ETXRFEW The suggestion by @U04V15CAJ (nbb + ink) seems interesting - I might go with that! Have you used this kind of setup?


@U03L31E1Y1F It depends on how complex your TUI must be. If it's just a questionnaire, you can also look at:

npx clojure-quiz
which is made with nbb and uses some console library for prompting input :)

👍 1

I haven't done much of that at all, but I've followed along in this tutorial and had it working (not a general TUI, but nbb and stuff).


I have the following in my VS Code settings JSON but when I do a global find, it still matches things in my Calva output REPL window -- any suggestions?

"search.exclude": {
      "**/.calva/output-window/output.calva-repl": true


I also have .calva in my .gitignore file.


I’ll give it a try and see if I can figure it out. But it sure looks like that excluded should do it.


open files are always included in results


Ah, that explains it! Thanks @U015879P2F8!


If I explicitly add *.calva-repl to the files to exclude box, it works even with the repl window being open so that's a workaround...


My VS Code Calva window started crashing today, every time I pressed Tab to indent, and also sometimes when I did not press Tab, but perhaps I may have triggered formatting with a different keystroke. It crashed regardless of whether a REPL was open. After I unchecked the setting to start LSP, the crashes stopped. I tried "Open Clojure LSP log" (and reviewed the file after the crash, having observed /tmp in the tab name) but there were no errors in that log. Calva was 2.0.286 but I did not see a version number in the LSP log. Edit: The crashes were preceded by several seconds of unresponsiveness, sometimes long enough for a box to come up asking me whether I wanted to close the window or wait for it; and when I scooted over to a terminal (outside VS Code) "top" showed VS Code using more than 100% of CPU.


This is probably a vscode issue, LSP client side, not related with clojure-lsp or Calva

Geoffrey Gaillard13:06:34

You are not the first to experience this Phill. While I understand the boundary between clojure-lsp and vscode, I'm 100% positive that stopping clojure-lsp makes the problem go away. I cleared up all caches, reinstalled vscode from scratch, tried older versions and the problem remains. There is an issue somewhere, and it made me stop using clojure-lsp with vscode.


Just to be clear that clojure-lsp is a process that calva/vscode spawns, and if the editor is freezing is a issue completely on editor side, I suspect it can be something on the vscode-language-client extension. Maybe try a older calva which has that plugin as a older version

👍 1
Daniel Jomphe15:06:27

I have a colleague whose VS Code couldn't support our project's setup, @U2DART3HA and OP. We ended up trying out the VS Code Insiders version (preview, less stable) and it worked on his machine. Weird but it's the only way we found on his machine to make things work. It's been going on like this for months and months. Uninstalling (profoundly and manually deep) and reinstalling didn't help. Only using this other version helped.

👍 2