emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.79k stars 890 forks source link

Faster xref handling over tramp #2945

Open muirdm opened 3 years ago

muirdm commented 3 years ago

Currently lsp--locations-to-xref-items opens all locations to give the user a preview of the matching line contents. This is useful, but very slow over tramp when there are many locations.

I propose we add an option to disable this behavior when the file is remote. In other words, if the location file is remote, only include the file's name in the xref item.

muirdm commented 3 years ago

Similarly, if there is only a single location and we are going to jump straight there (e.g. xref-find-definition), there is no need in any case to generate the line preview.

yyoncho commented 3 years ago

We can add a flag for that for now as a workarround. Btw have you tried the lsp-treemacs- versions of these? they should work faster.

IMHO xref should be changed to allow having this one calculated lazily. This will solve the issue with the ivy/helm/etc xref frontends.

muirdm commented 3 years ago

have you tried the lsp-treemacs- versions of these?

I don't use treemacs normally. I just tried lsp-treemacs-references and it took ~20s to display results for something with 1500 references. xref-find-references with my patch to not generate preview loads in ~1 second. Also note that clicking/entering on the treemacs entries didn't seem to pull up the file.

xref should be changed to allow having this one calculated lazily

Definitely. That would be great (as long as the preview loaded asynchronously).

Could lsp-mode also be optimized somehow to generate the preview remotely, and/or generate them concurrently?

yyoncho commented 3 years ago

Could lsp-mode also be optimized somehow to generate the preview remotely, and/or generate them concurrently?

There is no async IO in emacs(And I am consistently told that I don't need it)... Generally, we can run some external process like sed to get that data but this will be painfull to maintain.