Skip to content

Commit

Permalink
Fix doomemacs#5128: No format-on-save by lsp-formatters
Browse files Browse the repository at this point in the history
A call to `format-all--formatter-executable` with the formatter being
equal to `'lsp` or `'eglot` will return `nil`. Therefore, `funcall` was
never called in those cases.
  • Loading branch information
RBckmnn committed Jun 14, 2021
1 parent 2731685 commit 012b759
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/editor/format/config.el
Expand Up @@ -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)))

0 comments on commit 012b759

Please sign in to comment.