File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 204
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
233
(provide 'ra-emacs-lsp )
208
234
; ;; ra-emacs-lsp.el ends here
You can’t perform that action at this time.
0 commit comments