1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
local null_ls = require("null-ls")
local helpers = require("null-ls.helpers")
local blacklint = {
method = null_ls.methods.DIAGNOSTICS,
filetypes = { "python" },
-- null_ls.generator creates an async source
-- that spawns the command with the given arguments and options
generator = null_ls.generator({
command = "black",
args = { "--stdin" },
to_stdin = true,
from_stderr = true,
-- choose an output format (raw, json, or line)
format = "line",
check_exit_code = function(code)
return code <= 1
end,
-- use helpers to parse the output from string matchers,
-- or parse it manually with a function
on_output = helpers.diagnostics.from_patterns({
{
pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]],
groups = { "row", "col", "message" },
},
{
pattern = [[:(%d+) [%w-/]+ (.*)]],
groups = { "row", "message" },
},
}),
}),
}
null_ls.register(blacklint)
|