latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.51k stars 52 forks source link

Go To Definition does not work for macros defined in packages #855

Open real-or-random opened 1 year ago

real-or-random commented 1 year ago

When I want to look up definitions for macros defined in packages (e.g., \addbibresource in biblatex.sty, or \tnorm in cryptocode.sty), this doesn't work. The lsp-io-logs show that the server returns an empty result. But jumping to definitions works fine for macros that I define in my own tex files.

First of all, is this supposed to work? If yes, how can I get this working or debug this?

I'm using TeXLive 2022 on Arch Linux, lsp-mode in emacs, and texlab 5.2.0.

Thanks for this great server, by the way.

pfoerster commented 1 year ago

First of all, is this supposed to work?

No, not really at the moment. The feature is currently limited to the source code of the document and custom/local packages that are not directly part of the TeX distro. To provide auto completion for commands, texlab uses a precomputed list (latex-completion-data) but this file does not include the positions in the source file (and in fact, we do not know where how exactly it is defined).

Our approach to identifying command definitions in the server is very limited. Applying the same logic to packages requires a macro expansion engine.

Thanks for this great server, by the way.

Thanks for the kind words :)

real-or-random commented 1 year ago

Oh, I see. I noticed that it's supported for local packages, and then I assumed that it's also supported for distro packages. It may be a good idea to document this somewhere.