0

I'm using company-mode with lsp-mode as lsp client and gopls as lsp backend in order to lookup function and variable definitions in go projects.

On some repositories, when I want to lookup a definition (M-.) I get an unexpected:

 "Visit tags table (default TAGS):..." 

...instead of jumping to the function definition.

For instance: enter image description here

How can I fix this? Thanks!

12
  • What command is M-. bound to? C-h k M-. will tell you.
    – db48x
    Sep 29, 2021 at 16:35
  • @db48x Here it is: M-. runs the command xref-find-definitions (found in global-map), which is an autoloaded interactive compiled Lisp function in ‘xref.el’. It is bound to M-., <menu-bar> <edit> <goto> <xref-find-def>. (xref-find-definitions IDENTIFIER) Probably introduced at or before Emacs version 25.1. Find the definition of the identifier at point. With prefix argument or when there’s no identifier at point, prompt for it. Sep 29, 2021 at 21:52
  • I found the key binding online when installing lsp-mode and it was of course way more practical than typing M-x lsp-find-definition, which in this case yields a similar error: "The connected server does not support method testDocument/definition. To find out what capabilities support your server use M-x lsp-describe-session and exand the capabilities section." Sep 29, 2021 at 21:54
  • The result of M-x lsp-describe-session is in here: pastebin.com/4d30E6Gw I do not know how to interpret it... Sep 29, 2021 at 21:56
  • 1
    Sounds like a problem with how the LSP server is started. You should post that as an answer to your own question, but you might also look into changing how lsp-mode starts the lsp server; perhaps it could determine the correct directory to start it in automatically. Or perhaps setting lsp-auto-guess-root would work: emacs-lsp.github.io/lsp-mode/page/settings/mode/…
    – db48x
    Sep 29, 2021 at 23:18

1 Answer 1

1

As mentioned in the comments, a workaround for this issue is to start emacs on a folder (or on nothing) instead of on a single source file. This was discussed for VScode with gopls as backend here: https://stackoverflow.com/a/49977881/497180

Your Answer

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

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