Skip to content

Commit 9694e60

Browse files
committed
[radian-software/prescient.el#57] Use string candidates
The Ivy API requires that you use candidates with string values only in order for sorting and filtering to work properly in all cases. To provide for non-string candidates there is the option to pass cons cells whose cars are the strings to use for sorting and filtering and whose cdrs are the actual values you care about. Doing that fixes a conflict with prescient.el (see linked issue).
1 parent a6b7841 commit 9694e60

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lsp-ivy.el

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@
112112

113113

114114
(defun lsp-ivy--format-symbol-match (match)
115-
"Convert the (hash-valued) MATCH returned by `lsp-mode` into a candidate string."
116-
(let* ((container-name (gethash "containerName" match))
115+
"Convert the MATCH returned by `lsp-mode` into a candidate string.
116+
MATCH is a cons cell whose cdr is the hash-table from `lsp-mode`."
117+
(let* ((match (cdr match))
118+
(container-name (gethash "containerName" match))
117119
(name (gethash "name" match))
118120
(type (elt lsp-ivy-symbol-kind-to-face (gethash "kind" match) ))
119121
(typestr (if lsp-ivy-show-symbol-kind
@@ -124,8 +126,9 @@
124126
(format "%s.%s" container-name name)))))
125127

126128
(defun lsp-ivy--workspace-symbol-action (candidate)
127-
"Jump to selected CANDIDATE."
128-
(-let* (((&hash "uri" "range" (&hash "start" (&hash "line" "character")))
129+
"Jump to selected CANDIDATE, a cons cell whose cdr is a hash table."
130+
(-let* ((candidate (cdr candidate))
131+
((&hash "uri" "range" (&hash "start" (&hash "line" "character")))
129132
(gethash "location" candidate)))
130133
(find-file (lsp--uri-to-path uri))
131134
(goto-char (point-min))
@@ -145,7 +148,11 @@
145148
"workspace/symbol"
146149
(list :query user-input)
147150
(lambda (result)
148-
(ivy-update-candidates (-remove 'lsp-ivy--filter-func result)))
151+
(ivy-update-candidates
152+
(mapcar
153+
(lambda (data)
154+
(cons (gethash "name" data) data))
155+
(-remove 'lsp-ivy--filter-func result))))
149156
:mode 'detached
150157
:cancel-token :workspace-symbol))
151158
0)

0 commit comments

Comments
 (0)