local null_ls = require("null-ls") local sources = { -- -- prettier - using perttierd instead -- null_ls.builtins.formatting.prettier.with({ -- extra_filetypes = { "php" }, -- prefer_local = "node_modules/.bin", -- }), -- -- prettierd with php -- null_ls.builtins.formatting.prettierd.with({ -- extra_filetypes = { "php" }, -- }), -- prettierd without php (use phpcbf instead) null_ls.builtins.formatting.prettierd, -- phpcs - standards wordpress null_ls.builtins.diagnostics.phpcs.with({ condition = function(utils) return utils.root_has_file({ "vendor/bin/phpcs" }) end, command = "vendor/bin/phpcs", args = { "--standard=WordPress", "--report=json", "-s", "-" }, }), -- phpcbf - standards wordpress null_ls.builtins.formatting.phpcbf.with({ condition = function(utils) return utils.root_has_file({ "vendor/bin/phpcbf" }) end, command = "vendor/bin/phpcbf", args = { "--standard=WordPress", "-" }, }), -- phpcs null_ls.builtins.diagnostics.phpcs.with({ condition = function(utils) return not utils.root_has_file({ "vendor/bin/phpcs" }) end, }), -- phpcbf null_ls.builtins.formatting.phpcbf.with({ condition = function(utils) return not utils.root_has_file({ "vendor/bin/phpcbf" }) end, }), -- black null_ls.builtins.formatting.black, -- shellcheck, null_ls.builtins.diagnostics.shellcheck, -- flake8 null_ls.builtins.diagnostics.flake8, -- luaFormatter null_ls.builtins.formatting.lua_format, } null_ls.setup({ sources = sources, on_attach = function(client) if client.resolved_capabilities.document_formatting then vim.cmd([[ augroup lsp_formatting autocmd! * autocmd BufWritePre :lua vim.lsp.buf.formatting_seq_sync({}, 3000) augroup END ]]) end end, })