Rafael Cano
Rafael Cano

Reputation: 11

How can I configure phpcbf or phpcsfixer in Neovim using null-ls to indent code using 2 spaces?

I have read the documentation from both formatters and have tried different configurations using various coding styles with different arguments with no success. Here's a code snippet of how my configuration currently stands.

local present, null_ls = pcall(require, "null-ls")

if not present then
    return
end

local b = null_ls.builtins

local sources = {
    --php
    b.formatting.phpcbf.with({
        extra_args = { "--tab-width=2" },
    }),
    -- b.formatting.phpcsfixer.with {
    --   args = { "--no-interaction", "--quiet", "fix", "$FILENAME", "--using-cache=no" },
    -- },
    b.formatting.blade_formatter,
}

null_ls.setup({
    debug = true,
    sources = sources,
})

Upvotes: 1

Views: 1040

Answers (1)

kuba
kuba

Reputation: 3870

To achieve that in PHP CS Fixer you need to create config file, where you will be able to configure whitespaces. Theres, simply pass 2 spaces with setIndent method.

Upvotes: 1

Related Questions