Skip to content

Commit 6b5ce18

Browse files
committed
Fixes #5
1 parent db24399 commit 6b5ce18

File tree

1 file changed

+61
-58
lines changed

1 file changed

+61
-58
lines changed

helm-lsp.el

Lines changed: 61 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -76,71 +76,74 @@ CANDIDATE is the selected item in the helm menu."
7676
"Search against WORKSPACES NAME with default INPUT."
7777
(setq helm-lsp-symbols-result nil)
7878
(if workspaces
79-
(helm
80-
:sources (helm-build-sync-source name
81-
:candidates (lambda ()
82-
(if helm-lsp-symbols-result-p
83-
helm-lsp-symbols-result
84-
(with-lsp-workspaces workspaces
85-
(-let (((request &as &plist :id request-id) (lsp-make-request
86-
"workspace/symbol"
87-
(list :query helm-pattern))))
88-
;; cancel if there is pending request
89-
(when helm-lsp-symbols-request-id
90-
(lsp--cancel-request helm-lsp-symbols-request-id)
91-
(setq helm-lsp-symbols-request-id nil))
92-
93-
(setq helm-lsp-symbols-request-id request-id)
94-
(lsp-send-request-async
95-
request
96-
(lambda (candidates)
97-
(setq helm-lsp-symbols-request-id nil)
98-
(and helm-alive-p
99-
(let ((helm-lsp-symbols-result-p t))
100-
(setq helm-lsp-symbols-result candidates)
101-
(helm-update))))
102-
'detached)
103-
helm-lsp-symbols-result))))
104-
:action 'helm-lsp-workspace-symbol-action
105-
:volatile t
106-
:fuzzy-match t
107-
:match (-const t)
108-
:keymap helm-map
109-
:candidate-transformer
110-
(lambda (candidates)
111-
(-map
112-
(-lambda ((candidate &as
113-
&hash "containerName" container-name
114-
"name" "kind"))
115-
(let ((type (or (alist-get kind lsp--symbol-kind) "Unknown")))
116-
(cons
117-
(if (and (featurep 'lsp-treemacs)
118-
helm-lsp-treemacs-icons)
119-
(concat
120-
(or (helm-lsp--get-icon kind)
121-
(helm-lsp--get-icon 'fallback))
122-
(if (s-blank? container-name)
123-
name
124-
(concat name " " (propertize container-name 'face 'helm-lsp-container-face))))
125-
126-
(concat (if (s-blank? container-name)
127-
name
128-
(concat name " " (propertize container-name 'face 'helm-lsp-container-face) " -" ))
129-
" "
130-
(propertize (concat "(" type ")") 'face 'font-lock-type-face)))
131-
candidate)))
132-
candidates))
133-
:candidate-number-limit nil
134-
:requires-pattern 0)
135-
:input input)
79+
(with-lsp-workspaces workspaces
80+
(helm
81+
:sources (helm-build-sync-source name
82+
:candidates (lambda ()
83+
(if helm-lsp-symbols-result-p
84+
helm-lsp-symbols-result
85+
(with-lsp-workspaces workspaces
86+
(-let (((request &as &plist :id request-id) (lsp-make-request
87+
"workspace/symbol"
88+
(list :query helm-pattern))))
89+
;; cancel if there is pending request
90+
(when helm-lsp-symbols-request-id
91+
(lsp--cancel-request helm-lsp-symbols-request-id)
92+
(setq helm-lsp-symbols-request-id nil))
93+
94+
(setq helm-lsp-symbols-request-id request-id)
95+
(lsp-send-request-async
96+
request
97+
(lambda (candidates)
98+
(setq helm-lsp-symbols-request-id nil)
99+
(and helm-alive-p
100+
(let ((helm-lsp-symbols-result-p t))
101+
(setq helm-lsp-symbols-result candidates)
102+
(helm-update))))
103+
'detached)
104+
helm-lsp-symbols-result))))
105+
:action 'helm-lsp-workspace-symbol-action
106+
:volatile t
107+
:fuzzy-match t
108+
:match (-const t)
109+
:keymap helm-map
110+
:candidate-transformer
111+
(lambda (candidates)
112+
(-map
113+
(-lambda ((candidate &as
114+
&hash "containerName" container-name
115+
"name" "kind"))
116+
(let ((type (or (alist-get kind lsp--symbol-kind) "Unknown")))
117+
(cons
118+
(if (and (featurep 'lsp-treemacs)
119+
helm-lsp-treemacs-icons)
120+
(concat
121+
(or (helm-lsp--get-icon kind)
122+
(helm-lsp--get-icon 'fallback))
123+
(if (s-blank? container-name)
124+
name
125+
(concat name " " (propertize container-name 'face 'helm-lsp-container-face))))
126+
127+
(concat (if (s-blank? container-name)
128+
name
129+
(concat name " " (propertize container-name 'face 'helm-lsp-container-face) " -" ))
130+
" "
131+
(propertize (concat "(" type ")") 'face 'font-lock-type-face)))
132+
candidate)))
133+
candidates))
134+
:candidate-number-limit nil
135+
:requires-pattern 0)
136+
:input input))
136137
(user-error "No LSP workspace active")))
137138

138139
;;;###autoload
139140
(defun helm-lsp-workspace-symbol (arg)
140141
"`helm' for lsp workspace/symbol.
141142
When called with prefix ARG the default selection will be symbol at point."
142143
(interactive "P")
143-
(helm-lsp--workspace-symbol (lsp-workspaces)
144+
(helm-lsp--workspace-symbol (or (lsp-workspaces)
145+
(gethash (lsp-workspace-root default-directory)
146+
(lsp-session-folder->servers (lsp-session))))
144147
"Workspace symbol"
145148
(when arg (thing-at-point 'symbol))))
146149

0 commit comments

Comments
 (0)