aboutsummaryrefslogtreecommitdiff
path: root/editors/emacs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-29 08:06:17 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-06-29 08:06:17 +0100
commit0e1912de528b5092c10eedaf94c43c67d5f86f1a (patch)
tree6d420cbf82786ff890faefdd793880660d74cb04 /editors/emacs
parent1512ab31a046b181f8f6b8c18ea1394b28c037ae (diff)
parentdc7cec8cf4badddb54be03cfa187567b436dd82a (diff)
Merge #1453
1453: Add show syntax tree function to emacs r=matklad a=zbelial This PR adds preliminary support for showing syntax tree. Co-authored-by: zbelial <[email protected]>
Diffstat (limited to 'editors/emacs')
-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