@@ -555,49 +555,43 @@ them with `crate` or the crate name they refer to."
555
555
(defun lsp-rust-analyzer-syntax-tree ()
556
556
" Display syntax tree for current buffer."
557
557
(interactive )
558
- (-if-let* ((workspace (lsp-find-workspace 'rust-analyzer ))
559
- (root (lsp-workspace-root default-directory))
560
- (params (lsp-make-rust-analyzer-syntax-tree-params
561
- :text-document (lsp--text-document-identifier)
562
- :range? (if (use-region-p )
563
- (lsp--region-to-range (region-beginning ) (region-end ))
564
- (lsp--region-to-range (point-min ) (point-max )))))
565
- (results (with-lsp-workspace workspace
566
- (lsp-send-request (lsp-make-request
567
- " rust-analyzer/syntaxTree"
568
- params)))))
569
- (let ((buf (get-buffer-create (format " *rust-analyzer syntax tree %s * " root)))
570
- (inhibit-read-only t ))
571
- (with-current-buffer buf
572
- (lsp-rust-analyzer-syntax-tree-mode)
573
- (erase-buffer )
574
- (insert results)
575
- (goto-char (point-min )))
576
- (pop-to-buffer buf))
577
- (message " rust-analyzer not running. " )))
558
+ (-let* ((root (lsp-workspace-root default-directory))
559
+ (params (lsp-make-rust-analyzer-syntax-tree-params
560
+ :text-document (lsp--text-document-identifier)
561
+ :range? (if (use-region-p )
562
+ (lsp--region-to-range (region-beginning ) (region-end ))
563
+ (lsp--region-to-range (point-min ) (point-max )))))
564
+ (results (lsp-send-request (lsp-make-request
565
+ " rust-analyzer/syntaxTree"
566
+ params))))
567
+ (let ((buf (get-buffer-create (format " *rust-analyzer syntax tree %s * " root)))
568
+ (inhibit-read-only t ))
569
+ (with-current-buffer buf
570
+ (lsp-rust-analyzer-syntax-tree-mode)
571
+ (erase-buffer )
572
+ (insert results)
573
+ (goto-char (point-min )))
574
+ (pop-to-buffer buf))))
578
575
579
576
(define-derived-mode lsp-rust-analyzer-status-mode special-mode " Rust-Analyzer-Status"
580
577
" Mode for the rust-analyzer status buffer." )
581
578
582
579
(defun lsp-rust-analyzer-status ()
583
580
" Displays status information for rust-analyzer."
584
581
(interactive )
585
- (-if-let* ((workspace (lsp-find-workspace 'rust-analyzer ))
586
- (root (lsp-workspace-root default-directory))
587
- (params (lsp-make-rust-analyzer-analyzer-status-params
588
- :text-document (lsp--text-document-identifier)))
589
- (results (with-lsp-workspace workspace
590
- (lsp-send-request (lsp-make-request
591
- " rust-analyzer/analyzerStatus"
592
- params)))))
593
- (let ((buf (get-buffer-create (format " *rust-analyzer status %s * " root)))
594
- (inhibit-read-only t ))
595
- (with-current-buffer buf
596
- (lsp-rust-analyzer-status-mode)
597
- (erase-buffer )
598
- (insert results)
599
- (pop-to-buffer buf)))
600
- (message " rust-analyzer not running. " )))
582
+ (-let* ((root (lsp-workspace-root default-directory))
583
+ (params (lsp-make-rust-analyzer-analyzer-status-params
584
+ :text-document (lsp--text-document-identifier)))
585
+ (results (lsp-send-request (lsp-make-request
586
+ " rust-analyzer/analyzerStatus"
587
+ params))))
588
+ (let ((buf (get-buffer-create (format " *rust-analyzer status %s * " root)))
589
+ (inhibit-read-only t ))
590
+ (with-current-buffer buf
591
+ (lsp-rust-analyzer-status-mode)
592
+ (erase-buffer )
593
+ (insert results)
594
+ (pop-to-buffer buf)))))
601
595
602
596
(defun lsp-rust-analyzer-join-lines ()
603
597
" Join selected lines into one, smartly fixing up whitespace and trailing commas."
@@ -780,7 +774,7 @@ them with `crate` or the crate name they refer to."
780
774
nil )
781
775
782
776
(defun lsp-rust-analyzer-initialized? ()
783
- (when-let ((workspace (lsp-find-workspace 'rust-analyzer )))
777
+ (when-let ((workspace (lsp-find-workspace 'rust-analyzer ( buffer-file-name ) )))
784
778
(eq 'initialized (lsp--workspace-status workspace))))
785
779
786
780
(defun lsp-rust-analyzer-inlay-hints-change-handler (&rest _rest )
@@ -803,18 +797,15 @@ them with `crate` or the crate name they refer to."
803
797
(defun lsp-rust-analyzer-expand-macro ()
804
798
" Expands the macro call at point recursively."
805
799
(interactive )
806
- (-if-let (workspace (lsp-find-workspace 'rust-analyzer ))
807
- (-if-let* ((params (lsp-make-rust-analyzer-expand-macro-params
808
- :text-document (lsp--text-document-identifier)
809
- :position (lsp--cur-position)))
810
- (response (with-lsp-workspace workspace
811
- (lsp-send-request (lsp-make-request
812
- " rust-analyzer/expandMacro"
813
- params))))
814
- ((&rust-analyzer:ExpandedMacro :expansion ) response))
815
- (funcall lsp-rust-analyzer-macro-expansion-method expansion)
816
- (message " No macro found at point, or it could not be expanded. " ))
817
- (message " rust-analyzer not running. " )))
800
+ (-if-let* ((params (lsp-make-rust-analyzer-expand-macro-params
801
+ :text-document (lsp--text-document-identifier)
802
+ :position (lsp--cur-position)))
803
+ (response (lsp-send-request (lsp-make-request
804
+ " rust-analyzer/expandMacro"
805
+ params)))
806
+ ((&rust-analyzer:ExpandedMacro :expansion ) response))
807
+ (funcall lsp-rust-analyzer-macro-expansion-method expansion)
808
+ (message " No macro found at point, or it could not be expanded. " )))
818
809
819
810
(defun lsp-rust-analyzer-macro-expansion-default (result )
820
811
" Default method for displaying macro expansion."
0 commit comments