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..)
one feature clojure-lsp supports that CIDER does not (AFAIK) is finding references of local bindings
are their any instances where cider find ref or goto def does something lsp wont do? like because cider is using the runtime info?
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 usedThanks, yeah, i had seen that, wasn't sure i understood the full impact of the last bit.
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
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?
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
I've set up "goto" as first try clojure-lsp and if it doesn't find any, use CIDER
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
I think lsp will fail if the code is malformed. Cider will still refer to the last properly formed loaded ref.
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.
Kondo had some fixes about incomplete forms, so perhaps it should work now. If not you may file an issue
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.
Thanks for the replies everyone. it really helps 🙏
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.
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).
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.)
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.