Fix #5128: No format-on-save by lsp-formatters
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.
This commit is contained in:
parent
2731685095
commit
012b759e98
1 changed files with 9 additions and 7 deletions
|
@ -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)
|
||||||
|
(eq formatter 'eglot)
|
||||||
|
(condition-case-unless-debug e
|
||||||
(format-all--formatter-executable formatter)
|
(format-all--formatter-executable formatter)
|
||||||
(error
|
(error
|
||||||
(message "Warning: cannot reformat buffer because %S isn't installed"
|
(message "Warning: cannot reformat buffer because %S isn't installed"
|
||||||
(gethash formatter format-all--executable-table))
|
(gethash formatter format-all--executable-table))
|
||||||
nil))
|
nil)))
|
||||||
(funcall format-all-buffer--with formatter mode-result)))
|
(funcall format-all-buffer--with formatter mode-result)))
|
||||||
(apply orig-fn args)))
|
(apply orig-fn args)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue