@@ -150,7 +150,7 @@ will cause performances issues.")
150150(defvar-local lsp-ui-peek--offset 0 )
151151(defvar-local lsp-ui-peek--size-list 0 )
152152(defvar-local lsp-ui-peek--win-start nil )
153- (defvar-local lsp-ui-peek--kind nil )
153+ (defvar-local lsp-ui-peek--method nil )
154154(defvar-local lsp-ui-peek--deactivate-keymap-fn nil )
155155
156156(defvar lsp-ui-peek--jumps (make-hash-table )
@@ -337,7 +337,8 @@ XREFS is a list of references/definitions."
337337 (-let* ((xref (lsp-ui-peek--get-selection))
338338 ((&plist :file file :chunk chunk) (or xref lsp-ui-peek--last-xref))
339339 (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))))
341342 (ref-view (--> chunk
342343 (if (eq lsp-ui-peek-fontify 'on-demand )
343344 (lsp-ui-peek--render major-mode it)
@@ -554,13 +555,13 @@ XREFS is a list of references/definitions."
554555 (lsp-ui-peek--deactivate-keymap)
555556 (lsp-ui-peek--peek-hide)))
556557
557- (defun lsp-ui-peek--find-xrefs (input kind &optional request param )
558+ (defun lsp-ui-peek--find-xrefs (input method param )
558559 " Find INPUT references.
559560KIND 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)))
562563 (unless xrefs
563- (user-error " No %s found for: %s" ( symbol-name kind) input))
564+ (user-error " Not found for: %s" input))
564565 (xref-push-marker-stack )
565566 (when (featurep 'evil-jumps )
566567 (lsp-ui-peek--with-evil-jumps (evil-set-jump)))
@@ -575,44 +576,38 @@ KIND is ‘references’, ‘definitions’ or a custom kind."
575576 (lsp-ui-peek-mode)
576577 (lsp-ui-peek--show xrefs))))
577578
578- (defun lsp-ui-peek-find-references ()
579+ (defun lsp-ui-peek-find-references (&optional include-declaration extra )
579580 " Find references to the IDENTIFIER at point."
580581 (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))))
585584
586- (defun lsp-ui-peek-find-definitions ()
585+ (defun lsp-ui-peek-find-definitions (&optional extra )
587586 " Find definitions to the IDENTIFIER at point."
588587 (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))))
592590
593- (defun lsp-ui-peek-find-implementation ()
591+ (defun lsp-ui-peek-find-implementation (&optional extra )
594592 " Find implementation locations of the symbol at point."
595593 (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))))
599596
600- (defun lsp-ui-peek-find-workspace-symbol (pattern )
597+ (defun lsp-ui-peek-find-workspace-symbol (pattern &optional extra )
601598 " Find symbols in the worskpace.
602599The symbols are found matching PATTERN."
603600 (interactive (list (read-string " workspace/symbol: "
604601 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))))
609604
610- (defun lsp-ui-peek-find-custom (kind request &optional extra )
605+ (defun lsp-ui-peek-find-custom (method &optional extra )
611606 " Find custom references.
612607KIND is a symbol to name the references (definition, reference, ..).
613608REQUEST is the method string to send the the language server.
614609EXTRA 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
616611 (append extra (lsp--text-document-position-params))))
617612
618613(defun lsp-ui-peek--extract-chunk-from-buffer (pos start end )
@@ -704,12 +699,10 @@ interface Location {
704699 " If maybe-sequence is not a sequence, wraps it into a single-element sequence."
705700 (if (sequencep maybe-sequence) maybe-sequence (list maybe-sequence)))
706701
707- (defun lsp-ui-peek--get-references (_kind request &optional param )
702+ (defun lsp-ui-peek--get-references (method param )
708703 " Get all references/definitions for the symbol under point.
709704Returns 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))
713706 ; ; Language servers may return a single LOCATION instead of a sequence of them.
714707 (lsp-ui-peek--to-sequence)
715708 (lsp-ui-peek--locations-to-xref-items)
0 commit comments