Skip to content

Commit 0463e58

Browse files
authored
fix(builtins/formatting/black): set the cwd according to the config files (#1603)
* fix(builtins/formatting/black): set the cwd according to the config files * fixup! fix(builtins/formatting/black): set the cwd according to the config files
1 parent 81bf131 commit 0463e58

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local h = require("null-ls.helpers")
2+
local u = require("null-ls.utils")
23
local methods = require("null-ls.methods")
34

45
local FORMATTING = methods.internal.FORMATTING
@@ -20,6 +21,12 @@ return h.make_builtin({
2021
"-",
2122
},
2223
to_stdin = true,
24+
cwd = h.cache.by_bufnr(function(params)
25+
return u.root_pattern(
26+
-- https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
27+
"pyproject.toml"
28+
)(params.bufname)
29+
end),
2330
},
2431
factory = h.formatter_factory,
2532
})

0 commit comments

Comments
 (0)