Skip to content

Commit 07b3369

Browse files
committed
builtins: add condition for sources that needs a config file (#152)
1 parent f1b438a commit 07b3369

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ return h.make_builtin({
1919
"--best-effort",
2020
},
2121
to_stdin = true,
22+
-- cbfmt requires a config file
23+
condition = function(utils)
24+
return utils.root_has_file(".cbfmt.toml")
25+
end,
2226
},
2327
factory = h.formatter_factory,
2428
})

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

+4-9
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@ return h.make_builtin({
88
meta = {
99
url = "https://github.com/numtide/treefmt",
1010
description = "One CLI to format your repo",
11-
usage = [[
12-
local sources = {
13-
null_ls.builtins.formatting.treefmt.with({
14-
-- treefmt requires a config file
15-
condition = function(utils)
16-
return utils.root_has_file("treefmt.toml")
17-
end,
18-
}),
19-
}]],
2011
},
2112
method = FORMATTING,
2213
filetypes = {},
2314
generator_opts = {
2415
command = "treefmt",
2516
args = { "--allow-missing-formatter", "--stdin", "$FILENAME" },
2617
to_stdin = true,
18+
-- treefmt requires a config file
19+
condition = function(utils)
20+
return utils.root_has_file("treefmt.toml")
21+
end,
2722
},
2823
factory = h.formatter_factory,
2924
})

0 commit comments

Comments
 (0)