(defun lsp--completing-read (prompt collection transform-fn &optional predicate
require-match initial-input
hist def inherit-input-method)
"Wrap `completing-read' to provide tranformation function.
TRANSFORM-FN will be used to transform each of the items before displaying.
PROMPT COLLECTION PREDICATE REQUIRE-MATCH INITIAL-INPUT HIST DEF
INHERIT-INPUT-METHOD will be proxied to `completing-read' without changes."
(let* ((result (--map (cons (funcall transform-fn it) it) collection))
(completion (completing-read prompt (-map 'cl-first result)
predicate require-match initial-input hist
def inherit-input-method)))
(cdr (assoc completion result))))
I am author of that code - the proper solution is to create a ivy/helm wrappers which support multiple selection. There is completing-read-multiple in emacs but IMO it is even more inconvenient to use so I decided to do that wrapper over completing-read which for that particular usecase is very hard to use. Feel free to file a lsp-java PR so we could work on improving that piece of code. I will implement the helm wrapper at lsp-helm project since I am primary a helm user. I guess someone could port the method to ivy as well.
Edit: it seems like helm/ivy do have implementation of completing-read-multiple, I will try it first.
I thought about that but it does not work on helm since when you have initial selection in it hides the rest of the items… You may try to delete this function and use completing-read-multiple which ivy actually overrides. But still it does not allow default selection…
I try this on helm, it seems like it’s work normally. Furthermore, helm has a bit of benefit than ivy, the order of the candidates doesn’t have change when you selected.
@Cireulsp--completing-read is already doing that under the hood(e. g. when helm mode is enabled it replaces the completing-read function). I guess you are talking about lsp-java--completing-read-multiple? I am not 100% sure whether I understand what you mean by generic but something simple like this: