parent
20de3d0f29
commit
e9ea3cc591
2 changed files with 19 additions and 1 deletions
|
@ -107,6 +107,23 @@ the requested feature."
|
||||||
#'lsp-format-region))
|
#'lsp-format-region))
|
||||||
t))
|
t))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +format-with-eglot-fn (beg end op)
|
||||||
|
"Format the region/buffer using any available eglot formatter.
|
||||||
|
|
||||||
|
Does nothing if `+format-with-lsp' is nil or the active server doesn't support
|
||||||
|
the requested feature."
|
||||||
|
(when (and +format-with-lsp
|
||||||
|
(bound-and-true-p eglot-managed-mode)
|
||||||
|
(eglot--server-capable
|
||||||
|
(if (eq op 'buffer)
|
||||||
|
:documentFormattingProvider
|
||||||
|
:documentRangeFormattingProvider)))
|
||||||
|
(if (eq op 'buffer)
|
||||||
|
(eglot-format-buffer)
|
||||||
|
(eglot-format beg end))
|
||||||
|
t))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +format-in-org-src-blocks-fn (beg end _op)
|
(defun +format-in-org-src-blocks-fn (beg end _op)
|
||||||
"TODO"
|
"TODO"
|
||||||
|
|
|
@ -29,7 +29,8 @@ This has no effect on the +onsave flag, apheleia will always be used there.")
|
||||||
|
|
||||||
(defvar +format-functions
|
(defvar +format-functions
|
||||||
'(+format-in-org-src-blocks-fn
|
'(+format-in-org-src-blocks-fn
|
||||||
+format-with-lsp-fn)
|
+format-with-lsp-fn
|
||||||
|
+format-with-eglot-fn)
|
||||||
"A list of functions to run when formatting a buffer or region.
|
"A list of functions to run when formatting a buffer or region.
|
||||||
|
|
||||||
Each function is given three arguments: the starting point, end point, and a
|
Each function is given three arguments: the starting point, end point, and a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue