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)
:around #'format-all-buffer--from-hook
(letf! (defun format-all-buffer--with (formatter mode-result)
(and (condition-case-unless-debug e
(format-all--formatter-executable formatter)
(error
(message "Warning: cannot reformat buffer because %S isn't installed"
(gethash formatter format-all--executable-table))
nil))
(funcall format-all-buffer--with formatter mode-result)))
(when (or (eq formatter 'lsp)
(eq formatter 'eglot)
(condition-case-unless-debug e
(format-all--formatter-executable formatter)
(error
(message "Warning: cannot reformat buffer because %S isn't installed"
(gethash formatter format-all--executable-table))
nil)))
(funcall format-all-buffer--with formatter mode-result)))
(apply orig-fn args)))