From 18ec4e3403854995d44841a066ff3b190d8115e6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 18 Jan 2020 13:40:32 +0100 Subject: Improve parameter hints a bit & add emacs support - just include the name, not e.g. `mut` - don't return empty hints (or `_`) --- editors/emacs/rust-analyzer.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'editors/emacs') diff --git a/editors/emacs/rust-analyzer.el b/editors/emacs/rust-analyzer.el index 8ba98bf61..06db4f15f 100644 --- a/editors/emacs/rust-analyzer.el +++ b/editors/emacs/rust-analyzer.el @@ -210,9 +210,9 @@ ;; inlay hints (defun rust-analyzer--update-inlay-hints (buffer) (if (and (rust-analyzer--initialized?) (eq buffer (current-buffer))) - (lsp-send-request-async - (lsp-make-request "rust-analyzer/inlayHints" - (list :textDocument (lsp--text-document-identifier))) + (lsp-request-async + "rust-analyzer/inlayHints" + (list :textDocument (lsp--text-document-identifier)) (lambda (res) (remove-overlays (point-min) (point-max) 'rust-analyzer--inlay-hint t) (dolist (hint res) @@ -221,9 +221,16 @@ (overlay (make-overlay beg end))) (overlay-put overlay 'rust-analyzer--inlay-hint t) (overlay-put overlay 'evaporate t) - (overlay-put overlay 'after-string (propertize (concat ": " label) - 'font-lock-face 'font-lock-comment-face))))) - 'tick)) + (cond + ((string= kind "TypeHint") + (overlay-put overlay 'after-string (propertize (concat ": " label) + 'font-lock-face 'font-lock-comment-face))) + ((string= kind "ParameterHint") + (overlay-put overlay 'before-string (propertize (concat label ": ") + 'font-lock-face 'font-lock-comment-face))) + ) + ))) + :mode 'tick)) nil) (defvar-local rust-analyzer--inlay-hints-timer nil) -- cgit v1.2.3