Skip to content

Commit 8ee2179

Browse files
committed
Per #803: Change Rust language server to rust-analyzer
rust-analyzer is the officially blessed Language Server for Rust: rust-lang/rfcs#2912 Also drop the special support code for RLS. * eglot.el (eglot-server-programs): Add rust-mode language server "rust-analyzer" and prefer it to the older "rls". (eglot-rls, jsonrpc-connection-ready-p) (eglot-handle-notification): Delete special support for "rls". * eglot-tests.el (rls-analyzer-watches-files) (rls-analyzer-hover-after-edit): Rename to ... (rust-analyzer-watches-files) (rust-analyzer-hover-after-edit): ... this. Update tests to work with rust-analyzer. * README.md: Update references for RLS to point to rust-analyzer. * NEWS.md: Announce above change.
1 parent e5cea1f commit 8ee2179

File tree

4 files changed

+15
-29
lines changed

4 files changed

+15
-29
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ unnecessary code" or "deprecated or obsolete code". Following the
66
rendering suggestions in the protocol, we fade out unnecessary code
77
and strike-through deprecated code.
88

9+
##### The Rust language server is now rust-analyzer by default ([#803][github#803])
10+
Eglot will now prefer starting "rust-analazyer" to "rls" when it is
11+
available. The special support code for RLS has been removed.
12+
913
##### New servers have been added to `eglot-server-programs`
1014
- racket-langserver ([#694][github#694])
1115

@@ -327,3 +331,4 @@ and now said bunch of references-->
327331
[github#769]: https://github.com/joaotavora/eglot/issues/769
328332
[github#787]: https://github.com/joaotavora/eglot/issues/787
329333
[github#794]: https://github.com/joaotavora/eglot/issues/794
334+
[github#803]: https://github.com/joaotavora/eglot/issues/803

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ find-library` can help you tell if that happened.
6767
* R's [languageserver][r-languageserver]
6868
* Racket's [racket-langserver][racket-langserver]
6969
* Ruby's [solargraph][solargraph]
70-
* Rust's [rls][rls]
70+
* Rust's [rust-analyzer][rust-analyzer]
7171
* Scala's [metals][metals]
7272
* TeX/LaTeX's [Digestif][digestif]
7373
* VimScript's [vim-language-server][vim-language-server]
@@ -467,7 +467,7 @@ User-visible differences:
467467
connection name;
468468
- Pretty interactive mode-line section for live tracking of server
469469
communication;
470-
- Automatically restarts frequently crashing servers (like RLS);
470+
- Automatically restarts frequently crashing servers;
471471
- Slow-to-start servers start asynchronously in the background;
472472
- Server-initiated edits are confirmed with the user;
473473
- Diagnostics work out-of-the-box (no `flycheck.el` needed);
@@ -517,7 +517,7 @@ Under the hood:
517517
[r-languageserver]: https://cran.r-project.org/package=languageserver
518518
[racket-langserver]: https://github.com/jeapostrophe/racket-langserver
519519
[solargraph]: https://github.com/castwide/solargraph
520-
[rls]: https://github.com/rust-lang-nursery/rls
520+
[rust-analyzer]: https://github.com/rust-analyzer/rust-analyzer
521521
[metals]: https://scalameta.org/metals/
522522
[digestif]: https://github.com/astoff/digestif
523523
[vim-language-server]: https://github.com/iamcco/vim-language-server

eglot-tests.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ Pass TIMEOUT to `eglot--with-timeout'."
371371
(while (process-live-p proc) (accept-process-output nil 0.5)))
372372
(should (not (eglot-current-server)))))))
373373

374-
(ert-deftest rls-watches-files ()
375-
"Start RLS server. Notify it when a critical file changes."
376-
(skip-unless (executable-find "rls"))
374+
(ert-deftest rust-analyzer-watches-files ()
375+
"Start rust-analyzer. Notify it when a critical file changes."
376+
(skip-unless (executable-find "rust-analyzer"))
377377
(skip-unless (executable-find "cargo"))
378378
(let ((eglot-autoreconnect 1))
379379
(eglot--with-fixture
@@ -467,9 +467,9 @@ Pass TIMEOUT to `eglot--with-timeout'."
467467
do (sit-for 0.5)
468468
finally (error "eglot--tests-force-full-eldoc didn't deliver")))
469469

470-
(ert-deftest rls-hover-after-edit ()
471-
"Hover and highlightChanges are tricky in RLS."
472-
(skip-unless (executable-find "rls"))
470+
(ert-deftest rust-analyzer-hover-after-edit ()
471+
"Hover and highlightChanges."
472+
(skip-unless (executable-find "rust-analyzer"))
473473
(skip-unless (executable-find "cargo"))
474474
(eglot--with-fixture
475475
'(("hover-project" .

eglot.el

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ chosen (interactively or automatically)."
142142
when probe return (cons probe args)
143143
finally (funcall err)))))))
144144

145-
(defvar eglot-server-programs `((rust-mode . (eglot-rls "rls"))
145+
(defvar eglot-server-programs `((rust-mode . ("rust-analyzer" "rls"))
146146
(cmake-mode . ("cmake-language-server"))
147147
(vimrc-mode . ("vim-language-server" "--stdio"))
148148
(python-mode
@@ -2984,25 +2984,6 @@ If NOERROR, return predicate, else erroring function."
29842984
(when (eq ?! (aref arg 1)) (aset arg 1 ?^))
29852985
`(,self () (re-search-forward ,(concat "\\=" arg)) (,next)))
29862986

2987-
2988-
;;; Rust-specific
2989-
;;;
2990-
(defclass eglot-rls (eglot-lsp-server) () :documentation "Rustlang's RLS.")
2991-
2992-
(cl-defmethod jsonrpc-connection-ready-p ((server eglot-rls) what)
2993-
"Except for :completion, RLS isn't ready until Indexing done."
2994-
(and (cl-call-next-method)
2995-
(or ;; RLS normally ready for this, even if building.
2996-
(eq :textDocument/completion what)
2997-
(pcase-let ((`(,_id ,what ,done ,_detail) (eglot--spinner server)))
2998-
(and (equal "Indexing" what) done)))))
2999-
3000-
(cl-defmethod eglot-handle-notification
3001-
((server eglot-rls) (_method (eql window/progress))
3002-
&key id done title message &allow-other-keys)
3003-
"Handle notification window/progress."
3004-
(setf (eglot--spinner server) (list id title done message)))
3005-
30062987

30072988
;;; eclipse-jdt-specific
30082989
;;;

0 commit comments

Comments
 (0)