Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOWTO] rust-analyzer not working #2195

Closed
Mr-1311 opened this issue Dec 15, 2019 · 8 comments
Closed

[HOWTO] rust-analyzer not working #2195

Mr-1311 opened this issue Dec 15, 2019 · 8 comments
Labels
is:support A request for user support: questions, how-to's, and discussions module:lang/rust Pertains to Doom's :lang rust module module:tools/lsp Pertains to Doom's :tools lsp module status:resolved Issue was addressed internally

Comments

@Mr-1311
Copy link

Mr-1311 commented Dec 15, 2019

I am trying to install the rust-analyzer
I'm trying to install rust-analyzer but when I'm open rust buffer this message writes on bottom.
Server rls:20735 status:starting exited with status exit. Do you want to restart it? (y or n)
if I press y the number(20735) increase 1, every time. Also, the number(20735) different every time I open rust buffer.

I have done so far

  • I uncomment lsp on .doom.d/init.el
  • add +lsp to rust on .doom.d/init.el
  • cloned the rust-analyzer repo and installed
    git clone https://github.com/rust-analyzer/rust-analyzer && cd rust-analyzer
    cargo xtask install --server
    
  • installed these components
    • rustfmt-preview
    • cargo-check
    • clippy-preview
    • rust-src
  • and added these line to .doom.d/config.el
    (after! rustic
      (setq rustic-lsp-server 'rust-analyzer))
    

Additional information
ra_lsp_server on my path but when I run ra_lsp_server on my shell it's write to output nothing,
so I'm not sure that if it installed correctly or not.

System information

((emacs
  (version . "26.3")
  (features . "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD LCMS2")
  (build . "Aug 29, 2019")
  (buildopts "--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now")
  (windowsys . batch)
  (daemonp . server-running))
 (doom
  (version . "2.0.9")
  (build . "HEAD -> develop 721b63547 2019-12-15 02:17:40 -0500"))
 (system
  (type . gnu/linux)
  (config . "x86_64-pc-linux-gnu")
  (shell . "/usr/bin/zsh")
  (uname . "Linux 5.4.3-arch1-1 #1 SMP PREEMPT Fri, 13 Dec 2019 09:39:02 +0000 x86_64")
  (path "~/.cargo/bin" "/usr/local/bin" "/usr/bin" "/bin" "/usr/local/sbin" "/usr/bin/site_perl" "/usr/bin/vendor_perl" "/usr/bin/core_perl" "/usr/lib/emacs/26.3/x86_64-pc-linux-gnu"))
 (config
  (envfile . envvar-file)
  (elc-files . 0)
  (modules :completion company ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash ophints (popup +all +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text snippets :emacs dired electric ibuffer vc :tools (eval +overlay) flycheck (lookup +docsets) lsp magit :lang data emacs-lisp markdown (org +dragndrop +ipython +pandoc +present) (rust +lsp) sh :config (default +bindings +smartparens))
  (packages "n/a")
  (elpa "n/a")))

@Mr-1311 Mr-1311 added the is:support A request for user support: questions, how-to's, and discussions label Dec 15, 2019
@hlissner hlissner added module:lang/rust Pertains to Doom's :lang rust module module:tools/lsp Pertains to Doom's :tools lsp module help wanted Cannot be resolved without outside help labels Dec 15, 2019
@Mr-1311
Copy link
Author

Mr-1311 commented Dec 15, 2019

I just installed rls using rustup component add rls command and now completion is working but I guess it's not using rust-analyzer but rls even (setq rustic-lsp-server 'rust-analyzer)) in my config.el . How can I be sure which one is in use, rls or rust analyzer.

hlissner added a commit that referenced this issue Dec 16, 2019
lsp-rust is supposedly superior, and doesn't assume anything about our
package management system like rustic does.

Relevant to #2195
@hlissner
Copy link
Member

hlissner commented Dec 16, 2019

Use this instead:

(after! lsp-rust
  (setq lsp-rust-server 'rust-analyzer))

Doom now uses the lsp support built into lsp-mode, not the one built into rustic. I've just updated the README to reflect this.

@Mr-1311
Copy link
Author

Mr-1311 commented Dec 18, 2019

Tried this

(after! lsp-rust
  (setq lsp-rust-server 'rust-analyzer))

but still when I open rust buffer this: LSP :: rls:2915 initialized successfullywrites at bottom. and M-x lsp-rust-analyzer-status says rust-analyzer not running

when I run ra_lsp_server --version on shell, it prints this: rust-analyzer ff8f805
I guess rust analyzer installed correctly but emacs not using it.

On this page it says emacs need dash and ht package and load this file. Should I do this by myself or doom emacs did it already for me?

@hlissner
Copy link
Member

You don't need to install it's dependencies, no. Try this instead:

(setq lsp-rust-server 'rust-analyzer)

@Mr-1311
Copy link
Author

Mr-1311 commented Dec 18, 2019

Yes, this:

(setq lsp-rust-server 'rust-analyzer)

or this:

(after! rustic
  (setq lsp-rust-server 'rust-analyzer))

solve the problem, now emacs use rust analyzer instead of rls. Thank you.

@Mr-1311 Mr-1311 closed this as completed Dec 18, 2019
@brotzeit
Copy link
Contributor

brotzeit commented Dec 21, 2019

I kept rustic-lsp-server because it is supposed to also work with eglot. Maybe this should also be mentioned for eglot users.

@hlissner
Copy link
Member

@brotzeit Done.

@hlissner hlissner added the status:resolved Issue was addressed internally label Dec 21, 2019
@hlissner hlissner removed the help wanted Cannot be resolved without outside help label Feb 29, 2020
@nhaas
Copy link

nhaas commented Apr 5, 2020

FYI, I recently had trouble getting rust-analyzer to work and the OPs steps helped me out. The problem I ran into though was that lsp-rust-server was being overwritten and I couldn't debug where that was happening.
That is, with (setq lsp-rust-server 'rust-analyzer) I would see lsp-rust-server == rust-analyer on startup (emacs &). However, after opening a Rust buffer, it would be changed to lsp-rust-server == rls.
In the end, I found that (setq rustic-lsp-server 'rust-analyzer) ;; $DOOMDIR/config.el would connect to rust-analyzer for all Rustic buffers.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
is:support A request for user support: questions, how-to's, and discussions module:lang/rust Pertains to Doom's :lang rust module module:tools/lsp Pertains to Doom's :tools lsp module status:resolved Issue was addressed internally
Projects
None yet
Development

No branches or pull requests

4 participants