From 87d60a3ac54c5aac51d81c8996cb839ac59f548f Mon Sep 17 00:00:00 2001 From: Nikita Bloshchanevich Date: Wed, 4 Nov 2020 14:50:20 +0100 Subject: [PATCH] Don't abuse `ivy-configure' + display-transformer Fixes #18. --- lsp-ivy.el | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lsp-ivy.el b/lsp-ivy.el index 5cc2ef0..05bccf5 100644 --- a/lsp-ivy.el +++ b/lsp-ivy.el @@ -118,13 +118,7 @@ (cons string face) (cons string face))) -(eval-when-compile - (lsp-interface - (lsp-ivy:FormattedSymbolInformation - (:kind :name :location :textualRepresentation) - (:containerName :deprecated)))) - -(lsp-defun lsp-ivy--workspace-symbol-action +(lsp-defun lsp-ivy--goto-symbol ((&SymbolInformation :location (&Location :uri :range (&Range :start (&Position :line :character))))) "Jump to selected candidate." @@ -134,7 +128,7 @@ (forward-char character)) (lsp-defun lsp-ivy--format-symbol-match - ((&SymbolInformation :name :kind :container-name? :location (&Location :uri)) + ((&SymbolInformation :name :kind :container-name? :deprecated? :location (&Location :uri)) project-root) "Convert the match returned by `lsp-mode` into a candidate string." (let* ((type (elt lsp-ivy-symbol-kind-to-face kind)) @@ -156,8 +150,11 @@ FILTER-REGEXPS?, otherwise convert it to an `lsp-ivy:FormattedSymbolInformation' (let ((textual-representation (lsp-ivy--format-symbol-match symbol-information workspace-root))) (when (--all? (string-match-p it textual-representation) filter-regexps?) - (lsp-put symbol-information :textualRepresentation textual-representation) - symbol-information)))) + (cons textual-representation symbol-information))))) + +(lsp-defun lsp-ivy--workspace-symbol-action ((_ . sym)) + "Jump to the `cdr' of INPUT0, an `&SymbolInformation'." + (lsp-ivy--goto-symbol sym)) (defun lsp-ivy--workspace-symbol (workspaces prompt initial-input) "Search against WORKSPACES with PROMPT and INITIAL-INPUT." @@ -197,11 +194,6 @@ FILTER-REGEXPS?, otherwise convert it to an `lsp-ivy:FormattedSymbolInformation' :action #'lsp-ivy--workspace-symbol-action :caller 'lsp-ivy-workspace-symbol))) -(ivy-configure 'lsp-ivy-workspace-symbol - :display-transformer-fn - (-lambda ((&lsp-ivy:FormattedSymbolInformation :textual-representation)) - textual-representation)) - ;;;###autoload (defun lsp-ivy-workspace-symbol (arg) "`ivy' for lsp workspace/symbol.