emacs

djm 2025-03-24T13:27:23.940949Z

When I mentioned it previously, lots of people said there were affected by a regression in smartparens related to symbols ending with ?. Someone has raised a PR that fixes the issue, so if people can test and comment, that might help get it merged. https://github.com/Fuco1/smartparens/pull/1229

❤️ 1
1
Florian 2025-03-26T07:22:37.150469Z

Tried it in doom emacs using

(package! smartparens
          :pin "109b6fc684a96e3b52ed76ec68eec8c4052b9e61")
And it's not fixing the problem

djm 2025-03-26T07:47:57.398189Z

Did you forget some kind of rebuild/compile step? It works fine for me.

✅ 1
Florian 2025-03-26T08:07:37.004789Z

yes you're right, my doom emacs conf was bad. I should have been

(package! smartparens
  :recipe
  (:host github :repo "thatismatt/smartparens")
  :pin "109b6fc684a96e3b52ed76ec68eec8c4052b9e61")
And now it's working fine

👍 1
Gregory Bleiker 2025-03-24T16:44:55.442189Z

Is there any way to auto-import or auto-suggest clojure imports based on an unresolved function in the code, so if I'd write (m/sqrt 4.0) it would suggest require [clojure.math :as m] or similar? And also update deps.edn?

vemv 2025-03-24T16:46:26.629389Z

the deps part not so much, but clj-refactor's "slash" (just hitting slash) does this, in a very fine-grained and configurable manner

Gregory Bleiker 2025-03-24T16:47:41.552949Z

Thanks @vemv!

🙌 1
vemv 2025-03-24T17:31:37.181239Z

If you try it, LMK how it went. It's smarter than one might think, e.g. it scans your projects so that it automatically infers your prefered conventions

Gregory Bleiker 2025-03-24T17:33:25.982109Z

It needs cider to work, correct?

vemv 2025-03-24T17:34:08.224839Z

Yeah, it works over nrepl where typically you'd have cider and refactor-nrepl middleware

👍 1
Gregory Bleiker 2025-03-24T17:35:27.422499Z

I'm working on a cljojuredart project atm, but as soon as I have something in clojure, I'll try it and let you know. Thanks again

vemv 2025-03-24T17:38:17.820919Z

Nice! I know nothing about cljd. If it uses reader conditionals and a .cljd extension, we at cider would surely be happy to accomodate for changes (maybe it's not that simple? I could imagine)

Gregory Bleiker 2025-03-24T17:39:49.887599Z

unfortunately, cljd does currently not have a repl, so it's probably not feasible right now (but there's an ongoing discussion that this is on the roadmap)

👍 1
a13 2025-03-24T17:43:00.793189Z

@gregorybleiker You can take a look at my PR here https://github.com/clojure-emacs/clj-refactor.el/pull/559 It doesn't do anything smart, it just assumes common aliases.

ericdallo 2025-03-24T18:33:11.388099Z

BTW clojure-lsp supports that without the need of a repl, showing the usages count across the project https://clojure-lsp.io/features

👍 3
2025-03-24T20:17:48.470309Z

I am sure this has come up before, but I haven't found it, is there some way to stop cider from messing with M-.? jump to definition with clojure-lsp works great until I have a repl started and it stops working until I track down the source file the definition is (which jump to definition would be really helpful for) and load it in the repl

oyakushev 2025-03-25T07:16:15.172889Z

Could you please submit a ticket with a small reproducer to https://github.com/clojure-emacs/cider? Maybe there is a way to merge the xref backends.

bozhidar 2025-03-25T07:17:16.283139Z

@alexyakushev They are just a functions in a list (like so many things in Emacs), that's why it's kind of hard to automagically handle this.

bozhidar 2025-03-25T07:18:15.343609Z

What would probably be easier is for our backend to react differently to the lsp-mode or eglot being active, but it is still hard to guess what each user would like to do in this case.

bozhidar 2025-03-25T07:18:38.777329Z

E.g. I'd probably prefer references from LSP, but I'd still want find definitions to come from CIDER, and so on.

oyakushev 2025-03-25T07:18:43.403179Z

From what I heard so far, it sounds like CIDER xref function acts as a catch-all even if it can't resolve the thing to jump to, and that stops other backends from working. Maybe something can be done about that.

bozhidar 2025-03-25T07:19:26.893319Z

Ah, perhaps something can be improved for the chaining, but this still depends on the ordering of the backends in the list of backends.

oyakushev 2025-03-25T07:19:42.395259Z

Or we can suggest putting the cider function to the end of the list. Anyway, a reproducer would be very helpful as a something to work with

bozhidar 2025-03-25T07:19:45.161959Z

I recall most issues reported in the past were along those lines, but I might be forgetting/missing something.

djm 2025-03-25T13:44:28.859579Z

The documentation already linked to explains how to put the cider function at the end of the list (i.e. by setting cider-xref-fn-depth).

djm 2025-03-25T13:45:04.562239Z

https://elpa.gnu.org/packages/xref-union.html exists for combining xref backends, but I haven't used it

2025-03-25T15:14:46.194779Z

https://github.com/clojure-emacs/cider/blob/master/cider-mode.el#L489 this behavior means even if I turn xref off for cider, it still hijacks M-. and turning off xref just means it attaches M-. to an even less useful behavior

djm 2025-03-25T15:23:32.774579Z

Doesn't leaving it turned on, but giving it a lower priority than lsp do what you want? (To be clear: changing the priority/depth doesn't affect any buffers that xref-backend-functions is already set for, but only affects where in that list it'll be put in the future)

oyakushev 2025-03-25T16:16:15.102719Z

> (unless cider-use-xref I'm not 100% sure, but I think the whole cider-use-xref thing was added as a cautious fallback because we weren't confident about the new xref backend vs the old established functionality. I think at this point we can remove the fallback and use xref exclusively. @bozhidar does it sound right?

2025-03-25T17:05:40.975199Z

ah, yes, it does look like adjusting the cider-xref-fn-depth gets what I want

bozhidar 2025-03-25T17:09:00.348069Z

@alexyakushev More or less - we also had to support older Emacs versions at the time. Fundamentally, the biggest problem remains that the find-references in CIDER is not considered very useful by most people. I'm guessing if we implement in terms of a simple text search it will probably be more useful to the majority of people. I recall that's what SLIME was doing (or rather swank-clojure).

ericdallo 2025-03-24T20:21:54.413439Z

on doom-emacs I do this:

(set-lookup-handlers! '(cider-mode cider-repl-mode) nil) ;; use lsp
which completely delegates definition to LSP

2025-03-24T20:25:13.027029Z

yeah, I just figured out if I run (setq xref-backend-functions (cdr xref-backend-functions)) which punts cider's xref stuff out of the list my M-. starts working again

2025-03-24T20:28:44.008919Z

ah, there is a "cider use xrefs" customization and toggling that off unbreaks things. a pitty that information isn't merged properly from different sources

2025-03-24T20:42:56.955459Z

ugh, it is actually unclear if the xrefs customization did fix this, it seems like there is some buffer local state involved, and some of my buffers are working and some are not

2025-03-24T22:51:52.771959Z

arg, with a restarted emacs and xrefs customized to off for cider, when cider is running and I M-. on a symbol I get a "Symbol: " prompt in the mini buffer

2025-03-24T22:52:18.518019Z

when cider is not running it just works thanks to clojure-lsp

2025-03-24T23:00:41.646119Z

yeah, when you turn xrefs off for cider, it still hijacks M-. instead having it call cider's cider-find-var function

2025-03-24T23:06:05.195579Z

well I found the but of the cider keymap that does that and just commented it out 😕

bozhidar 2025-03-25T06:53:30.319439Z

The docs have a section about using LSP https://docs.cider.mx/cider/usage/misc_features.html#xref-integration

bozhidar 2025-03-25T06:57:17.739089Z

This disables CIDER's xref backend, which I assume is what you want to do.

Akiz 2025-03-29T09:25:59.319279Z

This is what i use

(cider-xref-fn-depth 90)
 (cider-use-xref nil)