Skip to content

Commit

Permalink
Per joaotavora/eglot#803: Change Rust language server to rust-analyzer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skangas committed Jan 17, 2022
1 parent 18ab123 commit f0d4376
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ chosen (interactively or automatically)."
when probe return (cons probe args)
finally (funcall err)))))))

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


;;; Rust-specific
;;;
(defclass eglot-rls (eglot-lsp-server) () :documentation "Rustlang's RLS.")

(cl-defmethod jsonrpc-connection-ready-p ((server eglot-rls) what)
"Except for :completion, RLS isn't ready until Indexing done."
(and (cl-call-next-method)
(or ;; RLS normally ready for this, even if building.
(eq :textDocument/completion what)
(pcase-let ((`(,_id ,what ,done ,_detail) (eglot--spinner server)))
(and (equal "Indexing" what) done)))))

(cl-defmethod eglot-handle-notification
((server eglot-rls) (_method (eql window/progress))
&key id done title message &allow-other-keys)
"Handle notification window/progress."
(setf (eglot--spinner server) (list id title done message)))


;;; eclipse-jdt-specific
;;;
Expand Down

0 comments on commit f0d4376

Please sign in to comment.