A workaround for formatting org mode

If point is in a source block, format that source block.
Else don't try to format the buffer. format-all-buffer does not support
org mode.
This commit is contained in:
Sam Whitlock 2020-12-13 15:36:56 +01:00
parent 2e61fbbf08
commit 99a83ca18f

View file

@ -225,9 +225,9 @@ If nil, BEG and/or END will default to the boundaries of the src block at point.
(defun +format/buffer ()
"Reformat the current buffer using LSP or `format-all-buffer'."
(interactive)
(if (and (eq major-mode 'org-mode)
(org-in-src-block-p t))
(+format--org-region nil nil)
(if (eq major-mode 'org-mode)
(when (org-in-src-block-p t)
(+format--org-region nil nil))
(call-interactively
(cond ((and +format-with-lsp
(bound-and-true-p lsp-mode)