reddit / emacs

xref-find-definitions stopped working, how can I diagnose?

hairlesscaveman · 2022-07-26 07:53
Hey all! So, around 3 months ago I upgraded to emacs 29 and set up a "fresh" init.el; lots of copy/paste from my old config with an eye to using less "custom" features/keybindings and using "modern" tooling like `embark` and `consult`. I mostly develop in Elixir, so configured `lsp` with `elixir-mode` and found that `xref-find-definitions` triggered from the `embark` menu was working great and a real time saver. A couple of weeks ago, `xref-find-definitions` stopped working. I don't _think_ I changed anything in my init.el, at least not related to lsp-mode or elixir-mode and definitely nothing related to xref. Now I always get `No definitions found` in the minibuffer whenever I call `xref-find-definitions` (either via `C-. RET` or `M-.`) even for items I _know_ worked a few weeks ago. I've switched to using `dump-jump` in the meantime which is a great package but isn't as well integrated into `embark`. Can anyone point me in the right direction for diagnosing this issue? ## Solution: Turns out `consult-lsp` was the culprit. Removing it from my config got `xref-find-definitions` working again as expected. It would be nice to have `consult-lsp` working, but I can live without it as long as I can jump to definitions quickly.
big_lentil · 2022-07-26 11:20
You should probably check whether xref works in other contexts or not. E.g. in the scratch buffer, does M-. on (xref-find-definitions) (has to be in parentheses) take you to xref.el? If it does I'd start suspecting the language server.
dharris · 2022-07-26 12:26
Not an answer but I’ve been meaning to research this as well. I use `dumb-jump` and whenever I restart emacs, I get the reminder that it’s obsolete. I’ve tried `xref-find-definitions` but it just hasn’t worked for me.
kundry_wag · 2022-07-26 15:06
You can try to bisect your config. For example, try to start Emacs with only the LSP related packages and use `xref-find-definitions`. If it doesn't work for LSP for it works elsewhere (eg. for Emacs Lisp), you could try to view the LSP server logs.
hvis · 2022-07-26 23:18
Whether it works, and how well, usually depends on the backend that plugs into it. And that one is defined either by the major mode (file type), or by an additional package like `eglot` or `lsp-mode`, if you are using a language server to get more accurate completions and navigation.
hairlesscaveman · 2022-07-27 07:27
> does `M-.` on `(xref-find-definitions)` take you to xref.el? Interestingly, no! It takes me to the first line in my `init.el` file. I'm therefore that I've done something to override the way xref works… no idea what though. I'll search through for any xref-related instructions and comment them out.
hairlesscaveman · 2022-07-28 15:22
Solution added above. Thanks /u/big_lentil for your assistance!