Stream: t-compiler/wg-rls-2.0

Topic: emacs / lsp compatibility


Andreas Fuchs (Feb 15 2019 at 23:24, on Zulip):

I just tried connecting the current HEAD of rust-analyzer to emacs's lsp-mode and it kinda works! All that's required is to put in this definition:

(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection '("ra_lsp_server"))
                  :major-modes '(rust-mode rustic-mode)
                  :priority 99
                  :server-id 'ra_lsp_server
                  :notification-handlers (lsp-ht ("window/progress" 'lsp-clients--rust-window-progress))))

and you get just about all the features that rust-analyzer's LSP server can deliver. Unfortunately, lsp-ui mode doesn't look pretty with it, mostly because symbol resolution isn't working well yet (most symbols/types/traits from other packages get a "not implemented" message). However, some code completion via company-mode, the documentation popup and go-to-definition do work!

Andreas Fuchs (Feb 15 2019 at 23:25, on Zulip):

Note the :priority 99 there - that instructs LSP to prefer ra_lsp_server to the built-in rls definition.

Florian Diebold (Feb 16 2019 at 00:07, on Zulip):

I've been using RA with emacs the whole time, actually :) I've got some code to handle rust-analyzer.applySourceChange as well, so code actions etc. work, but there's a lot missing still...

Andreas Fuchs (Feb 16 2019 at 00:49, on Zulip):

Whoa, I'd love to see that code action change - I'd been trying them and only getting errors about unsupported commands (:

Laurențiu Nicola (Feb 16 2019 at 07:13, on Zulip):

Speaking of LSP clients, I've found one that didn't send the initialized notification, making rust-analyzer panic. I wouldn't be surprised if other clients did the same. Maybe we should have a debugging option to trace the client-server communication?

matklad (Feb 16 2019 at 09:48, on Zulip):

I just tried connecting the current HEAD of rust-analyzer to emacs's lsp-mode and it kinda works! All that's required is to put in this definition:

I've got some code to handle rust-analyzer.applySourceChange as well, so code actions etc.

There's editors/emacs folder in the repo ;) Would be cool to have these things there.

matklad (Feb 16 2019 at 09:49, on Zulip):

I've found one that didn't send the initialized notification, making rust-analyzer panic.

Yeah, that's a common violation of the speck in the clients. I've personally fixed eglot and kak-lsp =)

Maybe we should have a debugging option to trace the client-server communication?

export RUST_LOG=gen_lsp_server=debug

Laurențiu Nicola (Feb 16 2019 at 10:06, on Zulip):

oh, right (:

Florian Diebold (Feb 16 2019 at 11:28, on Zulip):

Whoa, I'd love to see that code action change - I'd been trying them and only getting errors about unsupported commands (:

https://github.com/flodiebold/lsp-rust/blob/ra/lsp-rust.el#L169-L193

Florian Diebold (Feb 16 2019 at 14:28, on Zulip):

@Andreas Fuchs I've cleaned up and extended my code a bit: https://github.com/rust-analyzer/rust-analyzer/pull/841

Andreas Fuchs (Feb 17 2019 at 18:16, on Zulip):

this is wonderful! Thanks for PR'ing it!

Last update: Nov 12 2019 at 15:35UTC