rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.11k stars 179 forks source link

Feature Request: Support for flymake #484

Closed jgarte closed 7 months ago

jgarte commented 1 year ago

Hi, does rust-mode support using flymake instead of flycheck?

brotzeit commented 1 year ago

rust-mode doesn't contain any flycheck related code. We only added a link to make it easier for users. I actually don't know if flymake supports rust but I would be surprised if it doesn't. It's intended to be used with eglot so I'm sure it works at least with lsp(eglot).

jgarte commented 1 year ago

When I turn on flymake-mode with eglot and rust-analyzer I don't get any clippy/linter warnings. Completions work though for me.

I tried the functions in rust-mode that relate to running clippy and those do work but they are manual and don't pass through flymake-mode from what I experienced.

brotzeit commented 1 year ago

I don't use eglot so I'm not sure what's necessary to get it working. You have to change the command from check to clippy. This is from the rust-analyzer package.json:

                "rust-analyzer.checkOnSave.command": {
                    "markdownDescription": "Cargo command to use for `cargo check`.",
                    "default": "check",
                    "type": "string"
                },

Maybe ask on the doom discord channel, I think there are plenty eglot users. Sorry but this is not related to rust-mode or rustic.

brotzeit commented 1 year ago

If you find a solution it would be great if we could also add it to the rust-mode repo. I'm sure there are others with the same issue.

psibi commented 1 year ago

I was able to get flymake working with rust-mode and lsp-mode. Since I had flycheck installed, I had to do this:

(use-package lsp-mode
  :ensure t
  :init (setq lsp-keymap-prefix "C-l")
  :commands lsp
  :hook ((lsp-mode . lsp-enable-which-key-integration)
         (lsp-configure . lsp-lens-mode))
  :custom
  (lsp-diagnostics-provider :flymake))

And then for the rust-mode, this was the configuration:

(use-package rust-mode
  :ensure t
  :after (lsp-mode)
  :hook ((rust-mode . lsp-deferred)))

I could confirm that the error that was show in the flymake diagnostic buffer was the same one which was shown in flycheck. (Although I did get less information in flymake like there was no Rust error code visible in the flymake one etc).

brotzeit commented 1 year ago

I didn't realize flymake support was merged :+1:

psibi commented 7 months ago

Closing this since nothing needs to be done at rust-mode for this.