@@ -150,7 +150,7 @@ will cause performances issues.")
150
150
(defvar-local lsp-ui-peek--offset 0 )
151
151
(defvar-local lsp-ui-peek--size-list 0 )
152
152
(defvar-local lsp-ui-peek--win-start nil )
153
- (defvar-local lsp-ui-peek--kind nil )
153
+ (defvar-local lsp-ui-peek--method nil )
154
154
(defvar-local lsp-ui-peek--deactivate-keymap-fn nil )
155
155
156
156
(defvar lsp-ui-peek--jumps (make-hash-table )
@@ -337,7 +337,8 @@ XREFS is a list of references/definitions."
337
337
(-let* ((xref (lsp-ui-peek--get-selection))
338
338
((&plist :file file :chunk chunk) (or xref lsp-ui-peek--last-xref))
339
339
(header (concat " " (lsp-ui--workspace-path file) " \n " ))
340
- (header2 (format " %s %s " lsp-ui-peek--size-list (symbol-name lsp-ui-peek--kind)))
340
+ (header2 (format " %s %s " lsp-ui-peek--size-list
341
+ (string-remove-prefix " workspace/" (string-remove-prefix " textDocument/" lsp-ui-peek--method))))
341
342
(ref-view (--> chunk
342
343
(if (eq lsp-ui-peek-fontify 'on-demand )
343
344
(lsp-ui-peek--render major-mode it)
@@ -554,13 +555,13 @@ XREFS is a list of references/definitions."
554
555
(lsp-ui-peek--deactivate-keymap)
555
556
(lsp-ui-peek--peek-hide)))
556
557
557
- (defun lsp-ui-peek--find-xrefs (input kind &optional request param )
558
+ (defun lsp-ui-peek--find-xrefs (input method param )
558
559
" Find INPUT references.
559
560
KIND is ‘references’, ‘definitions’ or a custom kind."
560
- (setq lsp-ui-peek--kind kind )
561
- (let ((xrefs (lsp-ui-peek--get-references kind request param)))
561
+ (setq lsp-ui-peek--method method )
562
+ (let ((xrefs (lsp-ui-peek--get-references method param)))
562
563
(unless xrefs
563
- (user-error " No %s found for: %s" ( symbol-name kind) input))
564
+ (user-error " Not found for: %s" input))
564
565
(xref-push-marker-stack )
565
566
(when (featurep 'evil-jumps )
566
567
(lsp-ui-peek--with-evil-jumps (evil-set-jump)))
@@ -575,44 +576,38 @@ KIND is ‘references’, ‘definitions’ or a custom kind."
575
576
(lsp-ui-peek-mode)
576
577
(lsp-ui-peek--show xrefs))))
577
578
578
- (defun lsp-ui-peek-find-references ()
579
+ (defun lsp-ui-peek-find-references (&optional include-declaration extra )
579
580
" Find references to the IDENTIFIER at point."
580
581
(interactive )
581
- (lsp-ui-peek--find-xrefs (symbol-at-point )
582
- 'references
583
- " textDocument/references"
584
- (lsp--make-reference-params)))
582
+ (lsp-ui-peek--find-xrefs (symbol-at-point ) " textDocument/references"
583
+ (append extra (lsp--make-reference-params nil include-declaration))))
585
584
586
- (defun lsp-ui-peek-find-definitions ()
585
+ (defun lsp-ui-peek-find-definitions (&optional extra )
587
586
" Find definitions to the IDENTIFIER at point."
588
587
(interactive )
589
- (lsp-ui-peek--find-xrefs (symbol-at-point )
590
- 'definitions
591
- " textDocument/definition" ))
588
+ (lsp-ui-peek--find-xrefs (symbol-at-point ) " textDocument/definition"
589
+ (append extra (lsp--text-document-position-params))))
592
590
593
- (defun lsp-ui-peek-find-implementation ()
591
+ (defun lsp-ui-peek-find-implementation (&optional extra )
594
592
" Find implementation locations of the symbol at point."
595
593
(interactive )
596
- (lsp-ui-peek--find-xrefs (symbol-at-point )
597
- 'implementation
598
- " textDocument/implementation" ))
594
+ (lsp-ui-peek--find-xrefs (symbol-at-point ) " textDocument/implementation"
595
+ (append extra (lsp--text-document-position-params))))
599
596
600
- (defun lsp-ui-peek-find-workspace-symbol (pattern )
597
+ (defun lsp-ui-peek-find-workspace-symbol (pattern &optional extra )
601
598
" Find symbols in the worskpace.
602
599
The symbols are found matching PATTERN."
603
600
(interactive (list (read-string " workspace/symbol: "
604
601
nil 'xref--read-pattern-history )))
605
- (lsp-ui-peek--find-xrefs pattern
606
- 'symbols
607
- " workspace/symbol"
608
- (list :query pattern)))
602
+ (lsp-ui-peek--find-xrefs pattern " workspace/symbol"
603
+ (append extra (list :query pattern))))
609
604
610
- (defun lsp-ui-peek-find-custom (kind request &optional extra )
605
+ (defun lsp-ui-peek-find-custom (method &optional extra )
611
606
" Find custom references.
612
607
KIND is a symbol to name the references (definition, reference, ..).
613
608
REQUEST is the method string to send the the language server.
614
609
EXTRA is a plist of extra parameters."
615
- (lsp-ui-peek--find-xrefs (symbol-at-point ) kind request
610
+ (lsp-ui-peek--find-xrefs (symbol-at-point ) method
616
611
(append extra (lsp--text-document-position-params))))
617
612
618
613
(defun lsp-ui-peek--extract-chunk-from-buffer (pos start end )
@@ -704,12 +699,10 @@ interface Location {
704
699
" If maybe-sequence is not a sequence, wraps it into a single-element sequence."
705
700
(if (sequencep maybe-sequence) maybe-sequence (list maybe-sequence)))
706
701
707
- (defun lsp-ui-peek--get-references (_kind request &optional param )
702
+ (defun lsp-ui-peek--get-references (method param )
708
703
" Get all references/definitions for the symbol under point.
709
704
Returns item(s)."
710
- (-some->> (lsp--send-request (lsp--make-request
711
- request
712
- (or param (lsp--text-document-position-params))))
705
+ (-some->> (lsp--send-request (lsp--make-request method param))
713
706
; ; Language servers may return a single LOCATION instead of a sequence of them.
714
707
(lsp-ui-peek--to-sequence)
715
708
(lsp-ui-peek--locations-to-xref-items)
0 commit comments