Skip to content

Commit 6b01d49

Browse files
Nikola Pajkovskybrotzeit
authored andcommitted
lsp-rust: fix inlay hints
rust-analyzer has changed the inlay hint label from string to array of structs where struct has the member *value* contain inlay hints. The algorithm just iterate over label array, and concats all *value* into one string that's printed out. "label": [ { "value": ": " }, { "value": "File", "location": { "uri": "file:///home/nikola/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/fs.rs", "range": { "start": { "line": 97, "character": 11 }, "end": { "line": 97, "character": 15 } } } }, { "value": "" } Close #3896 Signed-off-by: Nikola Pajkovsky <nikola@enhance.com>
1 parent 3ac10bf commit 6b01d49

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clients/lsp-rust.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,12 +1339,18 @@ meaning."
13391339
(-let* (((&rust-analyzer:InlayHint :position :label :kind :padding-left :padding-right) hint)
13401340
(pos (lsp--position-to-point position))
13411341
(overlay (make-overlay pos pos nil 'front-advance 'end-advance)))
1342-
(when (stringp label)
1342+
(let ((concat-label
1343+
(string-join
1344+
(mapcar
1345+
(lambda (label)
1346+
(when (lsp-structure-p label)
1347+
(gethash "value" label "")))
1348+
label))))
13431349
(overlay-put overlay 'lsp-rust-analyzer-inlay-hint t)
13441350
(overlay-put overlay 'before-string
13451351
(format "%s%s%s"
13461352
(if padding-left " " "")
1347-
(propertize (lsp-rust-analyzer-format-inlay label kind)
1353+
(propertize (lsp-rust-analyzer-format-inlay concat-label kind)
13481354
'font-lock-face (lsp-rust-analyzer-face-for-inlay kind))
13491355
(if padding-right " " "")))))))
13501356
:mode 'tick))

0 commit comments

Comments
 (0)