Skip to content

Commit 9b81164

Browse files
feature: add cbfmt (#974)
1 parent 255b7c8 commit 9b81164

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

doc/BUILTINS.md

+17
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,23 @@ local sources = { null_ls.builtins.formatting.cabal_fmt }
19391939
- Method: `formatting`
19401940
- Command: `cabal-fmt`
19411941

1942+
### [cbfmt](https://github.com/lukas-reineke/cbfmt)
1943+
1944+
A tool to format codeblocks inside markdown and org documents.
1945+
1946+
#### Usage
1947+
1948+
```lua
1949+
local sources = { null_ls.builtins.formatting.cbfmt }
1950+
```
1951+
1952+
#### Defaults
1953+
1954+
- Filetypes: `{ "markdown", "org" }`
1955+
- Method: `formatting`
1956+
- Command: `cbfmt`
1957+
- Args: `{ "--stdin-filepath", "$FILENAME", "--best-effort" }`
1958+
19421959
### [clang_format](https://www.kernel.org/doc/html/latest/process/clang-format.html)
19431960

19441961
Tool to format C/C++/… code according to a set of rules and heuristics.

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ return {
205205
markdown = {
206206
code_actions = { "proselint" },
207207
diagnostics = { "alex", "markdownlint", "mdl", "proselint", "vale", "write_good" },
208-
formatting = { "markdownlint", "mdformat", "prettier", "prettier_d_slim", "prettierd", "remark", "terrafmt" },
208+
formatting = { "markdownlint", "mdformat", "prettier", "prettier_d_slim", "prettierd", "remark", "terrafmt", "cbfmt" },
209209
hover = { "dictionary" }
210210
},
211211
matlab = {
@@ -222,6 +222,9 @@ return {
222222
diagnostics = { "deadnix", "statix" },
223223
formatting = { "alejandra", "nixfmt", "nixpkgs_fmt" }
224224
},
225+
org = {
226+
formatting = { "cbfmt" }
227+
},
225228
pascal = {
226229
formatting = { "ptop" }
227230
},

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

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ return {
4343
cabal_fmt = {
4444
filetypes = { "cabal" }
4545
},
46+
cbfmt = {
47+
filetypes = { "markdown", "org" }
48+
},
4649
clang_format = {
4750
filetypes = { "c", "cpp", "cs", "java", "cuda" }
4851
},
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 = "cbfmt",
8+
meta = {
9+
url = "https://github.com/lukas-reineke/cbfmt",
10+
description = "A tool to format codeblocks inside markdown and org documents.",
11+
},
12+
method = FORMATTING,
13+
filetypes = { "markdown", "org" },
14+
generator_opts = {
15+
command = "cbfmt",
16+
args = {
17+
"--stdin-filepath",
18+
"$FILENAME",
19+
"--best-effort",
20+
},
21+
to_stdin = true,
22+
},
23+
factory = h.formatter_factory,
24+
})

0 commit comments

Comments
 (0)