Fork me on GitHub
#calva
<
2022-08-25
>
pez07:08:56

Dear Calva friends. v2.0.294 just released: • https://github.com/BetterThanTomorrow/calva/issues/1836 • Fix: https://github.com/BetterThanTomorrow/calva/issues/1833https://github.com/BetterThanTomorrow/calva/issues/1839 🎉 So when @bozhidar asks ”who's running nREPL 1.0?” you can raise your hand if you are a Calva jack-in user. 😃

cider 6
🎉 8
❤️ 3
😄 1
🙌 1
jeffparker18:08:41

We have a few babashka scripts without file extensions that begin with a shebang to indicate they're babashka scripts:

#!/usr/bin/env bb
; vim: ft=clojure
(load-file "")
In Calva, font locking is properly applied yet we're missing the function listing that shows with a .bb file extension. Is there an easy way to configure language association these based only on the shebang?

pez19:08:43

What does it mean that font locking is applied? I think this is an Emacs term, but I've never really understood what it is. 😃

jeffparker19:08:04

Correct, the theme colors applied look like they understand the language.

pez19:08:56

I see. Does the status bar indicate that it is a Clojure file?

jeffparker19:08:14

Yes, it does.

jeffparker19:08:53

What's missing is the list of functions that normally shows at the top of the file once I've clicked within a function in the file.

pez19:08:17

I don't quite follow which list this is. The breadcrumbs?

jeffparker19:08:56

Yes, that's what I mean.

pez19:08:19

OK. So I tried this now. I think I know what's (not) happening. It's clojure-lsp that is not active in this file. Right now I don't remember how clojure-lsp is activated for a file, but I am pretty sure you can't configure it. Please file an issue on Calva so that we can track this. Maybe @U9A1RLFNV and @UKFSJSM38 knows more about what we should do to fix it.

jeffparker19:08:07

I will, thanks. Have a good evening.

pez19:08:32

Thanks @UKFSJSM38. Is this documentSelector sent to clojure-lsp as config and clojure-lsp uses it to decide if it should handle the file or not?

pez19:08:02

I think the reason VS Code treats it as a Clojure file is because of some AI stuff based on the file content.

ericdallo19:08:17

No, this is entirely client responsibility to know when to start the server, I think that documentSelector is specific for vscode though

pez19:08:28

The server is started. That's not the problem. Or maybe I am misunderstanding you here.

pez19:08:05

There is also this: https://github.com/BetterThanTomorrow/calva/blob/published/src/lsp/main.ts#L129-L134 Even if it seems we only really exclude the output/repl window there.

ericdallo19:08:38

Yes, maybe what could be happening is:

ericdallo19:08:14

clojure-lsp apply semantic tokens based on clj-kondo analysis for that file, if the file has no extension, maybe kondo is not returning the analysis properly

ericdallo19:08:36

I can't recall if kondo fallback to infer a .clj extension or if clojure-lsp should pass it manually

ericdallo19:08:48

all of that, if the server is running properly of course

pez19:08:43

Yeah, the server is running properly. If I open a file with a recognized (by Calva) extension, we get semantic tokens and outline and things.

pez19:08:39

However, the fact that we need to exclude the Calva output/repl window extension indicates that clj-kondo is not discriminating based on this.

ericdallo19:08:59

The server could be running for other files but vscode not recognizing that file as a clojure file, resulting in no lsp features or clojure-lsp know about that file existence

ericdallo19:08:48

for example, on emacs, we only know we should use lsp on a file if one starts the clojure-mode on that file, then lsp-mode knows it should consider that file part of the running server

ericdallo19:08:13

TLDR: it's client responsibility to tell server that a file is part of that LSP workspace (sending didOpen requests )

ericdallo19:08:38

You can confirm that checking json logs between client<->server @U0ETXRFEW

pez20:08:43

That's one of the strange clues here. VS Code does recognize it as a Clojure file. I'll check the logs.

1
jeffparker20:08:40

Thanks for all your help. I've added the issue: https://github.com/BetterThanTomorrow/calva/issues/1841

🙏 1
pez20:08:40

The clinet<->server log actually contains traffic for the extension-less file, @UKFSJSM38. I commented on the issue with a finding.

👍 1
ericdallo13:08:13

Yep, yesterday I tested changing it and it worked, I was just double checking if there was other features using that that could be negatively affected

Lukas Domagala13:08:25

I think the biggest thing is probably that clients can’t be as lax as before. If you now treat every sent file as clojure code it’s going to give interesting results if my client just sends everything 🙂 But that would be a bug in the client so we should be aware of it but not base decisions around it

ericdallo13:08:03

Yeah, I think it's a better tradeoff from server side view

Lukas Domagala13:08:20

It still won’t pick up the files if they aren’t open in the client, correct? But doing that would add a bunch of new problems 😞

ericdallo13:08:48

I guess it's fine for now

Lukas Domagala13:08:29

Yeah, adding to much complexity for a very rare use-case doesn’t sound like a good idea

pez13:08:07

To me it's unclear what the alternative would be. I see only these two: • Limit on the file extensions, and let some Clojure files be treated wrongly • Don't limit on file extension, and the client gets what it asks for

Lukas Domagala13:08:29

Yes @U0ETXRFEW. Although file extensions will still be limited a bit in the sense that unknown extension files will only be analyzed when the client tells the server about them (mostly on open). So if you have a dependency on a file with an unknown ending and you don’t open that file, the dependency would be show as missing.

pez13:08:38

Yeah, I guess analyzing everything in the project is not an option. 😃

ericdallo14:08:34

Yes, I think supporting clojure-lsp features on the opened file is already enough to solve the issue for most people