lsp

Drew Verlee 2025-04-12T21:26:56.902169Z

what are the trade offs between cider-xref-fn-refs and lsp's find all references: assuming you can use either to their full capabilities (clj, project fully in repl, etc..)

borkdude 2025-04-12T21:33:27.248799Z

one feature clojure-lsp supports that CIDER does not (AFAIK) is finding references of local bindings

🙏 2
Drew Verlee 2025-04-12T21:34:32.089339Z

are their any instances where cider find ref or goto def does something lsp wont do? like because cider is using the runtime info?

borkdude 2025-04-12T21:34:54.299699Z

CIDER mentions the following limitations to their xref:

Keep in mind the following limitations:

This works only for Clojure

It's powered by runtime state analysis, which means it will show only data for loaded namespaces (like most of CIDER's functionality)

It doesn't (currently) find usages in lambdas

It doesn't give us the precise locations where something is used, we only know that it's used

👍 1
Drew Verlee 2025-04-12T21:35:43.875279Z

Thanks, yeah, i had seen that, wasn't sure i understood the full impact of the last bit.

borkdude 2025-04-12T21:35:53.336849Z

clojure-lsp relies on the static analysis of clj-kondo. if there's something clj-kondo doesn't understand then you'll not find the reference

🙏 1
Drew Verlee 2025-04-12T21:37:21.745359Z

last but not least, has anyone made emacs search function to rule them all? triggering lsp and cider, aggregating the results, picking the best, and maybe trying text-search if neither are available?

Drew Verlee 2025-04-12T21:37:59.534299Z

additional (and very personal to me) my emacs commands and bindings for find def and find ref are all over the place and i need to clean them up. lolcry

borkdude 2025-04-12T21:39:09.089399Z

I've set up "goto" as first try clojure-lsp and if it doesn't find any, use CIDER

👍 1
👆 1
2025-04-12T22:23:26.005749Z

I completely disable ciders xref support, just gets in the way, and only works if something is loaded in the repl, which stuff isn't always, then you need to find it to load it, and boy xref sure would be helpful in finding it to load it

2025-04-12T23:46:02.513719Z

I think lsp will fail if the code is malformed. Cider will still refer to the last properly formed loaded ref.

2025-04-12T23:47:34.970419Z

As an aside, I had implemented a local ref in Emacs directly in anakondo, because kondo would not work on malformed input, like missing closing parens, unbalanced forms, etc.

borkdude 2025-04-13T06:44:15.136989Z

Kondo had some fixes about incomplete forms, so perhaps it should work now. If not you may file an issue

👍 1
ericdallo 2025-04-13T12:56:51.681079Z

From my (biased) experience, I think that is the most reliable and tested LSP feature, that works so good out of the box that worth comparing with cider tradeoffs.

👍 2
Drew Verlee 2025-04-13T17:48:20.140449Z

Thanks for the replies everyone. it really helps 🙏

karol.adamiec 2025-04-14T06:57:09.983119Z

also, LSP finds keywords with namespaces in all? possible forms. AFAIR Cider was not able to do that. (i mean form, keys destructuring ets etc). Lifesaver.

djm 2025-04-14T07:05:10.126129Z

Given the choice, I'd use lsp for xref-find-references and cider for xref-find-definitions. But apparently I haven't cared enough to write the code to make it happen. (I think it was macros where cider does better for the latter).

Stig Brautaset 2025-04-14T09:44:31.405449Z

Definitively preferring clojure-lsp for xref. One issue I have with CIDER is that I work with many different projects, and for many of them CIDER won't start unless I start dependent services first. Moreover, because they all tend to rely on the same Pg port they won't all start at the same time. (I appreciate that this may be a problem with our test setup, but it certainly is a factor of my choice.)

☝️ 1
2025-04-14T20:36:25.493389Z

Ah true, when macros define vars, if they don't have a kondo config then those can't be found by lsp, but are by Cider. Though not sure where it jumps too in that case. But at least it auto-completes them.