Skip to content

Commit 75f7495

Browse files
authored
feat(builtins): Add cljfmt formatter for clojure code (#246)
1 parent 02f5275 commit 75f7495

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

doc/BUILTINS.md

+17
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,23 @@ local sources = { null_ls.builtins.formatting.clang_format }
22012201
- Command: `clang-format`
22022202
- Args: dynamically resolved (see [source](https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/formatting/clang_format.lua))
22032203

2204+
### [cljfmt](https://github.com/weavejester/cljfmt)
2205+
2206+
A tool for formatting Clojure code
2207+
2208+
#### Usage
2209+
2210+
```lua
2211+
local sources = { null_ls.builtins.formatting.cljfmt }
2212+
```
2213+
2214+
#### Defaults
2215+
2216+
- Filetypes: `{ "clojure" }`
2217+
- Method: `formatting`
2218+
- Command: `cljfmt`
2219+
- Args: `{ "fix", "-" }`
2220+
22042221
### [cljstyle](https://github.com/greglook/cljstyle)
22052222

22062223
Formatter for Clojure code.

doc/builtins.json

+5
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,11 @@
643643
"proto"
644644
]
645645
},
646+
"cljfmt": {
647+
"filetypes": [
648+
"clojure"
649+
]
650+
},
646651
"cljstyle": {
647652
"filetypes": [
648653
"clojure"

lua/null-ls/builtins/_meta/filetype_map.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ return {
7474
},
7575
clojure = {
7676
diagnostics = { "clj_kondo" },
77-
formatting = { "cljstyle", "zprint" }
77+
formatting = { "cljfmt", "cljstyle", "zprint" }
7878
},
7979
cmake = {
8080
diagnostics = { "cmake_lint" },

lua/null-ls/builtins/_meta/formatting.lua

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ return {
4646
clang_format = {
4747
filetypes = { "c", "cpp", "cs", "java", "cuda", "proto" }
4848
},
49+
cljfmt = {
50+
filetypes = { "clojure" }
51+
},
4952
cljstyle = {
5053
filetypes = { "clojure" }
5154
},
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
local h = require("null-ls.helpers")
2+
local methods = require("null-ls.methods")
3+
4+
local FORMATTING = methods.internal.FORMATTING
5+
6+
return h.make_builtin({
7+
name = "cljfmt",
8+
meta = {
9+
url = "https://github.com/weavejester/cljfmt",
10+
description = "A tool for formatting Clojure code",
11+
},
12+
method = FORMATTING,
13+
filetypes = { "clojure" },
14+
generator_opts = {
15+
command = "cljfmt",
16+
args = { "fix", "-" },
17+
to_stdin = true,
18+
},
19+
factory = h.formatter_factory,
20+
})

0 commit comments

Comments
 (0)