diff options
author | Florian Diebold <[email protected]> | 2019-05-29 21:57:25 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-05-29 22:00:56 +0100 |
commit | f2c191e9737c50659f0891dc36349c7b0539932f (patch) | |
tree | 6ce3cefeaed5ca1a4f4142e0870f1baf1e1d5900 | |
parent | cb21a219987eac0f8dc08f0c858e8a7154fccd04 (diff) |
Add status buffer function to emacs integration
Also fix a minor race condition in the 'extend selection' initialization.
-rw-r--r-- | editors/emacs/ra-emacs-lsp.el | 34 |
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 |