This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-25
Channels
- # announcements (4)
- # asami (26)
- # babashka (82)
- # beginners (27)
- # biff (6)
- # boot (1)
- # calva (42)
- # cider (2)
- # clj-commons (1)
- # clj-http-lite (2)
- # clj-kondo (37)
- # cljdoc (1)
- # clojure (46)
- # clojure-europe (34)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (2)
- # clojurescript (54)
- # code-reviews (18)
- # cursive (2)
- # datalevin (32)
- # datomic (7)
- # etaoin (1)
- # fulcro (9)
- # gratitude (3)
- # hyperfiddle (15)
- # introduce-yourself (1)
- # jobs (2)
- # lsp (32)
- # nrepl (1)
- # off-topic (18)
- # pathom (17)
- # pedestal (5)
- # polylith (89)
- # reitit (7)
- # releases (3)
- # remote-jobs (4)
- # shadow-cljs (52)
- # spacemacs (3)
- # squint (14)
- # tools-build (10)
- # tools-deps (18)
- # vim (4)
- # xtdb (34)
Dear Calva friends. v2.0.294 just released: • https://github.com/BetterThanTomorrow/calva/issues/1836 • Fix: https://github.com/BetterThanTomorrow/calva/issues/1833 • https://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. 😃
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?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. 😃
Correct, the theme colors applied look like they understand the language.
Yes, it does.
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.
Yes, that's what I mean.
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.
I will, thanks. Have a good evening.
I think https://github.com/BetterThanTomorrow/calva/blob/published/src/lsp/main.ts#L92-L93 is how we tell vscode to use this server
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?
I think the reason VS Code treats it as a Clojure file is because of some AI stuff based on the file content.
No, this is entirely client responsibility to know when to start the server, I think that documentSelector is specific for vscode though
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.
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
I can't recall if kondo fallback to infer a .clj extension or if clojure-lsp should pass it manually
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.
However, the fact that we need to exclude the Calva output/repl window extension indicates that clj-kondo is not discriminating based on this.
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
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
TLDR: it's client responsibility to tell server that a file is part of that LSP workspace (sending didOpen
requests )
You can confirm that checking json logs between client<->server @U0ETXRFEW
That's one of the strange clues here. VS Code does recognize it as a Clojure file. I'll check the logs.
Thanks for all your help. I've added the issue: https://github.com/BetterThanTomorrow/calva/issues/1841
The clinet<->server log actually contains traffic for the extension-less file, @UKFSJSM38. I commented on the issue with a finding.
@UKFSJSM38 I’m guessing it’s related to the file extension checks in here: https://github.com/clojure-lsp/clojure-lsp/blob/a4a88439e0360a8dbdd8b89885e4c23a6c6f6621/lib/src/clojure_lsp/shared.clj#L107
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
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
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 😞
Yeah, adding to much complexity for a very rare use-case doesn’t sound like a good idea
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
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.