Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set up for Caddyfile? #498

Closed
VesperQuartz opened this issue Jul 23, 2024 · 2 comments
Closed

How to set up for Caddyfile? #498

VesperQuartz opened this issue Jul 23, 2024 · 2 comments

Comments

@VesperQuartz
Copy link

I am trying to set this up to autoformat my Caddyfile, but when I save I get the error "WARNING: The file has been changed since reading it!!!"

This is my config

require("conform").setup({
  formatters_by_ft = {
  caddyfile = { "caddyfile" },
 },
  formatters = {
      caddyfile = {
        command = "caddy",
        args = { "fmt", "--overwrite" },
        stdin = true,
        cwd = require("conform.util").root_file({ "Caddyfile" }),
        require_cwd = true,
      }
  }
})
@VesperQuartz
Copy link
Author

VesperQuartz commented Jul 23, 2024

fixed with changing
args = { "fmt", "--overwrite" }, which does not print to stdout
to
args = { "fmt"}, prints to stdout

@wangweixuan
Copy link

The - argument can be used to tell caddy to read from stdin and avoid depending on cwd:

{
  command = "caddy",
  args = { "fmt", "-" },
  stdin = true,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants