0

I installed lsp-mode and using pyright as its server. However, most of the lsp function wouldn't work. For example, If I do M-x lsp-find-definition, it'll return error message "Symbol's value as variable is void: xref-auto-jump-to-first-definition".

Does anyone have this issue before? I've re-install my lsp-mode a couple of times but it wouldn't work.

4
  • Of coarse, Emacs version is important, but also did you installed the package lsp-pyright?
    – Ian
    Sep 18, 2023 at 7:17
  • @lan, Yes, I think I did. I have use-package lsp-pyright in my config file and in the Message buffer it also says pyright is initialized in the folder. I couldn't find lsp-pyright in the M-x though.
    – ymu_quant
    Sep 19, 2023 at 5:44
  • May depend on your configuration - try M-x lsp to start lsp server working, or add a hook to your configuration: (add-hook 'python-mode-hook #'lsp-deferred) to start automatically.
    – Ian
    Sep 19, 2023 at 11:47
  • My lsp-mode starts automatically.
    – ymu_quant
    Sep 21, 2023 at 2:30

1 Answer 1

1
xref-auto-jump-to-first-definition is a variable defined in ‘xref.el’.
  ...
  This variable was introduced, or its default value was changed, in
  version 28.1 of Emacs.

Are you using Emacs 27 or earlier?

I can see an upstream bug report for this at https://github.com/emacs-lsp/lsp-mode/issues/4063 which indicates that if you install a newer xref from GNU ELPA (as opposed to the version included as standard in Emacs 27) then this problem might go away.

(If you subsequently upgrade to a more-recent version of Emacs you might want to revert back to the in-built xref.)

10
  • Yes, I am using Emacs 27, which probably causes this issue. But is there any way to use lsp-mode functions within Emacs 27?
    – ymu_quant
    Sep 19, 2023 at 5:33
  • I couldn't even find the 'xref.el'. Is it in the ~/.emacs/elpa folder? @phils
    – ymu_quant
    Sep 19, 2023 at 5:50
  • Xref is part of Emacs since 25.1. M-x find-library
    – phils
    Sep 19, 2023 at 6:39
  • I can see that lsp-mode means to support 27.1 and higher, so raise a bug report with them so that they can add some backwards compatibility for this issue.
    – phils
    Sep 19, 2023 at 6:53
  • Interesting, I didn't know that I could find xref from M-x. Not sure if I can revise the codes to solve this issue.
    – ymu_quant
    Sep 20, 2023 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.