33
33
34
34
(require 'ivy )
35
35
(require 'dash )
36
+
37
+ (require 'lsp-protocol )
36
38
(require 'lsp-mode )
37
39
38
40
(defgroup lsp-ivy nil
111
113
(cons string face)))
112
114
113
115
114
- (defun lsp-ivy--format-symbol-match (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 ))
119
- (name (gethash " name" match ))
120
- (type (elt lsp-ivy-symbol-kind-to-face (gethash " kind" match ) ))
121
- (typestr (if lsp-ivy-show-symbol-kind
122
- (propertize (format " [%s ] " (car type)) 'face (cdr type))
123
- " " )))
124
- (concat typestr (if (or (null container-name) (string-empty-p container-name))
116
+ (defun lsp-ivy--format-symbol-match (symbol-information-match )
117
+ " Convert the match returned by `lsp-mode` into a candidate string.
118
+ SYMBOL-INFORMATION-MATCH is a cons cell whose cdr is the hash-table from `lsp-mode`."
119
+ (-let* (((&SymbolInformation :name :kind :container-name? ) (cdr symbol-information-match))
120
+ (type (elt lsp-ivy-symbol-kind-to-face kind))
121
+ (typestr (if lsp-ivy-show-symbol-kind
122
+ (propertize (format " [%s ] " (car type)) 'face (cdr type))
123
+ " " )))
124
+ (concat typestr (if (or (null container-name?) (string-empty-p container-name?) )
125
125
(format " %s " name)
126
- (format " %s .%s " container-name name)))))
127
-
128
- (defun lsp-ivy--workspace-symbol-action (candidate )
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" )))
132
- (gethash " location" candidate)))
126
+ (format " %s .%s " container-name? name)))))
127
+
128
+ (defun lsp-ivy--workspace-symbol-action (symbol-information-candidate )
129
+ " Jump to selected SYMBOL-INFORMATION-CANDIDATE, a cons cell whose cdr is a hash table."
130
+ (-let (((&SymbolInformation :location
131
+ (&Location :uri
132
+ :range
133
+ (&Range :start
134
+ (&Position :line :character ))))
135
+ (cdr symbol-information-candidate)))
133
136
(find-file (lsp--uri-to-path uri))
134
137
(goto-char (point-min ))
135
138
(forward-line line)
136
139
(forward-char character)))
137
140
138
- (defun lsp-ivy--filter-func (candidate )
139
- " Filter CANDIDATE kind from symbol kinds."
140
- (member ( gethash " kind" candidate) lsp-ivy-filter-symbol-kind))
141
+ (lsp- defun lsp-ivy--filter-func ((&SymbolInformation :kind ) )
142
+ " Filter candidate kind from symbol kinds."
143
+ (member kind lsp-ivy-filter-symbol-kind))
141
144
142
145
(defun lsp-ivy--workspace-symbol (workspaces prompt initial-input )
143
146
" Search against WORKSPACES with PROMPT and INITIAL-INPUT."
@@ -147,13 +150,13 @@ MATCH is a cons cell whose cdr is the hash-table from `lsp-mode`."
147
150
(with-lsp-workspaces workspaces
148
151
(lsp-request-async
149
152
" workspace/symbol"
150
- (list :query user-input)
153
+ (lsp-make-workspace-symbol-params :query user-input)
151
154
(lambda (result )
152
155
(ivy-update-candidates
153
156
(mapcar
154
- (lambda (data )
155
- (cons ( gethash " name" data) data ))
156
- (-remove 'lsp-ivy--filter-func result))))
157
+ (- lambda ((symbol-information &as &SymbolInformation :name ) )
158
+ (cons name symbol-information ))
159
+ (-remove # 'lsp-ivy--filter-func result))))
157
160
:mode 'detached
158
161
:cancel-token :workspace-symbol ))
159
162
0 )
0 commit comments