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

Finer-grained hover cache #3589

Open Kha opened 2 years ago

Kha commented 2 years ago

I have a language server (https://github.com/leanprover/lean4) that uses Hover.range? to highlight term structure, e.g. hovering over + in a + b highlights the entire term. While this works well in VS Code, in lsp-mode this unfortunately means that moving the cursor over a will not refresh eldoc since the range of the previous hover (lsp--hover-saved-bounds) has not been left. Could there be an option for finer grained caching of hover requests or at least a flag to disable it, somewhat like lsp-ui-sideline-update-mode?

yyoncho commented 2 years ago

I wish we don't need that (e. g. there is no point for the server to send range if it is sending overlapping ranges) but you may open a pr to add a flag.

Kha commented 2 years ago

Yeah, I was wondering if our language server was going against the spec while filing this issue! But it only says "is used to visualize a hover, e.g. by changing the background color", there is no mention that it should correspond to the points where the hover is activated. I'll see when I get around to filing a PR, thanks!

yyoncho commented 2 years ago

I see - then we should drop the caching at all client-side. This piece of the protocol was misinterpreted.

Kha commented 2 years ago

From a quick glance at VS Code, it looks like the hover is cached there at least inside a "word". That's not supported by the spec either, but probably harmless and may make for a smoother experience while sweeping the cursor over an identifier. Which OTOH might not be as important for Emacs users if they mostly navigate word-size, e.g. via M-f/b.

yyoncho commented 2 years ago

We should at least test - because blinking is also something that we want to avoid.