local util = require("conform.util")

return {
  {
    "stevearc/conform.nvim",

    -- @class ConformOpts
    opts = {
      formatters_by_ft = {
        {{ if not .isServer -}}
        -- lua
        lua = { "stylua" },
        {{ end -}}

        -- data/conf
        sql = { "prettier" },
        json = { "prettier" },
        toml = { "taplo" },
        yaml = { "prettier" },

        -- web
        html = { "prettier" },
        liquid = { "prettier" },
        css = { {{ if not .isServer }}"stylelint", {{ end }}"prettier" },
        scss = { {{ if not .isServer }}"stylelint", {{ end }}"prettier" },
        javascript = { {{ if not .isServer }}"eslint", {{ end }}"prettier" },
        typescript = { {{ if not .isServer }}"eslint", {{ end }}"prettier" },
        vue = { {{ if not .isServer }}"eslint", {{ end }}"prettier" },
        markdown = { "prettier" },

        {{ if not .isServer -}}
        -- php
        php = { "pint" },
        blade = { "blade-formatter", "rustywind" },
        {{ end -}}

        -- shell
        sh = { "shellcheck", "shfmt" },
        fish = { "fish_indent" },

        -- misc
        ruby = { "prettier" },
      },
      formatters = {
        shfmt = {
          prepend_args = { "--indent=2", "--case-indent", "--binary-next-line", "--func-next-line" },
        },
        {{ if not .isServer -}}
        pint = {
          meta = {
            url = "https://github.com/laravel/pint",
            description = "Laravel Pint is an opinionated PHP code style fixer for minimalists. Pint is built on top of PHP-CS-Fixer and makes it simple to ensure that your code style stays clean and consistent.",
          },
          command = util.find_executable({
            vim.fn.stdpath("data") .. "/mason/bin/pint",
            "vendor/bin/pint",
          }, "pint"),
          args = { "$FILENAME" },
          stdin = false,
        },
        {{ end -}}
      },
    },
  },
}
