Fork me on GitHub
#calva
<
2022-06-15
>
dchelimsky01:06:50

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

1
dchelimsky01:06:17

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

dchelimsky01:06:57

Obs: this is in a cljc file.

dchelimsky01:06:56

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

borkdude05:06:46

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

dchelimsky10:06:52

D’oh! Of course.

phill01:06:53

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.

borkdude05:06:21

Perhaps your project has a bb.edn?

seancorfield03:06:51

I'm seeing something strange lately with Calva/LSP: if I add a new namespace to the :require in an ns, e.g., [foo.bar :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 'foo.bar/some-func instead of bar/some-func which is what I'd expect. Any suggestions for debugging why it isn't working?

seancorfield03:06:42

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.

seancorfield03:06:19

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.

ericdallo13:06:15

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

seancorfield16:06:06

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

ericdallo16:06:31

Could you provide a simple repro where I can try?

seancorfield16:06:11

I'll try but this is all work code.

seancorfield16:06:27

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

ericdallo16:06:56

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

seancorfield16:06:35

Do you have any suggestions for debugging that?

seancorfield16:06:05

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

ericdallo16:06:13

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

ericdallo16:06:18

Clojure-lsp server info

ericdallo16:06:31

There should print the source-paths

seancorfield16:06:46

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

👍 1
seancorfield16:06:58

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

ericdallo16:06:48

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

seancorfield16:06:22

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...?

ericdallo16:06:23

Yes, maybe the project root is wrong

seancorfield16:06:33

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 classpath.sh script to run clojure -Spath ... with all the right aliases...

ericdallo16:06:36

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

seancorfield16:06:08

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

ericdallo16:06:08

Probably you could just use the :source-aliases setting

ericdallo16:06:44

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

seancorfield16:06:32

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

seancorfield16:06:02

Now I'm getting the correct code suggestions.

ericdallo16:06:25

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

ericdallo16:06:34

Then you wouldn't need that classpath script

ericdallo16:06:56

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

seancorfield17:06:03

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?

seancorfield17:06:48

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.

ericdallo17:06:06

That for debugging only

ericdallo17:06:18

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

ericdallo17:06:48

@U04V70XH6 thats why I suggested using source-aliases setting

seancorfield17:06:16

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
seancorfield17:06:55

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

seancorfield17:06:06

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

seancorfield17:06:17

What about the nREPL server thing?

ericdallo17:06:10

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

1
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: https://docs.cider.mx/cider/basics/middleware_setup.html , but I didn't really understand it. Can anyone help me out with this? Any pointers?

👋 1
calva 1
pez07:06:35

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.

pez11:06:05

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.

pez12:06:55

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?

pez12:06:28

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).

pez13:06:17

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.

pez13:06:34

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 😀

pez13:06:08

Haha, we will be two speaking broken English.

pez13:06:24

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?

pez13:06:03

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.

pez15:06:22

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).

pez15:06:48

Like so:

borkdude15:06:10

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.

borkdude16:06:28

@U03L31E1Y1F Cool. Maybe nbb + ink is something worth trying https://github.com/babashka/nbb#reagent

👍 1
👋 1
Sohang Chopra16:06:36

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

pez06:06:44

@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)

pez07:06:44

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?

pez07:06:02

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!

pez07:06:39

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 (https://github.com/sohang3112/example-clojure-app) 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.

pez11:06:20

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

pez13:06:30

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.

pez13:06:31

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?

pez14:06:13

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?

pez14:06:15

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?

borkdude14:06:16

@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
pez15:06:25

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).

seancorfield18:06:05

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
    }

seancorfield18:06:22

I also have .calva in my .gitignore file.

pez18:06:05

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

chucklehead19:06:23

open files are always included in results

seancorfield19:06:10

Ah, that explains it! Thanks @U015879P2F8!

seancorfield20:06:38

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...

phill22:06:49

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.

ericdallo03:06:32

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.

ericdallo14:06:53

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