aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorMohsin Kaleem <mohkale@kisara.moe>2021-12-27 18:00:21 +0000
committerGitHub <noreply@github.com>2021-12-27 10:00:21 -0800
commit2e9816513789c233acc79493523a7e1aa5b3eeb6 (patch)
tree26f43ff2238443e4dfc0e2dfb7c85cecb6023d1e /README.md
parente700c78a5db4ea9599b2d04bbc8e4c40ce822c37 (diff)
[#62] Support functions as formatters (#63)
* [#62] Support functions as formatters Closes #62. Lets you use a lisp function as a formatter. This gives apheleia a lot more flexibility in regards to what constitutes a formatter. For example you can now plug an external language server or another tool as a formatter for use with apheleia. Here's a very basic example of using indent-line-function with apheleia after merging this commit. Note: this doesn't take into account any special local variables in the original buffer such as lisp-body-indent. It's really just for demonstration purposes and as a proof of concept. ```lisp (defun apheleia-indent-region+ (orig scratch callback) (with-current-buffer scratch (setq-local indent-line-function (buffer-local-value 'indent-line-function orig)) (indent-region (point-min) (point-max)) (funcall callback scratch))) (push '(indent-region . apheleia-indent-region+) apheleia-formatters) (push '(elisp-mode . indent-region) apheleia-mode-alist) (push '(lisp-interaction-mode . indent-region) apheleia-mode-alist) ``` * Fix misc-bugs + prevent race conditions * Update docstring * Reword a bit * Add to README Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
Diffstat (limited to 'README.md')
-rw-r--r--README.md5
1 files changed, 5 insertions, 0 deletions
diff --git a/README.md b/README.md
index 00fa7f1..be22b9f 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,11 @@ variables:
example a buffer called `*foo-bar.c*` that has no associated
file will have an implicit file-name of `foo-bar.c` and any
temporary files will be suffixed with a `.c` extension.
+ * You can implement formatters as arbitrary Elisp functions which
+ operate directly on a buffer, without needing to invoke an
+ external command. This can be useful to integrate with e.g.
+ language servers. See the docstring for more information on the
+ expected interface for Elisp formatters.
* `apheleia-mode-alist`: Alist mapping major modes and filename
regexps to names of formatters to use in those modes and files. See
the docstring for more information.