nvim-kickstart/lua/custom/none-ls.lua

43 lines
1.2 KiB
Lua

local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.phpcbf.with({
command = "phpcbf", -- or full path if not in PATH
extra_args = { "--standard=PSR12", "--standard=phpcs.xml" },
}),
null_ls.builtins.diagnostics.phpstan.with({
command = "phpstan",
args = {
"analyse",
"--error-format", "raw",
"--no-progress",
"$FILENAME", -- or your project's entrypoint folder
},
method = null_ls.methods.DIAGNOSTICS_ON_SAVE, -- or ON_OPEN or BOTH
condition = function(utils)
return utils.root_has_file({ "phpstan.neon", "phpstan.neon.dist" })
end,
}),
null_ls.builtins.diagnostics.phpcs.with({
command = "phpcs", -- or "vendor/bin/phpcs" if local
args = {
"--standard=PSR12", -- or "phpcs.xml", "phpcs.xml.dist", etc.
"-s", -- show sniff codes
"-q", -- suppress warnings
"--report=emacs",
"--stdin-path", "$FILENAME",
"-"
},
condition = function(utils)
return utils.root_has_file({ "phpcs.xml", "phpcs.xml.dist" }) or true
end,
}),
null_ls.builtins.formatting.phpcsfixer.with({
command = "php-cs-fixer",
-- no extra_args needed if config file is correctly named and in root
}),
},
on_attach = on_attach,
})