aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/emacs/ra-emacs-lsp.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/editors/emacs/ra-emacs-lsp.el b/editors/emacs/ra-emacs-lsp.el
index 2ea106533..21a90c86b 100644
--- a/editors/emacs/ra-emacs-lsp.el
+++ b/editors/emacs/ra-emacs-lsp.el
@@ -204,5 +204,31 @@
204 "rust-analyzer/analyzerStatus"))))))) 204 "rust-analyzer/analyzerStatus")))))))
205 205
206 206
207(defun rust-analyzer--syntax-tree-params ()
208 "Syntax tree params."
209 (list :textDocument (lsp--text-document-identifier)
210 :range (if (use-region-p)
211 (lsp--region-to-range (region-beginning) (region-end))
212 (lsp--region-to-range (point-min) (point-max)))))
213
214(defun rust-analyzer-syntax-tree ()
215 "Displays syntax tree for current buffer."
216 (interactive)
217 (when (eq 'rust-mode major-mode)
218 (let* ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name)))
219 (buf (get-buffer-create (concat "*rust-analyzer syntax tree " (with-lsp-workspace workspace (lsp-workspace-root)) "*"))))
220 (when workspace
221 (let ((parse-result (with-lsp-workspace workspace
222 (lsp-send-request (lsp-make-request
223 "rust-analyzer/syntaxTree"
224 (rust-analyzer--syntax-tree-params))))))
225 (with-current-buffer buf
226 (let ((inhibit-read-only t))
227 (erase-buffer)
228 (insert parse-result))
229 )
230 (pop-to-buffer buf))))))
231
232
207(provide 'ra-emacs-lsp) 233(provide 'ra-emacs-lsp)
208;;; ra-emacs-lsp.el ends here 234;;; ra-emacs-lsp.el ends here