Merge pull request #5179 from RBckmnn/Fix#5128

Fix #5128: No format-on-save by lsp-formatters
This commit is contained in:
Henrik Lissner 2021-07-08 17:45:33 -04:00 committed by GitHub
commit bbd15a16ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,11 +74,13 @@ This is controlled by `+format-on-save-enabled-modes'."
(defadvice! +format--all-buffer-from-hook-a (orig-fn &rest args) (defadvice! +format--all-buffer-from-hook-a (orig-fn &rest args)
:around #'format-all-buffer--from-hook :around #'format-all-buffer--from-hook
(letf! (defun format-all-buffer--with (formatter mode-result) (letf! (defun format-all-buffer--with (formatter mode-result)
(and (condition-case-unless-debug e (when (or (eq formatter 'lsp)
(format-all--formatter-executable formatter) (eq formatter 'eglot)
(error (condition-case-unless-debug e
(message "Warning: cannot reformat buffer because %S isn't installed" (format-all--formatter-executable formatter)
(gethash formatter format-all--executable-table)) (error
nil)) (message "Warning: cannot reformat buffer because %S isn't installed"
(funcall format-all-buffer--with formatter mode-result))) (gethash formatter format-all--executable-table))
nil)))
(funcall format-all-buffer--with formatter mode-result)))
(apply orig-fn args))) (apply orig-fn args)))