joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.27k stars 200 forks source link

Display contact description in on-connection message #465

Open dandavison opened 4 years ago

dandavison commented 4 years ago

When connecting, I would like eglot to display a message like this:

Connected! `rust-analyzer' Server `EGLOT (delta/rust-mode)' now managing `rust-mode' buffers in project `delta'.

Currently, the message does not display the rust-analyzer part.

In fact, personally, I would be happy with

Connected! `rust-analyzer' server now managing `rust-mode' buffers in project `delta'.

but I'm not that experienced with the project and I may not be appreciating the utility in that extra component.

If you are sympathetic to this suggestion, I can work on it. The implementation could perhaps involve a new function named something like eglot-format-contact or eglot-contact-readable-name. That could perhaps be used here:

(readable-name (format "EGLOT (%s/%s)" nickname managed-major-mode))

as long as you are happy including the new info in the process name. Alternatively it could simply be used here:

(eglot--message "Connected! %sServer `%s' now managing `%s' buffers in project `%s'." ... )
nemethf commented 4 years ago

Eglot displays the following:

Connected! Server `ccls' now managing `c++-mode' buffers in project `test-ccls'.

Because ccls sends serverInfo of the LSP v3.15.0. If rust-analyzer adds support for serverInfo, Eglot will automatically something similar for rust as well.

dandavison commented 4 years ago

@nemethf Thanks! I did see (plist-get serverInfo :name) in the code but wasn't sure how often we should expect it.

OK, so from a quick search it looks like serverInfo was added in protocol version 3.15, released in January.

I'm using eglot for python and rust, and it appears that pyls also doesn't support serverInfo currently. I see no code or issue hits when searching their repo for that term, and eglot is also not displaying the contact type:

Connected! Server `EGLOT (compilers/python-mode)' now managing `python-mode' buffers in project `compilers'.

So I think there are at least two questions:

  1. Is the length of time it's going to take server implementations to support serverInfo sufficiently long that it would make sense for eglot to fall back to showing the information itself for now?

  2. When the user is using, for example, (host, port) I can see value in displaying that info in the connection message (so the general concept would be "format the elisp contact object as a human-readable string"). So should eglot do that?

nemethf commented 4 years ago

It seems rust-analyzer now sends the serverInfo.

If you are interested in receiving the serverInfo from pyls, you should at least open an issue at its project page. But I found that project was not very responsive. But it's worth a try.

skangas commented 2 years ago
  1. Is the length of time it's going to take server implementations to support serverInfo sufficiently long that it would make sense for eglot to fall back to showing the information itself for now?

I tend to think that it is not worth working on this: we show the serverInfo if it is available, and if not, the server should be fixed. For debugging needs, that should be fixed by #476. However, if someone wants this and sends a PR, I don't see any reason why we can't accept it, if it is done cleanly.

  1. When the user is using, for example, (host, port) I can see value in displaying that info in the connection message (so the general concept would be "format the elisp contact object as a human-readable string"). So should eglot do that?

I can see value in displaying this information, I think. Should it be displayed both in a message and in the events buffer, perhaps?