-- ┌                                               ┐
-- │            Formatting, diagnostics            │
-- └                                               ┘
return {
    "nvimtools/none-ls.nvim",
    dependencies = {
        "nvimtools/none-ls-extras.nvim",
    },
    event = { "BufReadPre", "BufNewFile" },
    config = function()
        local null_ls = require("null-ls")

        null_ls.setup({
            sources = {
                null_ls.builtins.formatting.stylua.with({
                    extra_args = {
                        '--indent-type',
                        'Spaces'
                    }
                }),
                null_ls.builtins.formatting.prettier.with({
                    filetypes = {
                        "css",
                        "scss",
                        "less",
                        "html",
                        "json",
                        "yaml",
                        "markdown",
                        "graphql",
                    },
                    extra_args = {
                        "--print-width",
                        "120",
                        "--tab-width",
                        "4",
                        "--bracket-spacing",
                        "true",
                        "--bracket-same-line",
                        "true",
                        "--arrow-parens",
                        "avoid",
                        "--jsx-single-quote",
                        "true",
                        "--trailing-comma",
                        "es5",
                        "--no-semi",
                        "false",
                        "--single-quote",
                        "true",
                        "--single-attribute-per-line",
                        "true",
                        "--bracket-same-line",
                        "true",
                        "--vue-indent-script-and-style",
                        "true",
                    },
                }),
                null_ls.builtins.formatting.shfmt,
                null_ls.builtins.formatting.phpcbf,
                null_ls.builtins.formatting.asmfmt,
                null_ls.builtins.code_actions.proselint,
                null_ls.builtins.formatting.dart_format,
                require("none-ls.diagnostics.eslint_d"),
                require("none-ls.code_actions.eslint_d"),
                require("none-ls.formatting.eslint_d").with( {
                    timeout = 4000
                } ),
                null_ls.builtins.formatting.black,
                null_ls.builtins.formatting.clang_format
            },
        })
    end,
}
