LSP mode format + organize import? #205
-
Hi! I'm currently following the method suggested by #120, for enabling Using the same idea, I'm writing these for organize import (cl-defun apheleia-lsp-organize-import-formatter (&key buffer scratch callback stdin &allow-other-keys)
(with-current-buffer buffer
(when (lsp-feature? "textDocument/codeAction")
(if-let ((action (->> (lsp-get-or-calculate-code-actions "source.organizeImports")
(-filter (-lambda ((&CodeAction :kind?))
(and kind? (s-prefix? "source.organizeImports" kind?))))
lsp--select-action)))
(with-current-buffer scratch
(lsp-execute-code-action action)))))
(funcall callback)) Now, when I use them separately, both performs their own job successfully. But, when I tried to combine them, only one of them runs. Is there anything I miss? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Is it possible that Looking at https://github.com/emacs-lsp/lsp-mode/blob/c9db552dcef80c481ecca6bf53c86a12f2a9cd55/lsp-mode.el#L4260, this seems like it might be the case. |
Beta Was this translation helpful? Give feedback.
Hey, sorry for just responding to this.
I decided to use another method previously since its available, and currently I'm stuck in the situation where I need this and decided to dig deeper.
Thanks for your pointer, I have working solution right now! Here's the snippet.