aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/inlay_hints.ts14
-rw-r--r--editors/code/src/server.ts1
-rw-r--r--editors/emacs/ra-emacs-lsp.el28
3 files changed, 30 insertions, 13 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts
index ffaaaebcb..0dbdd94fb 100644
--- a/editors/code/src/commands/inlay_hints.ts
+++ b/editors/code/src/commands/inlay_hints.ts
@@ -87,7 +87,7 @@ export class HintsUpdater {
87 range: hint.range, 87 range: hint.range,
88 renderOptions: { 88 renderOptions: {
89 after: { 89 after: {
90 contentText: `: ${this.truncateHint(hint.label)}` 90 contentText: `: ${hint.label}`
91 } 91 }
92 } 92 }
93 })); 93 }));
@@ -98,18 +98,6 @@ export class HintsUpdater {
98 } 98 }
99 } 99 }
100 100
101 private truncateHint(label: string): string {
102 if (!Server.config.maxInlayHintLength) {
103 return label;
104 }
105
106 let newLabel = label.substring(0, Server.config.maxInlayHintLength);
107 if (label.length > Server.config.maxInlayHintLength) {
108 newLabel += '…';
109 }
110 return newLabel;
111 }
112
113 private async queryHints(documentUri: string): Promise<InlayHint[] | null> { 101 private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
114 const request: InlayHintsParams = { 102 const request: InlayHintsParams = {
115 textDocument: { uri: documentUri } 103 textDocument: { uri: documentUri }
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index a3ef21a16..7907b70bc 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -43,6 +43,7 @@ export class Server {
43 initializationOptions: { 43 initializationOptions: {
44 publishDecorations: true, 44 publishDecorations: true,
45 lruCapacity: Server.config.lruCapacity, 45 lruCapacity: Server.config.lruCapacity,
46 maxInlayHintLength: Server.config.maxInlayHintLength,
46 excludeGlobs: Server.config.excludeGlobs, 47 excludeGlobs: Server.config.excludeGlobs,
47 useClientWatching: Server.config.useClientWatching, 48 useClientWatching: Server.config.useClientWatching,
48 featureFlags: Server.config.featureFlags 49 featureFlags: Server.config.featureFlags
diff --git a/editors/emacs/ra-emacs-lsp.el b/editors/emacs/ra-emacs-lsp.el
index 79822c8ce..fafb9cbe7 100644
--- a/editors/emacs/ra-emacs-lsp.el
+++ b/editors/emacs/ra-emacs-lsp.el
@@ -16,6 +16,7 @@
16;; - implements joinLines (you need to bind rust-analyzer-join-lines to a key) 16;; - implements joinLines (you need to bind rust-analyzer-join-lines to a key)
17;; - implements selectionRanges (either bind lsp-extend-selection to a key, or use expand-region) 17;; - implements selectionRanges (either bind lsp-extend-selection to a key, or use expand-region)
18;; - provides rust-analyzer-inlay-hints-mode for inline type hints 18;; - provides rust-analyzer-inlay-hints-mode for inline type hints
19;; - provides rust-analyzer-expand-macro to expand macros
19 20
20;; What's missing: 21;; What's missing:
21;; - file system changes in apply-source-change 22;; - file system changes in apply-source-change
@@ -247,5 +248,32 @@
247 (remove-hook 'after-change-functions #'rust-analyzer--inlay-hints-change-handler t)))) 248 (remove-hook 'after-change-functions #'rust-analyzer--inlay-hints-change-handler t))))
248 249
249 250
251
252;; expand macros
253(defun rust-analyzer-expand-macro ()
254 "Expands the macro call at point recursively."
255 (interactive)
256 (when (eq 'rust-mode major-mode)
257 (let* ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name)))
258 (params (list :textDocument (lsp--text-document-identifier)
259 :position (lsp--cur-position))))
260 (when workspace
261 (let* ((response (with-lsp-workspace workspace
262 (lsp-send-request (lsp-make-request
263 "rust-analyzer/expandMacro"
264 params))))
265 (result (when response (ht-get response "expansion"))))
266 (if result
267 (let ((buf (get-buffer-create (concat "*rust-analyzer macro expansion " (with-lsp-workspace workspace (lsp-workspace-root)) "*"))))
268 (with-current-buffer buf
269 (let ((inhibit-read-only t))
270 (erase-buffer)
271 (insert result)
272 (setq buffer-read-only t)
273 (special-mode)))
274 (pop-to-buffer buf))
275 (message "No macro found at point, or it could not be expanded")))))))
276
277
250(provide 'ra-emacs-lsp) 278(provide 'ra-emacs-lsp)
251;;; ra-emacs-lsp.el ends here 279;;; ra-emacs-lsp.el ends here