aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAron Griffis <aron@scampersand.com>2023-10-17 10:54:51 -0400
committerGitHub <noreply@github.com>2023-10-17 07:54:51 -0700
commit280055248661a4fc7b692db2d5ee80a465ebb577 (patch)
tree5680580c21936a556e4159487cf141de493b7f86
parent1281e26948fc06994e0e0cdcaafdd9bbd28929e7 (diff)
feat: zprint formatter for clojure (#146)
-rw-r--r--README.md1
-rw-r--r--lua/conform/formatters/zprint.lua17
2 files changed, 18 insertions, 0 deletions
diff --git a/README.md b/README.md
index baea89d..bd535f0 100644
--- a/README.md
+++ b/README.md
@@ -263,6 +263,7 @@ You can view this list in vim with `:help conform-formatters`
- [yamlfmt](https://github.com/google/yamlfmt) - yamlfmt is an extensible command line tool or library to format yaml files.
- [yapf](https://github.com/google/yapf) - Yet Another Python Formatter.
- [zigfmt](https://github.com/ziglang/zig) - Reformat Zig source into canonical form.
+- [zprint](https://github.com/kkinnear/zprint) - Highly configurable formatter for Clojure and EDN.
<!-- /FORMATTERS -->
</details>
diff --git a/lua/conform/formatters/zprint.lua b/lua/conform/formatters/zprint.lua
new file mode 100644
index 0000000..935a485
--- /dev/null
+++ b/lua/conform/formatters/zprint.lua
@@ -0,0 +1,17 @@
+---@type conform.FileFormatterConfig
+return {
+ meta = {
+ url = "https://github.com/kkinnear/zprint",
+ description = "Formatter for Clojure and EDN.",
+ },
+ command = "zprint",
+ range_args = function(ctx)
+ return {
+ string.format(
+ "{:input {:range {:start %d :end %d :use-previous-!zprint? true :continue-after-!zprint-error? true}}}",
+ ctx.range.start[1] - 1,
+ ctx.range["end"][1] - 1
+ ),
+ }
+ end,
+}