This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-28
Channels
- # announcements (7)
- # beginners (49)
- # calva (18)
- # cider (48)
- # clj-yaml (1)
- # clojure (37)
- # clojure-dev (23)
- # clojure-europe (29)
- # clojure-nl (1)
- # clojure-norway (16)
- # clojure-sweden (41)
- # clojure-uk (6)
- # clojurescript (32)
- # community-development (9)
- # conjure (4)
- # datomic (13)
- # hyperfiddle (24)
- # kaocha (6)
- # leiningen (4)
- # missionary (46)
- # nextjournal (1)
- # nrepl (26)
- # off-topic (101)
- # shadow-cljs (67)
- # testing (9)
- # yamlscript (5)
Why were symbols and keywords with multiple /
slashes added in https://github.com/clojure-emacs/clojure-mode/pull/475? I don't believe any of these are valid. (Context: I'm looking at https://github.com/clojure-emacs/clojure-mode/issues/653)
I don't like it myself, but seg.mnt/ve/yCom|pLex.stu-ff
(per https://github.com/clojure-emacs/clojure-mode/pull/475/files) appears to be a valid name, in the same way that clojure.core has (defn / [])
for division
keywords as well, or only symbols?
$ clj
Clojure 1.11.1
user=> :a/a/a
:a/a/a
not that I like it, but I can see why someone would want it supportedfair point, should've tried that myself
When using clojure-ts-mode
C-c C-z
doesnβt work in the REPL anymore because the fn
cider-repl-type-for-buffer
checks for buffers with clojure-mode
enabled. I patched the function like this and now it works fine -
(defun cider-repl-type-for-buffer (&optional buffer)
"Return the matching connection type (clj or cljs) for BUFFER.
BUFFER defaults to the `current-buffer'. In cljc buffers return
multi. This function infers connection type based on the major mode.
For the REPL type use the function `cider-repl-type'."
(with-current-buffer (or buffer (current-buffer))
(cond
((seq-some #'derived-mode-p '(clojurescript-ts-mode clojurescript-mode)) 'cljs)
((seq-some #'derived-mode-p '(clojurec-ts-mode clojurec-mode)) cider-clojurec-eval-destination)
((seq-some #'derived-mode-p '(clojure-ts-mode clojure-mode)) 'clj)
(cider-repl-type))))
Is this the best way to fix the issue?There are a few other issues, all of them are because of certain assumptions that cider makes about clojure-mode
being enabled/available. Is there any recommendation on how to use clojure-ts-mode
with cider at the moment?
A GH issue would be most welcome The only input we have so far is https://github.com/clojure-emacs/cider/issues/3356#issuecomment-1601174777
Cider builds a lot of functionality on top of clojure-mode at the moment and as you've discovered isn't aware of clojure-ts-mode's existence. I suspect some time in the future we will start building awareness of clojure-ts-mode into cider, or perhaps write some sort of compatability layer on top of clojure-ts-mode that acts like clojure-mode. Right now I don't have an "official" suggestion other than to do what you are doing right now and patching things up to make them work as you encounter them. Maybe some of the solutions you find could be submitted to cider? It may not be what we land on but would get the conversation started for how to start integrating clojure-ts-mode and other packages.
Yeah, that's what I'm thinking of in term of a compatibility layer. You are spot on there.
I wonder how it would work if clojure-ts-mode just defined functions with the exact same name in clojure-mode, like clojure-find-ns
for instance, and then at the end of the file called (provide 'clojure-mode)
. As long as clojure-ts-mode is loaded before cider this would work.
Whatever the solution, it shouldn't be noticed by users IMO
(defvar clojure-ts--find-ns-query
(treesit-query-compile
'clojure
'(((source (list_lit
:anchor (sym_lit name: (sym_name) @ns)
:anchor (sym_lit name: (sym_name) @ns-name)))
(:equal @ns "ns")))))
(defun clojure-ts-find-ns ()
"Return the name of the current namespace."
(let ((nodes (treesit-query-capture 'clojure clojure-ts--find-ns-query)))
(treesit-node-text (cdr (assoc 'ns-name nodes)))))
This is the total implementation of find-ns in clojure-ts-mode.
https://github.com/clojure-emacs/clojure-ts-mode/blob/d630cd63af8022d5a1fee0e7aa05450b6e0fd75e/clojure-ts-mode.el#L673-L684> I wonder how it would work if clojure-ts-mode just defined functions with the exact same name in clojure-mode Not sure if I would be a fan myself, since older packages would still depend on clojure-mode. So order would be determined by the package dependency tree? Wouldn't sound fun to troubleshoot / support π
Haha, fair enough. Just a fleeting thought.
I'd prefer to make the compatibility more explicit myself - like the checks proposed above for CIDER to just wrap whatever functionality it needs from clojure-mode
in functions that try both clojure-mode
and clojure-ts-mode
. (or something along those lines) Perhaps there can be even a config option in CIDER for which major mode to prefer.
Shouldn't be very hard to do - I guess the only tricky part would be some REPL-powered font-locking and indentation when you're using clojure-ts-mode, but we can simply disable this in the beginning.
> I guess the only tricky part would be some REPL-powered font-locking and indentation when you're using clojure-ts-mode, but we can simply disable this in the beginning That is going to be tricky
It's not essential, so I assume most people will be able live without it for a while. I'm not sure we'll be able to update the TS grammar's on the fly the way we've been doing it for clojure-mode.
The grammar we cannot update on the fly since it is statically compiled
But some of the rules we may be able to, although many of the tree-sitter facilities are setup such that they are captured when the mode is initialized.
We'll figure something out. As I said that's not an essential feature, so I don't see it as some roadblock.
βΉοΈ Starting from today's snapshot (`<tel:202308281813|20230828.1813>` , or simply master
if Git is your jam), CIDER has a revamped enrich-classpath integration.
Over the last couple months (and after a long pause) I've reworked that lib, and its integration into cider.el.
enrich-classpath allows you to interact with Java sources in autocompletions, navigation, documentation and stacktraces. It makes available both third-party Java sources, and the sources from the JDK itself.
What's new?
β’ Categorically more robust
β’ Integrates with Lein and now Clojure CLI
β’ If you use Lein, your repl will use just one JVM backed by a clean java
command, instead of Lein's usual two-JVM approach
https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath and other http://docs.cider.mx pages are its documentation for now. (enrich's https://github.com/clojure-emacs/enrich-classpath on github is outdated atm)
tldr: opt in to (setq cider-enrich-classpath t)
, and enjoy it when jacking in to JVM projects. (No cider-connect usage is documented for now)
Bear in mind the first run will be a touch slow for a given project.
Feedback would be extremely useful before releasing CIDER 1.8.0. ππ
Is it intended that cider-jack-in-clj
simply freezes emacs while it loads? I am using Emacs 28.2 and just ran M-x straight-pull-package-and-deps
and M-x straight-rebuild-package
to try out the latest CIDER
the previous behavior I would see the leiningen command invoked in my message buffer and wait β it was async
these changes also seem to have broken a few leiningen options (e.g. repl options like :init-ns
doesnt work anymore)
It can appear to freeze since it's doing stuff. Can take a good minute on a large project
> these changes also seem to have broken a few leiningen options (e.g. repl options like :init-ns
doesnt work anymore)
Interesting. I honor :init
but hadn't thought of :init-ns
in short I have a project with the following set
:repl-options {:init-ns foo.bar}
:global-vars {*warn-on-reflection* true}
and I start in the user
namespace with *warn-on-reflection*
set to false
I'll see what I can do about that one. Maybe it's easy. Note that Clojure CLI doesn't offer that, so it's in a grey zone
> Is it intended that cider-jack-in-clj
simply freezes emacs while it loads?
I infer from your other feedback that the command eventually succeeded?
Yes, it succeeded. It just froze all of Emacs until the REPL appeared. The previous behavior in CIDER was spawning lein
and I was able to do other things while waiting
Thanks. I'll consider it. It's certainly a nuisance.
With Enrich's caching (which is partly shared across projects - much like ~/.m2
), as you use it more, load times will decrease.
With a bit of luck I can simply use whatever async facility made this work for traditional jack-in.
Is it possible to downgrade CIDER in the meantime? I assume this would depend on the package manager on uses in Emacs
yeah, I have it set to t
by default since I find the functionality useful, though the current workflow is disrupting a few of my lein projects
in particular, im noticing the dev profile is not being applied (though this is set by myself in a custom lein command in cider)
Does it really take more than a few seconds after the first time though? Profiles should be applied, I've used that myself every day let's debug it
i.e. I have cider-lein-parameters
set to "with-profile +dev repl :headless :host localhost"
, but one of my larger projects is no longer applying some stuff in the dev profile. itll be tough to make a repro but I can try soon
my cider-lein-parameters are:
"with-profile \"+async-checking,+test,+dev,+emacs-backend,+emacs-backend-init,+yourkit,+g1gc,+parallel-reload,+cider-nrepl-latest\" repl :headless :host localhost"
And all of them are appliedI see. I just attempted restarting CIDER, though the REPL only clears itself. However, if I quit the REPL then run M-x cider-jack-in-clj
, Emacs freezes for about 10 seconds, but this is way faster than the first startup π
Please paste the output of M-:
(cider--extract-lein-profiles cider-lein-parameters)
?
The other thing to keep in mind is, as mentioned, :init-ns and :global-vars are disregarded. Which is not a profiles bug, it's something else
It looks like the profiles do work. I just did a search in the java invocation and indeed I see the extra source paths provided by dev
. Sorry for the distraction
No issue!
> Emacs freezes for about 10 seconds, but this is way faster than the first startup
Pretty good news!
> I just attempted restarting CIDER, though the REPL only clears itself.
Ah, I'm not a sesman-restart
user myself so it escaped my mind. It's an important thing to support.
Thanks for the round of feedback!
I've gotten awesome value from it.
