Skip to content

Commit 5b2f374

Browse files
authored
Implement additional features related to rust-analyzer (#4257)
1 parent 6d3fb63 commit 5b2f374

File tree

1 file changed

+126
-14
lines changed

1 file changed

+126
-14
lines changed

clients/lsp-rust.el

Lines changed: 126 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,104 @@ to a closure. Only applies to closures with blocks, same as
372372
:group 'lsp-rust-analyzer
373373
:package-version '(lsp-mode . "8.0.1"))
374374

375+
(defcustom lsp-rust-analyzer-highlight-breakpoints t
376+
"Enables highlighting of related references while the cursor is on
377+
`break`, `loop`, `while`, or `for` keywords."
378+
:type 'boolean
379+
:group 'lsp-rust-analyzer
380+
:package-version '(lsp-mode . "8.0.1"))
381+
382+
(defcustom lsp-rust-analyzer-highlight-closure-captures t
383+
"Enables highlighting of all captures of a closure while the
384+
cursor is on the `|` or move keyword of a closure."
385+
:type 'boolean
386+
:group 'lsp-rust-analyzer
387+
:package-version '(lsp-mode . "8.0.1"))
388+
389+
(defcustom lsp-rust-analyzer-highlight-exit-points t
390+
"Enables highlighting of all exit points while the cursor is on
391+
any `return`, `?`, `fn`, or return type arrow (`->`)."
392+
:type 'boolean
393+
:group 'lsp-rust-analyzer
394+
:package-version '(lsp-mode . "8.0.1"))
395+
396+
(defcustom lsp-rust-analyzer-highlight-references t
397+
"Enables highlighting of related references while the cursor is on
398+
any identifier."
399+
:type 'boolean
400+
:group 'lsp-rust-analyzer
401+
:package-version '(lsp-mode . "8.0.1"))
402+
403+
(defcustom lsp-rust-analyzer-highlight-yield-points t
404+
"Enables highlighting of all break points for a loop or block
405+
context while the cursor is on any `async` or `await` keywords."
406+
:type 'boolean
407+
:group 'lsp-rust-analyzer
408+
:package-version '(lsp-mode . "8.0.1"))
409+
410+
(defcustom lsp-rust-analyzer-closure-return-type-hints "never"
411+
"Whether to show inlay type hints for return types of closures."
412+
:type '(choice
413+
(const "never")
414+
(const "always")
415+
(const "with_block"))
416+
:group 'lsp-rust-analyzer
417+
:package-version '(lsp-mode . "8.0.1"))
418+
419+
(defcustom lsp-rust-analyzer-discriminants-hints "never"
420+
"Whether to show enum variant discriminant hints."
421+
:type '(choice
422+
(const "never")
423+
(const "always")
424+
(const "fieldless"))
425+
:group 'lsp-rust-analyzer
426+
:package-version '(lsp-mode . "8.0.1"))
427+
428+
(defcustom lsp-rust-analyzer-expression-adjustment-hints "never"
429+
"Whether to show inlay hints for type adjustments.."
430+
:type '(choice
431+
(const "never")
432+
(const "always")
433+
(const "reborrow"))
434+
:group 'lsp-rust-analyzer
435+
:package-version '(lsp-mode . "8.0.1"))
436+
437+
(defcustom lsp-rust-analyzer-expression-adjustment-hints-mode "prefix"
438+
"Whether to show inlay hints as postfix ops (`.*` instead of `*`, etc)."
439+
:type '(choice
440+
(const "prefix")
441+
(const "postfix")
442+
(const "prefer_prefix")
443+
(const "prefer_postfix"))
444+
:group 'lsp-rust-analyzer
445+
:package-version '(lsp-mode . "8.0.1"))
446+
447+
(defcustom lsp-rust-analyzer-expression-adjustment-hide-unsafe nil
448+
"Whether to hide inlay hints for type adjustments outside of
449+
`unsafe` blocks."
450+
:type 'boolean
451+
:group 'lsp-rust-analyzer
452+
:package-version '(lsp-mode . "8.0.1"))
453+
454+
(defcustom lsp-rust-analyzer-implicit-drops nil
455+
"Whether to show implicit drop hints."
456+
:type 'boolean
457+
:group 'lsp-rust-analyzer
458+
:package-version '(lsp-mode . "8.0.1"))
459+
460+
461+
(defcustom lsp-rust-analyzer-closure-capture-hints nil
462+
"Whether to show inlay hints for closure captures."
463+
:type 'boolean
464+
:group 'lsp-rust-analyzer
465+
:package-version '(lsp-mode . "8.0.1"))
466+
467+
(defcustom lsp-rust-analyzer-closure-style "impl_fn"
468+
"Closure notation in type and chaining inlay hints."
469+
:type 'string
470+
:group 'lsp-rust-analyzer
471+
:package-version '(lsp-mode . "8.0.1"))
472+
375473
(defcustom lsp-rust-analyzer-hide-named-constructor nil
376474
"Whether to hide inlay type hints for constructors."
377475
:type 'boolean
@@ -1555,6 +1653,11 @@ https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.m
15551653
:allTargets ,(lsp-json-bool lsp-rust-analyzer-check-all-targets)
15561654
:features ,lsp-rust-analyzer-checkonsave-features
15571655
:overrideCommand ,lsp-rust-analyzer-cargo-override-command)
1656+
:highlightRelated (:breakPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-breakpoints))
1657+
:closureCaptures (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-closure-captures))
1658+
:exitPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-exit-points))
1659+
:references (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-references))
1660+
:yieldPoints (:enable ,(lsp-json-bool lsp-rust-analyzer-highlight-yield-points)))
15581661
:files (:exclude ,lsp-rust-analyzer-exclude-globs
15591662
:watcher ,(if lsp-rust-analyzer-use-client-watching "client" "notify")
15601663
:excludeDirs ,lsp-rust-analyzer-exclude-dirs)
@@ -1582,20 +1685,29 @@ https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/lsp-extensions.m
15821685
:trait (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-references-trait-enable)))
15831686
:run (:enable ,(lsp-json-bool lsp-rust-analyzer-lens-run-enable)))
15841687

1585-
:inlayHints (:bindingModeHints ,(lsp-json-bool lsp-rust-analyzer-binding-mode-hints)
1586-
:chainingHints ,(lsp-json-bool lsp-rust-analyzer-display-chaining-hints)
1587-
:closingBraceHints (:enable ,(lsp-json-bool lsp-rust-analyzer-closing-brace-hints)
1588-
:minLines ,lsp-rust-analyzer-closing-brace-hints-min-lines)
1589-
:closureReturnTypeHints ,(lsp-json-bool lsp-rust-analyzer-display-closure-return-type-hints)
1590-
:lifetimeElisionHints (:enable ,lsp-rust-analyzer-display-lifetime-elision-hints-enable
1591-
:useParameterNames ,(lsp-json-bool lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names))
1592-
:maxLength ,lsp-rust-analyzer-max-inlay-hint-length
1593-
:parameterHints ,(lsp-json-bool lsp-rust-analyzer-display-parameter-hints)
1594-
:reborrowHints ,lsp-rust-analyzer-display-reborrow-hints
1595-
:renderColons ,(lsp-json-bool lsp-rust-analyzer-server-format-inlay-hints)
1596-
:typeHints (:enable ,(lsp-json-bool lsp-inlay-hint-enable)
1597-
:hideClosureInitialization ,(lsp-json-bool lsp-rust-analyzer-hide-closure-initialization)
1598-
:hideNamedConstructor ,(lsp-json-bool lsp-rust-analyzer-hide-named-constructor)))
1688+
:inlayHints (:bindingModeHints (:enable ,(lsp-json-bool lsp-rust-analyzer-binding-mode-hints))
1689+
:chainingHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-chaining-hints))
1690+
:closingBraceHints (:enable ,(lsp-json-bool lsp-rust-analyzer-closing-brace-hints)
1691+
:minLines ,lsp-rust-analyzer-closing-brace-hints-min-lines)
1692+
:closureCaptureHints (:enable ,(lsp-json-bool lsp-rust-analyzer-closure-capture-hints))
1693+
:closureReturnTypeHints (:enable ,lsp-rust-analyzer-closure-return-type-hints)
1694+
:closureStyle ,lsp-rust-analyzer-closure-style
1695+
:discriminantHints (:enable ,lsp-rust-analyzer-discriminants-hints)
1696+
1697+
:expressionAdjustmentHints (:enable ,lsp-rust-analyzer-expression-adjustment-hints
1698+
:hideOutsideUnsafe ,(lsp-json-bool lsp-rust-analyzer-expression-adjustment-hide-unsafe)
1699+
:mode ,lsp-rust-analyzer-expression-adjustment-hints-mode)
1700+
:implicitDrops (:enable ,(lsp-json-bool lsp-rust-analyzer-implicit-drops))
1701+
:lifetimeElisionHints (:enable ,lsp-rust-analyzer-display-lifetime-elision-hints-enable
1702+
:useParameterNames ,(lsp-json-bool lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names))
1703+
:maxLength ,lsp-rust-analyzer-max-inlay-hint-length
1704+
:parameterHints (:enable ,(lsp-json-bool lsp-rust-analyzer-display-parameter-hints))
1705+
:reborrowHints (:enable ,lsp-rust-analyzer-display-reborrow-hints)
1706+
:renderColons ,(lsp-json-bool lsp-rust-analyzer-server-format-inlay-hints)
1707+
:typeHints (:enable ,(lsp-json-bool lsp-inlay-hint-enable)
1708+
:hideClosureInitialization ,(lsp-json-bool lsp-rust-analyzer-hide-closure-initialization)
1709+
:hideNamedConstructor ,(lsp-json-bool lsp-rust-analyzer-hide-named-constructor))
1710+
)
15991711
:completion (:addCallParenthesis ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-parenthesis)
16001712
:addCallArgumentSnippets ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-argument-snippets)
16011713
:postfix (:enable ,(lsp-json-bool lsp-rust-analyzer-completion-postfix-enable))

0 commit comments

Comments
 (0)