reddit / emacs

Rustic + eglot - unable to get code completion working

fast-90 · 2022-08-04 06:56
# Update Never mind, it works if I try it on a new project created via \`cargo new\`. Probably shouldn't have tested it on the \`rustlings\` exercises :'). Still just in the beginning of my rust journey so wasn't clear when I could expect the completion to work (I presume it has to do with the \`toml\` file and the project structure, but happy to be corrected). Leaving my original post here though in case someone else faces the same "issue" as me in the future. # Original post I am just starting to learn rust, and want to use eglot as my LSP client (as I am also using it for other languages). I am unable to get code completion and some other LSP features working. I have tried it with both `lsp-mode` and `eglot` and `corfu` and `company`, so I'm not sure which part of my config is causing the issue (and therefore on which repo I should raise an issue). Maybe it is something with my rust/cargo setup? I do have rust-analyzer installed via its repo though... Any help is appreciated! # My setup (use-package eglot :ensure t :defer t :hook (python-mode-hook . eglot-ensure)) (use-package rustic :ensure t :config (setq rustic-format-on-save t) (setq rustic-lsp-client 'eglot)) (use-package corfu :ensure t :bind (:map corfu-map ("C-j" . corfu-next) ("C-k" . corfu-previous) ("TAB" . corfu-insert) ("RET" . nil)) :custom (corfu-cycle t) (corfu-auto t) :init (global-corfu-mode) (global-set-key (kbd "M-i") #'completion-at-point)) # Issues Syntax checking works: https://preview.redd.it/p7av9g5aanf91.png?width=937&format=png&auto=webp&s=d16ff9dcc66fdf0bd9a03ea73333f46662d72cc9 However code completion does not work (`corfu-mode` is on). Manually invoking `completion-at-point` returns "No match". In addition, it also does not seem to check for existing modules: https://preview.redd.it/p4t2fvmbanf91.png?width=937&format=png&auto=webp&s=ac580f497fd7f9d34649ba29976187c969579a36 I would expect it to raise an error here as `ioo` does not exist? # What I have tried * Trying to use `company` instead of `corfu`. Same issues as above (both are working well for Python though). * Followed [this guide](https://www.bytedude.com/setting-up-rust-support-in-emacs/) which uses a similar setup. * Tried an alternative setup with `lsp-mode` via [this guide](https://robert.kra.hn/posts/rust-emacs-setup/) \- still same issues. * Trying a minimum config with `emacs -Q`.
hkjels · 2022-08-04 08:56
I’m not near my computer right now, but I think maybe rustic can be replaced with rust-mode now
yyoncho · 2022-08-04 10:20
AFAIK rust-analyzer does not support rustlings
fast-90 · 2022-08-04 11:05
This explains it then :) Thanks for confirming!
PhantomSeahorse · 2022-08-04 14:06
How so?