This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-22
Channels
- # announcements (13)
- # babashka (22)
- # beginners (22)
- # biff (17)
- # calva (6)
- # clerk (20)
- # clj-kondo (25)
- # clj-together (5)
- # clj-yaml (20)
- # cljdoc (16)
- # cljs-dev (1)
- # clojure (42)
- # clojure-brasil (1)
- # clojure-europe (26)
- # clojure-nl (6)
- # clojure-norway (24)
- # clojure-turkiye (3)
- # clojure-uk (5)
- # clojurescript (37)
- # core-async (7)
- # core-logic (2)
- # datalevin (7)
- # datomic (43)
- # events (2)
- # fulcro (7)
- # gratitude (1)
- # hyperfiddle (7)
- # java (7)
- # jobs (3)
- # lsp (4)
- # off-topic (16)
- # pathom (18)
- # polylith (1)
- # portal (27)
- # reitit (4)
- # releases (3)
- # shadow-cljs (47)
- # tools-build (14)
- # tools-deps (16)
- # yamlscript (11)
I found a weird behaviour, I initially used this main-opts for my nrepl alias:
:main-opts ["-m" "nrepl.cmdline"]
but because the The nREPL server does not support cider-nrepl
warning always show up every jack-in and I want to get rid of it, I changed my main-opts to this:
:main-opts ["-m" "nrepl.cmdline" "--interactive" "--color"
"--middleware" "[cider.nrepl/cider-middleware]"]
which makes the warning go away
however, this happens: I can’t use the cmd + click
to see usage references anymore, is this a config issue or a bug?
small repro project with the connect sequence as well: https://github.com/keychera/repro-calva-refsI think what happens is that without the middleware, the nREPL server is not good enough, and Calva will not try to do definition lookups via nREPL, but instead falls back on clojure-lsp. Then when you add the middleware Calva gets happy enough with the nREPL setup and will use that for its lookups. But since you haven’t loaded main.clj
yet, nothing is defined and that lookup won’t find anything. See if defining do-something
(loading the file with the Calva: Load/Evaluate Current File and Dependencies command is the best test) makes definition lookups on it work. Some more notes:
• You don’t need to select an nREPL alias as far as Calva is concerned. (Maybe you have other reasons for it, just noting.)
◦ Related to this, your nrepl alias is using newer versions of the dependencies than Calva has been tested with. It is probably fine, but you’re in uncharted territory. 😃
• Search for Calva Diagnostics in the command palette and you’ll find a way to log the nrepl traffic
• There’s a setting for prioritizing which service is queried for definitions first (clojure-lsp or nrepl); calva.definitionProviderPriority
(it’s a bit up to what you define as the “truth” which one will work best in some edge cases).
Please let us know how you fare! 🙏
So I just learned a whole lot from what you told me
1. I didn’t know there could be two sources of definition, being from lsp and repl is not in my mental model up until now
2. I didn’t know that you don’t have to specify an alias, I think I confused it with someone else’s project config I saw, I mimic it, and at some point, I just assumed that I need it
now, this is what I tried
1. I delete the aliases (using empty map {}
deps.edn) and "menuSelections": { "cljAliases": []},
in the connectSequence
- doesn’t work yet
2. I try Load/Evaluate current file...
- doesn’t work yet
3. got a random idea: I remove my "afterCLJReplJackInCode": "(do (require 'main) (in-ns 'main))"
and re Jack-in
- it does work now!
So that code is the problem, but why is that?
I originally use that as a small shortcut so that I can eval stuff in the comment
block in that file immediately, but it’s not that crucial, but I still want to know why it does that
Thanks for the feedback. I think part of the issue here is a bug causing Calva to not fall back properly on lsp when the nrepl provider does not return with anything useful. And not providing useful feedback about the lookup failing. I don’t think you as a user should need the correct mental model to get the basics working.
I’m not sure why your jackInCode doesn’t work. But knowing about it makes me take back a bit of my previous theory. 😃 Well, mostly it is still correct. But not for the reasons I speculated in. That nREPL log I mentioned above might be of help to see what’s going on with the jack-in-code. You can also try evaluate it manually after jack-in and see if you get an error.
BTW. Generally you should have an app namespace and then your main namespace in there, Something like my-app.main
. It doesn’t matter in development. The REPL doesn’t care. But when packaging things in uberjars, precompiled I think you might run into trouble. Something with the JVM, something, something (I have forgotten the reasons).
menuSelections
is optional, FYI.
A reason that other project had an nrepl alias might have been that it was used by people using tools that need it.
@U0ETXRFEW just a little update, for now I used the settings definitionProviderPriority
to prioritize lsp. writing this because I felt like I left you hanging, sorry about that.
I agree that users shouldn’t always need to understand the inner working to use the tools but in my case I actually appreciate it much because I also want to understand at least the “boundaries” between the tools.
I might explore this again since this is reproducible and I am kinda curious, but it’s just the matter of the available time I have 😅 so for now, this issue is resolved for me and I will make a new thread or github issue once I properly gather all the info again someday