parent
dfab5b941f
commit
7472cffadd
1 changed files with 17 additions and 13 deletions
|
@ -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")
|
||||||
(save-restriction
|
(if (and (bound-and-true-p lsp-mode)
|
||||||
(narrow-to-region beg end)
|
(lsp-feature? "textDocument/rangeFormatting"))
|
||||||
(let ((+format-region-p t))
|
#'lsp-format-region
|
||||||
(+format/buffer))))
|
(save-restriction
|
||||||
|
(narrow-to-region beg end)
|
||||||
|
(let ((+format-region-p t))
|
||||||
|
(+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))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue