@@ -122,13 +122,7 @@ SymbolKind (defined in the LSP)."
122
122
(cons string face)
123
123
(cons string face)))
124
124
125
- (eval-when-compile
126
- (lsp-interface
127
- (lsp-ivy:FormattedSymbolInformation
128
- (:kind :name :location :textualRepresentation )
129
- (:containerName :deprecated ))))
130
-
131
- (lsp-defun lsp-ivy--workspace-symbol-action
125
+ (lsp-defun lsp-ivy--goto-symbol
132
126
((&SymbolInformation
133
127
:location (&Location :uri :range (&Range :start (&Position :line :character )))))
134
128
" Jump to selected candidate."
@@ -153,58 +147,47 @@ SymbolKind (defined in the LSP)."
153
147
154
148
(lsp-defun lsp-ivy--transform-candidate ((symbol-information &as &SymbolInformation :kind )
155
149
filter-regexps? workspace-root)
156
- " Map candidate to nil if it should be excluded based on `lsp-ivy-filter-symbol-kind' or
157
- FILTER-REGEXPS?, otherwise convert it to an `lsp-ivy:FormattedSymbolInformation' object."
150
+ " Map candidate to nil if it should be excluded based on
151
+ `lsp-ivy-filter-symbol-kind' or FILTER-REGEXPS?, otherwise convert it to a cons
152
+ of textual representation and the original candidate."
158
153
(unless (member kind lsp-ivy-filter-symbol-kind)
159
154
(let ((textual-representation
160
155
(lsp-ivy--format-symbol-match symbol-information workspace-root)))
161
156
(when (--all? (string-match-p it textual-representation) filter-regexps?)
162
- (lsp-put symbol-information :textualRepresentation textual-representation)
163
- symbol-information))))
157
+ (cons textual-representation symbol-information)))))
158
+
159
+ (lsp-defun lsp-ivy--workspace-symbol-action ((_ . sym))
160
+ " Jump to the `cdr' of INPUT0, an `&SymbolInformation' ."
161
+ (lsp-ivy--goto-symbol sym))
164
162
165
163
(defun lsp-ivy--workspace-symbol (workspaces prompt initial-input )
166
164
" Search against WORKSPACES with PROMPT and INITIAL-INPUT."
167
- (let* ((prev-query nil )
165
+ (let* ((non-essential t )
166
+ (prev-query nil )
168
167
(unfiltered-candidates '())
169
- (filtered-candidates nil )
170
- (workspace-root (lsp-workspace-root))
171
- (update-candidates
172
- (lambda (all-candidates filter-regexps? )
173
- (setq filtered-candidates
174
- (--keep (lsp-ivy--transform-candidate it filter-regexps? workspace-root)
175
- all-candidates))
176
- (ivy-update-candidates filtered-candidates))))
168
+ (workspace-root (lsp-workspace-root)))
177
169
(ivy-read
178
170
prompt
179
171
(lambda (user-input )
180
172
(let* ((parts (split-string user-input))
181
173
(query (or (car parts) " " ))
182
174
(filter-regexps? (mapcar #'regexp-quote (cdr parts))))
183
- (when query
184
- (if (string-equal prev-query query)
185
- (funcall update-candidates unfiltered-candidates filter-regexps?)
186
- (with-lsp-workspaces workspaces
187
- (lsp-request-async
188
- " workspace/symbol"
189
- (lsp-make-workspace-symbol-params :query query)
190
- (lambda (result )
191
- (setq unfiltered-candidates result)
192
- (funcall update-candidates unfiltered-candidates filter-regexps?) )
193
- :mode 'detached
194
- :cancel-token :workspace-symbol ))))
195
- (setq prev-query query))
196
- (or filtered-candidates 0 ))
175
+ (unless (string-equal prev-query query)
176
+ (setq unfiltered-candidates
177
+ (with-lsp-workspaces workspaces
178
+ (lsp-request-while-no-input
179
+ " workspace/symbol"
180
+ (lsp-make-workspace-symbol-params :query query)))))
181
+ (setq prev-query query)
182
+ (or (--keep (lsp-ivy--transform-candidate it filter-regexps? workspace-root)
183
+ unfiltered-candidates)
184
+ 0 )))
197
185
:dynamic-collection t
198
186
:require-match t
199
187
:initial-input initial-input
200
188
:action #'lsp-ivy--workspace-symbol-action
201
189
:caller 'lsp-ivy-workspace-symbol )))
202
190
203
- (ivy-configure 'lsp-ivy-workspace-symbol
204
- :display-transformer-fn
205
- (-lambda ((&lsp-ivy:FormattedSymbolInformation :textual-representation ))
206
- textual-representation))
207
-
208
191
;;;### autoload
209
192
(defun lsp-ivy-workspace-symbol (arg )
210
193
" `ivy' for lsp workspace/symbol.
0 commit comments