lassik / emacs-format-all-the-code

Auto-format source code in many languages with one command
https://melpa.org/#/format-all
MIT License
605 stars 105 forks source link

[Feature Request] Support mint-lang. #198

Open zw963 opened 2 years ago

zw963 commented 2 years ago

https://mint-lang.com/guide/getting-started/tools

Following is a usage example:

 ╰─ $ 1  mint format source/Main.mint 
Mint - Formatting files
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All files are formatted!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
All done in 299μs!

Thank you.

lassik commented 2 years ago

Looks doable. If someone sends a PR, I'll merge it.

$ mint format --help
Usage:
  mint format [flags...] <pattern> [arg...]

Formats source files

Flags:
  --check    # Checks that formatting code produces no changes
  --env, -e  # Loads the given .env file
  --help     # Displays help for the current command.
  --stdin    # Formats Mint code from STDIN

Arguments:
  pattern    # The pattern which determines which files to format
zw963 commented 2 years ago

Another issue is, mint format will return code 1 if current file formatted by this command.

i consider this probably a design error, mint format --check exactly do this things, instead, i consider the correct process is, if mint format run successful, whatever formatted file no no any changes made, it should always return code 0.

if need do some extra step for this?

lassik commented 2 years ago

Thanks for investigating it.

Indeed, almost all other formatters use exit code 0 even when they did not make any changes to the code.

format-all--buffer-hard can work around it, but it would be better to fix the upstream mint format. Can you ask in their issue tracker?

zw963 commented 2 years ago

Thanks for investigating it.

Indeed, almost all other formatters use exit code 0 even when they did not make any changes to the code.

format-all--buffer-hard can work around it, but it would be better to fix the upstream mint format. Can you ask in their issue tracker?

Maybe i am wrong, if use like this, cat source/Main.mint |mint format --stdin, it seem like always return 0 whatever if content was changed.