47
47
:group 'lsp-ivy
48
48
:type 'boolean )
49
49
50
+ (defcustom lsp-ivy-show-symbol-filename
51
+ t
52
+ " Whether to show the project-relative path to a symbol's point of definition."
53
+ :group 'lsp-ivy
54
+ :type 'boolean )
55
+
50
56
(defcustom lsp-ivy-filter-symbol-kind
51
57
nil
52
58
" A list of LSP SymbolKind's to filter out."
127
133
(forward-line line)
128
134
(forward-char character))
129
135
130
- (defun lsp-ivy--format-symbol-match (symbol-information )
131
- " Convert the match returned by `lsp-mode` into a candidate string.
132
- SYMBOL-INFORMATION is a SymbolInformation object from `lsp-mode`."
133
- (-let* (((&SymbolInformation :name :kind :container-name? ) symbol-information)
134
- (type (elt lsp-ivy-symbol-kind-to-face kind))
135
- (typestr (if lsp-ivy-show-symbol-kind
136
- (propertize (format " [%s ] " (car type)) 'face (cdr type))
137
- " " )))
136
+ (lsp-defun lsp-ivy--format-symbol-match
137
+ ((&SymbolInformation :name :kind :container-name? :location (&Location :uri ))
138
+ project-root)
139
+ " Convert the match returned by `lsp-mode` into a candidate string."
140
+ (let* ((type (elt lsp-ivy-symbol-kind-to-face kind))
141
+ (typestr (if lsp-ivy-show-symbol-kind
142
+ (propertize (format " [%s ] " (car type)) 'face (cdr type))
143
+ " " ))
144
+ (pathstr (if lsp-ivy-show-symbol-filename
145
+ (propertize (format " · %s " (file-relative-name (lsp--uri-to-path uri) project-root))
146
+ 'face font-lock-comment-face ) " " )))
138
147
(concat typestr (if (or (null container-name?) (string-empty-p container-name?) )
139
148
(format " %s " name)
140
- (format " %s .%s " container-name? name)))))
149
+ (format " %s .%s " container-name? name)) pathstr )))
141
150
142
151
(lsp-defun lsp-ivy--transform-candidate ((symbol-information &as &SymbolInformation :kind )
143
- filter-regexps?)
152
+ filter-regexps? workspace-root )
144
153
" Map candidate to nil if it should be excluded based on `lsp-ivy-filter-symbol-kind' or
145
154
FILTER-REGEXPS?, otherwise convert it to an `lsp-ivy:FormattedSymbolInformation' object."
146
155
(unless (member kind lsp-ivy-filter-symbol-kind)
147
- (let ((textual-representation (lsp-ivy--format-symbol-match symbol-information)))
156
+ (let ((textual-representation
157
+ (lsp-ivy--format-symbol-match symbol-information workspace-root)))
148
158
(when (--all? (string-match-p it textual-representation) filter-regexps?)
149
159
(lsp-put symbol-information :textualRepresentation textual-representation)
150
160
symbol-information))))
@@ -154,10 +164,11 @@ FILTER-REGEXPS?, otherwise convert it to an `lsp-ivy:FormattedSymbolInformation'
154
164
(let* ((prev-query nil )
155
165
(unfiltered-candidates '())
156
166
(filtered-candidates nil )
167
+ (workspace-root (lsp-workspace-root))
157
168
(update-candidates
158
169
(lambda (all-candidates filter-regexps? )
159
170
(setq filtered-candidates
160
- (--keep (lsp-ivy--transform-candidate it filter-regexps?)
171
+ (--keep (lsp-ivy--transform-candidate it filter-regexps? workspace-root )
161
172
all-candidates))
162
173
(ivy-update-candidates filtered-candidates))))
163
174
(ivy-read
0 commit comments