diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index c07eb01404d..4d555d4886e 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -29,7 +29,6 @@ fn main() -> Result<()> { } } } - fn main_inner() -> Result<()> { let (receiver, sender, threads) = stdio_transport(); let cwd = ::std::env::current_dir()?; @@ -50,3 +49,27 @@ fn main_inner() -> Result<()> { info!("... IO is down"); Ok(()) } + +/* + (let ((backend (eglot-xref-backend))) + (mapcar + (lambda (xref) + (let ((loc (xref-item-location xref))) + (propertize + (concat + (when (xref-file-location-p loc) + (with-slots (file line column) loc + (format "%s:%s:%s:" + (propertize (file-relative-name file) + 'face 'compilation-info) + (propertize (format "%s" line) + 'face 'compilation-line + ) + column))) + (xref-item-summary xref)) + 'xref xref))) + (xref-backend-apropos backend "Analysis")) + ) + + +*/ diff --git a/editors/emacs/ra.el b/editors/emacs/ra.el index 099f611be7b..a0b17f3af26 100644 --- a/editors/emacs/ra.el +++ b/editors/emacs/ra.el @@ -83,5 +83,41 @@ "Set selections cache for current buffer state and START END." (setq ra--selections-cache `(,(buffer-modified-tick) 0 ,(ra--selections start end)))) + +(require 'eglot) +(require 'ivy) +(require 'counsel) + + +(defun workspace-symbols () + (interactive) + (let ((buf (current-buffer))) + (ivy-read "Symbol name: " + (lambda (str) + (with-current-buffer buf + (let ((backend (eglot-xref-backend))) + (mapcar + (lambda (xref) + (let ((loc (xref-item-location xref))) + (propertize + (concat + (when (xref-file-location-p loc) + (with-slots (file line column) loc + (format "%s:%s:%s:" + (propertize (file-relative-name file) + 'face 'compilation-info) + (propertize (format "%s" line) + 'face 'compilation-line + ) + column))) + (xref-item-summary xref)) + 'xref xref))) + (xref-backend-apropos backend str)) + ))) + :dynamic-collection t + :action (lambda (item) + (xref--pop-to-location (get-text-property 0 'xref item)))))) + +(add-to-list 'eglot-server-programs '(rust-mode . ("ra_lsp_server"))) (provide 'ra) ;;; ra.el ends here