require("conform").setup({
  formatters_by_ft = {
    python = { "ruff_format" },
    lua = { "stylua" },
    rust = { "rustfmt", lsp_format = "fallback" },
    javascript = { "prettierd", "prettier", stop_after_first = true },
    sh = { "shfmt" },
    bash = { "shfmt" },
    c = { "clang_format" },
    cpp = { "clang_format" },
    clojure = { "cljfmt" },
    css = { "prettierd" },
    scss = { "prettierd" },
    html = { "prettierd" },
    json = { "prettierd", "prettier" },
    jsonc = { "prettierd", "prettier" },
    elixir = { "mix_format" },
    elm = { "elm_format" },
    go = { "gofumpt" },
    gohtmltmpl = { "prettierd" },
    haskell = { "fourmolu" },
    java = { "google_java_format" },
    javascriptreact = { "prettierd", "prettier", stop_after_first = true },
    kdl = { "kdlfmt" },
    typescript = { "prettierd", "prettier", stop_after_first = true },
    typescriptreact = { "prettierd", "prettier", stop_after_first = true },
    typst = { "typstfmt" },
    latex = { "latexindent" },
    nix = { "nixfmt" },
    ocaml = { "ocamlformat" },
    scala = { "scalafmt" },
    toml = { "taplo" },
    yaml = { "prettierd", "prettier" },
    zig = { "zigfmt" },
    fish = { "fish_indent" },
    cmake = { "cmake_format" },
    terraform = { "terraform_fmt" },
    fortran = { "fprettify" },
    crystal = { "crystal_tool_format" },
    proto = { "buf" },
    dhall = { "dhall" },
    prisma = { "prisma" },
    sql = { "sqlfluff" },
    -- markdown = { "prettierd", "prettier" },
    -- markdown = { "mdformat" },
    markdown = { "markdownlint" },
  },
  lsp_fallback = true,
  formatters = {
    markdownlint = {
      command = "markdownlint-cli2",
      args = { "--fix", "$FILENAME" },
      stdin = false,
    },
    mdformat = {
      command = "mdformat",
      args = { "--wrap", "80", "--number", "--end-of-line", "lf", "-" },
      stdin = true,
    },
    typstfmt = {
      command = "typstfmt",
      stdin = true,
    },
    crystal_tool_format = {
      command = "crystal",
      args = { "tool", "format", "-" },
      stdin = true,
    },
    dhall = {
      command = "dhall",
      args = { "format" },
      stdin = true,
    },
    mix_format = {
      command = "mix",
      args = { "format", "-" },
      stdin = true,
    },
    google_java_format = {
      command = "google-java-format",
      args = { "-" },
      stdin = true,
    },
    prisma = {
      command = "prisma",
      args = { "format", "--schema", "$FILENAME" },
      stdin = false,
    },
    buf = {
      command = "buf",
      args = { "format", "-w" },
      stdin = false,
    },
    tinymist = {
      command = "tinymist",
      stdin = true,
    },
    stylua = {
      prepend_args = { "--indent-type", "Spaces", "--indent-width", "2" },
    },
  },
})
