aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-30 09:36:41 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-30 09:36:41 +0100
commit572a1e507e3009de8eea84d6fad7e9abedadb6f0 (patch)
treed4873495d9b94fd996f84b8ce3087eaf4a0addff /editors
parent615b59aea09d4bd55c3e3a72e9aab86810107ca6 (diff)
parentf2c191e9737c50659f0891dc36349c7b0539932f (diff)
Merge #1347
1347: Add status buffer function to emacs integration r=flodiebold a=flodiebold Also fix a minor race condition in the 'extend selection' initialization. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'editors')
-rw-r--r--editors/emacs/ra-emacs-lsp.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/editors/emacs/ra-emacs-lsp.el b/editors/emacs/ra-emacs-lsp.el
index 84c018b66..71bc20f17 100644
--- a/editors/emacs/ra-emacs-lsp.el
+++ b/editors/emacs/ra-emacs-lsp.el
@@ -134,6 +134,13 @@
134 '(rust-analyzer-extend-selection)))) 134 '(rust-analyzer-extend-selection))))
135 135
136(with-eval-after-load 'expand-region 136(with-eval-after-load 'expand-region
137 ;; add the expansion for all existing rust-mode buffers. If expand-region is
138 ;; loaded lazily, it might be loaded when the first rust buffer is opened, and
139 ;; then it's too late for the hook for that buffer
140 (dolist (buf (buffer-list))
141 (with-current-buffer buf
142 (when (eq 'rust-mode major-mode)
143 (rust-analyzer--add-er-expansion))))
137 (add-hook 'rust-mode-hook 'rust-analyzer--add-er-expansion)) 144 (add-hook 'rust-mode-hook 'rust-analyzer--add-er-expansion))
138 145
139;; runnables 146;; runnables
@@ -170,5 +177,32 @@
170 (rust-analyzer--select-runnable)))) 177 (rust-analyzer--select-runnable))))
171 (rust-analyzer-run (or runnable rust-analyzer--last-runnable))) 178 (rust-analyzer-run (or runnable rust-analyzer--last-runnable)))
172 179
180;; analyzer status buffer
181(define-derived-mode rust-analyzer-status-mode special-mode "Rust-Analyzer-Status"
182 "Mode for the rust-analyzer status buffer.")
183
184(defvar-local rust-analyzer--status-buffer-workspace nil)
185
186(defun rust-analyzer-status ()
187 "Displays status information for rust-analyzer."
188 (interactive)
189 (let* ((workspace (lsp-find-workspace 'rust-analyzer (buffer-file-name)))
190 (buf (get-buffer-create (concat "*rust-analyzer status " (with-lsp-workspace workspace (lsp-workspace-root)) "*"))))
191 (with-current-buffer buf
192 (rust-analyzer-status-mode)
193 (setq rust-analyzer--status-buffer-workspace workspace)
194 (rust-analyzer-status-buffer-refresh))
195 (pop-to-buffer buf)))
196
197(defun rust-analyzer-status-buffer-refresh ()
198 (interactive)
199 (when rust-analyzer--status-buffer-workspace
200 (let ((inhibit-read-only t))
201 (erase-buffer)
202 (insert (with-lsp-workspace rust-analyzer--status-buffer-workspace
203 (lsp-send-request (lsp-make-request
204 "rust-analyzer/analyzerStatus")))))))
205
206
173(provide 'ra-emacs-lsp) 207(provide 'ra-emacs-lsp)
174;;; ra-emacs-lsp.el ends here 208;;; ra-emacs-lsp.el ends here