summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelicián Németh <felician.nemeth@gmail.com>2022-12-19 13:09:36 +0100
committerFelicián Németh <felician.nemeth@gmail.com>2022-12-19 13:09:36 +0100
commite25b7525469564b2a5c41cc2fff2de0480571eb8 (patch)
tree382321577b8d036942bb9f5c5d5ebfd3c8183d6f
parentdba0000be43badf77c09047d9f325b96e71e3061 (diff)
Add flycheck commands (rust-analyzer)
* eglot-x.el (eglot-x-menu): Add a flycheck submenu. (eglot-x-run-flycheck,eglot-x-clear-flycheck,eglot-x-cancel-flycheck): New defuns. * README.md: Document changes.
-rw-r--r--README.md3
-rw-r--r--eglot-x.el29
2 files changed, 32 insertions, 0 deletions
diff --git a/README.md b/README.md
index b9a09e8..33c650c 100644
--- a/README.md
+++ b/README.md
@@ -118,6 +118,8 @@ positions.
- [Expand Macro]: see defun `eglot-x-expand-macro`.
- [Related Tests]: see defun `eglot-x-ask-related-tests`.
- [Reload Workspace]: see defun `eglot-x-reload-workspace`.
+- [Flycheck commands]: see defuns `eglot-x-run-flycheck`, `eglot-x-clear-flycheck`,
+ and `eglot-x-cancel-flycheck`.
- [View Crate Graph]: see variable `eglot-x-graph-type` and defun `eglot-x-view-crate-graph`.
![crate-graph](https://raw.githubusercontent.com/wiki/nemethf/eglot-x/view-crate-graph.png)
@@ -165,6 +167,7 @@ See the documentation of `eglot-x-enable-ff-related-file-integration`.
[Open External Documentation]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#open-external-documentation
[Related Tests]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#related-tests
[Reload Workspace]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#reload-workspace
+[Flycheck commands]: https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#controlling-flycheck
[Runnables]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#runnables
[Server Status]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#server-status
[Snippet TextEdits]: https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#snippet-textedit
diff --git a/eglot-x.el b/eglot-x.el
index 0da74f9..d92ef92 100644
--- a/eglot-x.el
+++ b/eglot-x.el
@@ -207,6 +207,10 @@ manages .toml files, or (ii) the rust-analyzer LSP server manages
["Ask related tests" eglot-x-ask-related-tests]
["Find workspace symbol" eglot-x-find-workspace-symbol]
["Expand macro" eglot-x-expand-macro]
+ ("Flycheck"
+ ["Run flycheck" eglot-x-run-flycheck]
+ ["Clear flycheck" eglot-x-clear-flycheck]
+ ["Cancel flycheck" eglot-x-cancel-flycheck])
["View crate graph" eglot-x-view-crate-graph]
"--"
["Reload workspace" eglot-x-reload-workspace]
@@ -1089,6 +1093,31 @@ For debugging purposes."
;;(eglot--managed-mode)
(view-mode)))
+;;; rust-analyzer: Controlling Flycheck
+;;
+;; https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.md#controlling-flycheck
+
+(defun eglot-x-run-flycheck (arg)
+ "Start a manual flycheck for the current buffer when checkOnSave is disabled.
+With prefix arg start all flycheck processes."
+ (interactive "P")
+ (jsonrpc-notify (eglot-current-server)
+ :rust-analyzer/runFlycheck
+ `(:textDocument ,(if arg
+ nil
+ (eglot--TextDocumentIdentifier)))))
+
+(defun eglot-x-clear-flycheck ()
+ "Clear the flycheck diagnostics."
+ (interactive)
+ (jsonrpc-notify (eglot-current-server) :rust-analyzer/clearFlycheck nil))
+
+
+(defun eglot-x-cancel-flycheck ()
+ "Cancel all running flycheck processes."
+ (interactive)
+ (jsonrpc-notify (eglot-current-server) :rust-analyzer/cancelFlycheck nil))
+
;;; (Memory Usage) -- this is not documented in lsp-extensions.md
(defun eglot-x-memory-usage ()