@@ -378,12 +378,6 @@ to a closure.ppOnly applies to closures with blocks, same as
378378 :group 'lsp-rust-analyzer
379379 :package-version '(lsp-mode . " 8.0.1" ))
380380
381- (defcustom lsp-rust-analyzer-server-display-inlay-hints nil
382- " Show inlay hints."
383- :type 'boolean
384- :group 'lsp-rust-analyzer
385- :package-version '(lsp-mode . " 6.2" ))
386-
387381(defcustom lsp-rust-analyzer-max-inlay-hint-length nil
388382 " Max inlay hint length."
389383 :type 'integer
@@ -783,7 +777,7 @@ or JSON objects in `rust-project.json` format."
783777 :parameterHints ,(lsp-json-bool lsp-rust-analyzer-display-parameter-hints)
784778 :reborrowHints , lsp-rust-analyzer-display-reborrow-hints
785779 :renderColons ,(lsp-json-bool lsp-rust-analyzer-server-format-inlay-hints)
786- :typeHints (:enable ,(lsp-json-bool lsp-rust-analyzer-server-display- inlay-hints )
780+ :typeHints (:enable ,(lsp-json-bool lsp-inlay-hint-enable )
787781 :hideClosureInitialization ,(lsp-json-bool lsp-rust-analyzer-hide-closure-initialization)
788782 :hideNamedConstructor ,(lsp-json-bool lsp-rust-analyzer-hide-named-constructor)))
789783 :completion (:addCallParenthesis ,(lsp-json-bool lsp-rust-analyzer-completion-add-call-parenthesis)
@@ -1233,9 +1227,7 @@ tokens legend."
12331227 (" public" . , lsp-rust-analyzer-public-modifier )
12341228 (" reference" . , lsp-rust-analyzer-reference-modifier )
12351229 (" trait" . , lsp-rust-analyzer-trait-modifier )
1236- (" unsafe" . , lsp-rust-analyzer-unsafe-modifier )
1237- ))
1238-
1230+ (" unsafe" . , lsp-rust-analyzer-unsafe-modifier )))
12391231
12401232(lsp-register-client
12411233 (make-lsp-client
@@ -1255,14 +1247,9 @@ tokens legend."
12551247 (" rust-analyzer.showReferences" #'lsp-rust--analyzer-show-references )
12561248 (" rust-analyzer.triggerParameterHints" #'lsp--action-trigger-parameter-hints ))
12571249 :library-folders-fn (lambda (_workspace ) lsp-rust-analyzer-library-directories)
1258- :after-open-fn (lambda ()
1259- (when lsp-rust-analyzer-server-display-inlay-hints
1260- (lsp-rust-analyzer-inlay-hints-mode)))
1261- :ignore-messages nil
1262-
12631250 :semantic-tokens-faces-overrides `(:discard-default-modifiers t
1264- :modifiers
1265- ,(lsp-rust-analyzer--semantic-modifiers))
1251+ :modifiers
1252+ ,(lsp-rust-analyzer--semantic-modifiers))
12661253 :server-id 'rust-analyzer
12671254 :custom-capabilities `((experimental . ((snippetTextEdit . ,(and lsp-enable-snippet (featurep 'yasnippet ))))))
12681255 :download-server-fn (lambda (_client callback error-callback _update? )
@@ -1282,42 +1269,6 @@ tokens legend."
12821269
12831270; ; inlay hints
12841271
1285- (defvar-local lsp-rust-analyzer-inlay-hints-timer nil )
1286-
1287- (defface lsp-rust-analyzer-inlay-face
1288- '((t :inherit font-lock-comment-face ))
1289- " The face to use for the Rust Analyzer inlays."
1290- :group 'lsp-rust-analyzer
1291- :package-version '(lsp-mode . " 7.0" ))
1292-
1293- (defface lsp-rust-analyzer-inlay-type-face
1294- '((t :inherit lsp-rust-analyzer-inlay-face))
1295- " Face for inlay type hints (e.g. inferred variable types)."
1296- :group 'lsp-rust-analyzer
1297- :package-version '(lsp-mode . " 8.0.0" ))
1298-
1299- (defcustom lsp-rust-analyzer-inlay-type-format " : %s"
1300- " Format string for variable inlays (part of the inlay face,
1301- used only if lsp-rust-analyzer-server-format-inlay-hints is
1302- non-nil)."
1303- :type '(string :tag " String" )
1304- :group 'lsp-rust-analyzer
1305- :package-version '(lsp-mode . " 8.0.0" ))
1306-
1307- (defface lsp-rust-analyzer-inlay-param-face
1308- '((t :inherit lsp-rust-analyzer-inlay-face))
1309- " Face for inlay parameter hints (e.g. function parameter names at call-site)."
1310- :group 'lsp-rust-analyzer
1311- :package-version '(lsp-mode . " 8.0.0" ))
1312-
1313- (defcustom lsp-rust-analyzer-inlay-param-format " %s:"
1314- " Format string for parameter inlays (part of the inlay face,
1315- used only if lsp-rust-analyzer-server-format-inlay-hints is
1316- non-nil)."
1317- :type '(string :tag " String" )
1318- :group 'lsp-rust-analyzer
1319- :package-version '(lsp-mode . " 8.0.0" ))
1320-
13211272(defcustom lsp-rust-analyzer-debug-lens-extra-dap-args
13221273 '(:MIMode " gdb" :miDebuggerPath " gdb" :stopAtEntry t :externalConsole :json-false )
13231274 " Extra arguments to pass to DAP template when debugging a test from code lens.
@@ -1331,85 +1282,10 @@ meaning."
13311282 :group 'lsp-rust-analyzer
13321283 :package-version '(lsp-mode . " 8.0.0" ))
13331284
1334- (defvar lsp-rust-analyzer-already-warned-about-inlay-hint-type nil )
1335-
1336- (defun lsp-rust-analyzer-update-inlay-hints (buffer )
1337- (if (and (lsp-rust-analyzer-initialized?)
1338- (eq buffer (current-buffer )))
1339- (lsp-request-async
1340- " textDocument/inlayHint"
1341- (lsp-make-rust-analyzer-inlay-hints-params
1342- :text-document (lsp--text-document-identifier)
1343- :range (if (use-region-p )
1344- (lsp--region-to-range (region-beginning ) (region-end ))
1345- (lsp--region-to-range (point-min ) (point-max ))))
1346- (lambda (res )
1347- (remove-overlays (point-min ) (point-max ) 'lsp-rust-analyzer-inlay-hint t )
1348- (dolist (hint res)
1349- (-let* (((&rust-analyzer:InlayHint :position :label :kind :padding-left :padding-right ) hint)
1350- (pos (lsp--position-to-point position))
1351- (overlay (make-overlay pos pos nil 'front-advance 'end-advance )))
1352- (let ((concat-label
1353- (cl-typecase label
1354- (vector
1355- (string-join
1356- (mapcar
1357- (lambda (label )
1358- (when (lsp-structure-p label)
1359- (lsp-get label :value )))
1360- label)))
1361- (string
1362- label)
1363- (t
1364- (unless lsp-rust-analyzer-already-warned-about-inlay-hint-type
1365- (message " Unexpected type for inlay hint: %s " (type-of label))
1366- (setq lsp-rust-analyzer-already-warned-about-inlay-hint-type t ))
1367- " " ))))
1368- (overlay-put overlay 'lsp-rust-analyzer-inlay-hint t )
1369- (overlay-put overlay 'before-string
1370- (format " %s%s%s "
1371- (if padding-left " " " " )
1372- (propertize (lsp-rust-analyzer-format-inlay concat-label kind)
1373- 'font-lock-face (lsp-rust-analyzer-face-for-inlay kind))
1374- (if padding-right " " " " )))))))
1375- :mode 'tick ))
1376- nil )
1377-
1378- (defun lsp-rust-analyzer-format-inlay (label kind )
1379- (if lsp-rust-analyzer-server-format-inlay-hints
1380- label
1381- (cond
1382- ((eql kind lsp/rust-analyzer-inlay-hint-kind-type-hint) (format lsp-rust-analyzer-inlay-type-format label))
1383- ((eql kind lsp/rust-analyzer-inlay-hint-kind-param-hint) (format lsp-rust-analyzer-inlay-param-format label))
1384- (t label))))
1385-
1386- (defun lsp-rust-analyzer-face-for-inlay (kind )
1387- (cond
1388- ((eql kind lsp/rust-analyzer-inlay-hint-kind-type-hint) 'lsp-rust-analyzer-inlay-type-face )
1389- ((eql kind lsp/rust-analyzer-inlay-hint-kind-param-hint) 'lsp-rust-analyzer-inlay-param-face )
1390- (t 'lsp-rust-analyzer-inlay-face )))
1391-
13921285(defun lsp-rust-analyzer-initialized? ()
13931286 (when-let ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name ))))
13941287 (eq 'initialized (lsp--workspace-status workspace))))
13951288
1396- (defun lsp-rust-analyzer-inlay-hints-change-handler (&rest _rest )
1397- (when lsp-rust-analyzer-inlay-hints-timer
1398- (cancel-timer lsp-rust-analyzer-inlay-hints-timer))
1399- (setq lsp-rust-analyzer-inlay-hints-timer
1400- (run-with-idle-timer 0.1 nil #'lsp-rust-analyzer-update-inlay-hints (current-buffer ))))
1401-
1402- (define-minor-mode lsp-rust-analyzer-inlay-hints-mode
1403- " Mode for displaying inlay hints."
1404- :lighter nil
1405- (cond
1406- (lsp-rust-analyzer-inlay-hints-mode
1407- (lsp-rust-analyzer-update-inlay-hints (current-buffer ))
1408- (add-hook 'lsp-on-change-hook #'lsp-rust-analyzer-inlay-hints-change-handler nil t ))
1409- (t
1410- (remove-overlays (point-min ) (point-max ) 'lsp-rust-analyzer-inlay-hint t )
1411- (remove-hook 'lsp-on-change-hook #'lsp-rust-analyzer-inlay-hints-change-handler t ))))
1412-
14131289(defun lsp-rust-analyzer-expand-macro ()
14141290 " Expands the macro call at point recursively."
14151291 (interactive )
0 commit comments