mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
@ -198,7 +198,14 @@ See `+format/buffer' for the interactive version of this function, and
|
|||||||
;;; Commands
|
;;; Commands
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defalias '+format/buffer #'format-all-buffer)
|
(defun +format/buffer ()
|
||||||
|
"Reformat the current buffer using LSP or `format-all-buffer'."
|
||||||
|
(interactive)
|
||||||
|
(call-interactively
|
||||||
|
(if (and (bound-and-true-p lsp-mode)
|
||||||
|
(lsp-feature? "textDocument/formatting"))
|
||||||
|
#'lsp-format-buffer
|
||||||
|
#'format-all-buffer)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +format/region (beg end)
|
(defun +format/region (beg end)
|
||||||
@ -208,10 +215,13 @@ WARNING: this may not work everywhere. It will throw errors if the region
|
|||||||
contains a syntax error in isolation. It is mostly useful for formatting
|
contains a syntax error in isolation. It is mostly useful for formatting
|
||||||
snippets or single lines."
|
snippets or single lines."
|
||||||
(interactive "rP")
|
(interactive "rP")
|
||||||
|
(if (and (bound-and-true-p lsp-mode)
|
||||||
|
(lsp-feature? "textDocument/rangeFormatting"))
|
||||||
|
#'lsp-format-region
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(narrow-to-region beg end)
|
(narrow-to-region beg end)
|
||||||
(let ((+format-region-p t))
|
(let ((+format-region-p t))
|
||||||
(+format/buffer))))
|
(+format/buffer)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +format/region-or-buffer ()
|
(defun +format/region-or-buffer ()
|
||||||
@ -220,14 +230,8 @@ is selected)."
|
|||||||
(interactive)
|
(interactive)
|
||||||
(call-interactively
|
(call-interactively
|
||||||
(if (doom-region-active-p)
|
(if (doom-region-active-p)
|
||||||
(if (and (bound-and-true-p lsp-mode)
|
#'+format/region
|
||||||
(lsp-feature? "textDocument/rangeFormatting"))
|
#'+format/buffer)))
|
||||||
#'lsp-format-region
|
|
||||||
#'+format/region)
|
|
||||||
(if (and (bound-and-true-p lsp-mode)
|
|
||||||
(lsp-feature? "textDocument/formatting"))
|
|
||||||
#'lsp-format-buffer
|
|
||||||
#'+format/buffer))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
Reference in New Issue
Block a user