Skip to content

Commit 5005ebe

Browse files
authored
Add more settings for rust-analyzer (#2370)
1 parent 34f2f76 commit 5005ebe

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

clients/lsp-rust.el

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,18 @@ The command should include `--message=format=json` or similar option."
413413
:group 'lsp-rust
414414
:package-version '(lsp-mode . "6.3.2"))
415415

416+
(defcustom lsp-rust-analyzer-diagnostics-enable-experimental t
417+
"Whether to show native rust-analyzer diagnostics that are still experimental (might have more false positives than usual)."
418+
:type 'boolean
419+
:group 'lsp-rust
420+
:package-version '(lsp-mode . "7.1.0"))
421+
422+
(defcustom lsp-rust-analyzer-diagnostics-disabled []
423+
"List of native rust-analyzer diagnostics to disable."
424+
:type 'lsp-string-vector
425+
:group 'lsp-rust
426+
:package-version '(lsp-mode . "7.1.0"))
427+
416428
(defcustom lsp-rust-analyzer-cargo-load-out-dirs-from-check nil
417429
"Whether to run `cargo check` on startup to get the correct value for package OUT_DIRs."
418430
:type 'boolean
@@ -461,9 +473,31 @@ The command should include `--message=format=json` or similar option."
461473
:group 'lsp-rust
462474
:package-version '(lsp-mode . "6.3.2"))
463475

476+
(defcustom lsp-rust-analyzer-import-merge-behaviour "full"
477+
"The strategy to use when inserting new imports or merging imports. Valid values are:\n - \"none\": No merging\n - \"full\": Merge all layers of the import trees\n - \"last\": Only merge the last layer of the import trees"
478+
:type '(choice
479+
(const "none")
480+
(const "full")
481+
(const "last"))
482+
:group 'lsp-rust
483+
:package-version '(lsp-mode . "7.1.0"))
484+
485+
(defcustom lsp-rust-analyzer-import-prefix "plain"
486+
"The path structure for newly inserted paths to use. Valid values are:\n - \"plain\": Insert import paths relative to the current module, using up to one `super` prefix if the parent module contains the requested item.\n - \"by_self\": Prefix all import paths with `self` if they don't begin with `self`, `super`, `crate` or a crate name\n - \"by_crate\": Force import paths to be absolute by always starting them with `crate` or the crate name they refer to."
487+
:type '(choice
488+
(const "plain")
489+
(const "by_self")
490+
(const "by_crate"))
491+
:group 'lsp-rust
492+
:package-version '(lsp-mode . "7.1.0"))
493+
464494
(defun lsp-rust-analyzer--make-init-options ()
465495
"Init options for rust-analyzer"
466-
`(:diagnostics (:enable ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable))
496+
`(:diagnostics (:enable ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable)
497+
:enableExperimental ,(lsp-json-bool lsp-rust-analyzer-diagnostics-enable-experimental)
498+
:disabled ,lsp-rust-analyzer-diagnostics-disabled)
499+
:assist (:importMergeBehaviour ,lsp-rust-analyzer-import-merge-behaviour
500+
:importPrefix ,lsp-rust-analyzer-import-prefix)
467501
:lruCapacity ,lsp-rust-analyzer-lru-capacity
468502
:checkOnSave (:enable ,(lsp-json-bool lsp-rust-analyzer-cargo-watch-enable)
469503
:command ,lsp-rust-analyzer-cargo-watch-command

0 commit comments

Comments
 (0)