fix(format): apheleia doesn't invoke lsp formatter

change `+format--lsp-fn` to run `+format--lsp-fn` in context of main
buffer rather than apheleia's scratch buffer so that the lsp mode can
be discovered
This commit is contained in:
Eloise Christian 2024-07-08 21:18:49 -04:00 committed by Henrik Lissner
parent af2b1a62dc
commit 081231b73f

View file

@ -44,9 +44,9 @@ mode unconditionally, call `+format-with-lsp-mode' instead."
;;; Apheleia formatters
;;;###autoload
(cl-defun +format-lsp-buffer (&rest plist &key callback &allow-other-keys)
(cl-defun +format-lsp-buffer (&rest plist &key buffer callback &allow-other-keys)
"Format the current buffer with any available lsp-mode or eglot formatter."
(if-let* ((fn (+format--lsp-fn))
(if-let* ((fn (with-current-buffer buffer (+format--lsp-fn)))
((apply fn plist)))
(funcall callback)
(funcall callback "LSP server doesn't support formatting")))