This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-16
Channels
- # announcements (18)
- # architecture (12)
- # babashka (20)
- # beginners (32)
- # biff (21)
- # calva (81)
- # clerk (6)
- # clj-kondo (16)
- # clj-otel (5)
- # cljsrn (8)
- # clojure (94)
- # clojure-austin (1)
- # clojure-australia (1)
- # clojure-europe (68)
- # clojure-nl (2)
- # clojure-norway (6)
- # clojure-uk (2)
- # clojurescript (13)
- # conjure (1)
- # core-logic (1)
- # cursive (7)
- # data-science (2)
- # datahike (3)
- # datomic (12)
- # emacs (33)
- # etaoin (1)
- # fulcro (8)
- # graalvm (2)
- # graphql (1)
- # honeysql (1)
- # hyperfiddle (97)
- # improve-getting-started (40)
- # jobs (2)
- # jobs-discuss (12)
- # lsp (9)
- # membrane (6)
- # nbb (2)
- # off-topic (16)
- # portal (6)
- # re-frame (2)
- # reagent (3)
- # releases (2)
- # remote-jobs (1)
- # tools-deps (7)
- # xtdb (38)
I'm attempting to get a REPL into an existing project that has an nREPL Server, running with particular deps.edn aliases. I'm accustomed to working on this project using IntelliJ IDEA/Cursive. With Cursive one sets up a configuration specifying a connection type of nREPL, and that the nREPL is running at localhost:5309. That's all! Running this configuration gives you the local REPL needed for starting the web server and doing REPL development. Is there an equivalent configuration with Calva? I think the answer is no, as I've tried https://calva.io/connect/ at the heading "Connecting Without Jack-in". There isn't a Connect to a running REPL (as specified in the docs) but I assume the equivalent is now Calva: Connect to a Running REPL Server in the project. Trying that gave me this:
The nREPL server does not support cider-nrepl info op, which indicates troubles ahead. You need to start the REPL with cider-nrepl dependencies met.
Is it true that Calva only works with cider? I've put the cider-nrepl dependency into the nREPL Server, but that didn't help. So I guess my next question is how to support the 'info op', and what info will need to be supplied?Hi! I don't understand the part with how things work in Cursive and thus can't answer if it is possible in Calva. Can you describe what you need to work without framing it in how it works in Cursive? Calva works best with cider-nrepl, but doesn't strictly require it. There'll probably be some things that don't work. There's a command for copying a command line that will satisfy Calva's dependency needs. Calva: Copy Jack-in Command Line (or something like that). See if you can use that (with any adaptions you need) to start a REPL server that Calva does not complain about.
What (ideally) I need to work is connecting to a running nREPL Server by only specifying its host (localhost) and its port (5309). In our case the running nREPL Server has already setup everything via aliases, so I just need to get a local REPL that channels the commands back and forth to the nREPL Server. FWIW that's what I need to work without mentioning Cursive at all. I've now got the Jack-in command line. I'll try to work with that. Thanks.
What does a local REPL mean? Is it some kind of proxy? Generally if you have an application running with the nrepl dependencies and middleware configured, the Calva connect command should work. It will prompt you for a host and port. The prompt will be pre-populated if there is a repl port file present. Which file Calva looks for depends on the project type. You can also specify a custom REPL Connect Sequence, and change the port file there.
'local REPL' is my made up expression. It is a command line that I type Clojure into, that communicates with the nREPL Server. What should I call it?? Anyway 'Calva Connect' sounds promising. Got to run for something but will try it later. Thanks again...
Ah, sorry for being thick. That's what in Calva is referred to as the REPL client, I take it. I should have figured on channels the commands back and forth to the nREPL Server. Anyway, I think what's going wrong is that the cider-nrepl middleware isn't correctly injected. Let me know how you fare, I am pretty sure we can get this working. Possibly with one prompt more than you are used to.
Working now. The Calva: Copy Jack-in Command Line to Clipboard is a great idea and worked perfectly. I used it to augment what was already at the alias that has :main-opts ["-m" "nrepl.cmdline" ...]
. Yes there might be one or two times I have to press <enter> with filled in defaults compared to what I'm used to with Cursive. And as you say I could even get past that with a repl port file to specify the port.
Great to hear! You can get an almost prompt free experience with https://calva.io/connect-sequences/, Though we need to fix https://github.com/BetterThanTomorrow/calva/issues/1908 to get rid of the port prompt entirely.
@U0D5RN0S1 You might find https://corfield.org/blog/2022/12/18/calva-joyride-portal/ interesting as it talks about how we run plain nREPL servers in production processes at work and connect to them from Calva to debug stuff (we also run Portal servers and connect a browser to those, inside Calva, for visualization while debugging).
Thanks too @U04V70XH6 bookmarked that.
I received some complains about Calva watched files sending to clojure-lsp analyze clojure-lsp stub files
we could fix in calva or in clojure-lsp, specifically telling to ignore .lsp/.cache/stubs
but I wonder if Calva should not do that, suppose there is a file my-root/my-random-folder/some-weird-file.clj
, that is not in the source-path, calva will send and lsp analyze and report any found errors
Is there ever a case when we want notifications from the lsp cache? Calva could have an exclude list of globs, with some sane defaults, I think.
if the user find a definition of datomic.api we should show the errors, the issue is that it's being shown even without opening the cache files
Was it verified that those files were not somehow included in source paths? I’m guessing they weren’t, but anyway, I don’t know why those notifications are sent but I assume it’s something to do with how the vscode language client works by default. Maybe we can stop it from sending those notifications by default, but then make sure errors are still shown if they open a file like that.
If we exclude files in .lsp/.cache/stubs
, I’m guessing even if they open one they still won’t get errors since it’s excluded?
An issue is welcome.
Yeah, they are not in the classpath. Exactly, I suspect this is how vscode file watcher works, if we could add .lsp/.cache to a filter would probably be enough
Not that I'm aware of. Is this still a problem for some users? I'm guessing it is for you, @U9N15525C? If so, would you mind creating a GitHub issue about it?
I opened an issue and feel free to request more details if the isn't enough. https://github.com/BetterThanTomorrow/calva/issues/2465
Thanks. Maybe you can include information about what a stub file is? Maybe I’m not the only one who doesn’t know. 😃
The clojure-lsp stub is a clojure-lsp feature which uses https://github.com/clj-easy/stub lib to generate dummy clojure files to have clj-kondo analysis, so for example one would get auto complete for datomic.api
for example, a lib which is closed source
This feature spawns under the hood a clj process which exports the ns and vars, it's only enalbed if one has a :stub
setting in clojure-lsp config
Is there a way to configure Calva to redirect REPL stdout to a file? I’d like to be able to use some unix command line tools on it (lots of noise).
Not possible to configure Calva for this. There's an issue about it here: https://github.com/BetterThanTomorrow/calva/issues/1104 Some options: • The Output/REPL window is a file. Run your unix commands on that file? • Set some dynamic variable for where stdout should go (I don't know if this works, but seems it should...) • Evaluate the things you are interested in via Calva's API https://calva.io/api/#replevaluatecode from #joyride, this API supports a callback function for stdout. (This option is not very nice if you want to redirect evaluations generally, but good to know about, I think.)
Can I configure it to use a custom shell command for starting the REPL?
… for jack-in
I’m sure I could start lein from the command line and connect Calva via REPL port. I realize I don’t get all the nice nrepl integrations that way, but I don’t need that in this case
Not sure I follow... You can copy the jack-in command to the clipboard and start the repl yourself.
that is exactly what I am trying now
piping it through tee
Jack-in does not support custom shell commands today. I've been wanting to add that a while.
Another option would be to add a tap that prints to where you want. That is similar to tee
.
These actions produce an extra space that I wish weren’t there:
⏐:b
;; Want to wrap :b, type '['
[⏐]:b
;; slurp forward
[⏐ :b]
;; don't like that space, wish instead it were
[⏐:b]
There are ways to ‘fix’ it. I can immediately hit TAB
and the space goes away, or I can select :b
before hitting [
. This isn’t specific to brackets, it’s the same result with any delimiter. Any suggestions?I agree. We changed this a while ago to fix another problem, but this extra space is quite annoying. You are welcome to file an issue.
Or ctl+alt+shift+p
to wrap-with-`(`..`)`
(similarly cas+ s/c for square/curly)
Yes, for some slurp operations there are alternatives. But not for all and this space is not cleaned away properly for more Paredit commands.
I've tried to add some context to the issue in a comment now. And the question's out to @ahtunget if you feel hungry for yet another PR? https://github.com/BetterThanTomorrow/calva/issues/2085
Honestly, I quite like the current behavior. Yes, it can be slightly annoying sometimes. But what about the case where you want to keep typing where the cursor is?
; now I want to add foo
[|bar]
If you start typing immediately, there is no space between your cursor and the slurped-in symbol.
[foo|bar]
Type hinting is broken and clj-kondo throws a fit about foobar
not being declared.
The solution is, of course, is to type Space
then Left-Arrow
. before you start typing again.
[|bar]
[ |bar] ; space
[| bar] ; left
[foo| bar] ; now we can finally type
But coming up with that uses way more cognitive load than a simple Delete
when the space is unwanted.After a recent update of VSC/Calva, all symbols required as :refer :all
from another workspace are highlighted in red by the editor. Any fixes?
It's clj-kondo that is discouraging you from bad habits. 😃 I thought it was doing that by default since long, but maybe I am wrong. Could be that it is new and clojure-lsp has been updated because Calva set to use latest
clojure-lsp. You can disable this linting by adding clj-kondo config. See https://calva.io/linting/ for some pointers.
There are some answers to this at https://stackoverflow.com/questions/24463469/is-it-possible-to-use-refer-all-in-a-clojurescript-require, including that refer-all was omitted from ClojureScript because it is such poor style. :-)
Clojure aims at an ideal that program code should be "evident" - the meaning should be visible. I seem to recall Java's "import star" being cited as a motivating anti-pattern: it "saves time" for the first ten minutes and forever thereafter confounds you. Core-library symbols are excused, but every other symbol should be defined in the file where it is used. A single refer-all strains the principle because there is no positive indication of the source of a symbol, and a second refer-all suddenly drowns the reader in cluelessness.
Hello Calva friends! I have been using Calva in VS Code in WSL for quite a while but it looks like I may have to use VS Code in Windows now. I cloned a repo and when I opened it in VS Code I get this message:
I can successfully do a lein run.
Hmmm Cannot run program "clojure" (in directory "C:\Projects\activity-indexer"): CreateProcess error=2, The system cannot find the file specified
I am able to run one Clojure project and get no errors.
So this must be project dependent.
I noticed no .lsp directory.
There are a few things to consider here:
• In the Leiningen project, clojure
is not needed.
• If you are starting the project with Calva Jack-in, and clojure
is not installed, it will still work (Calva uses a fallback method)
A lot of times I lein run and then connect to the project repl. Sometimes we spin up a repl port when running in dev.
Sometimes VS Code does not have the same environment as you have at a command prompt. So to see that lein
works, use it from an integrated VS Code terminal. If that doesn't work, then clojure-lsp will fail for that project.
All I do is run from the integrated terminal.
Less windows. 🙂
I see. Then I actually don't understand why you get that error. Maybe @UKFSJSM38 has some input.
Ok. I'll keep going. Not sure if stuff in my project is causing it. I'll try another one.
For the best Calva REPL experience: When using connect to connect to a running REPL, That REPL should be started satisfying some Calva dependencies. There is a command Calva: Copy Jack-in Command Line that gives you a command for starting the REPL in a Calva compliant way.
Oh cool! I'll check it out! Thank you for responding so quickly.
All this because I had to switch to a 3rd party VPN and my projects in VS Code in WSL2 can't connect to Postgres SQL now.
Also: A lot of Calva still works even when clojure-lsp fails to start, so you can still work on your project.
Ok. Thanks, again.
Yeah. My coworkers all have Macs and I went to the effort to set up a dev environment in WSL2 so we could be same-same.
Maybe try figure out how to connect that Postgres from WSL2. Sounds like it shouldn't be impossible?
Yup. I would rather stay in WSL2. Thanks for your time.
@U01925RGFC7 I'm curious which VPN doesn't work with WSL? We use the Cisco AnyConnect client at work and WSL is fine with that -- I ssh from WSL to servers at work all the time with the Windows VPN in place.
CheckPoint Endpoint Security
Good to know. Thanks.
I can ping the Postgres server all day long. But can't connect.
@U01925RGFC7 Have you tried running this exact command in a terminal (integrated and not)?
I mean using that absolute path to that lein.bat file along with the args stated in that message.
I've tried to add some context to the issue in a comment now. And the question's out to @ahtunget if you feel hungry for yet another PR? https://github.com/BetterThanTomorrow/calva/issues/2085