purcell / emacs-reformatter

Define commands which run reformatters on the current Emacs buffer
265 stars 21 forks source link

Need help for mint format. #37

Open zw963 opened 2 years ago

zw963 commented 2 years ago

What i said is mint-lang.

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

Following is command:

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

I have no idea how to make this command work.

Following is my config:

(reformatter-define mint-format
  :program "mint"
  :args '("format")
  :stdout nil
  )

Thank you.

zw963 commented 2 years ago

Try more but still no luck

(defun mint--format-args ()
  (append
   '("format")
   `(,(buffer-file-name))
   )
  )

(defun mint--format-exit-code (code)
  t
  ;; (when (or (eq code 0) (eq code 1))
  ;;   t
  ;;   )
  )

(reformatter-define mint-format
  :program "mint"
  :args (mint--format-args)
  :stdout nil
  :input (reformatter-temp-file-in-current-directory "mint")
  :exit-code-success-p mint--format-exit-code
  )
purcell commented 2 years ago

Does mint format support reading/writing with stdin/stdout? That's the best solution if possible, and if not, an upstream bug report is advised. Very very few such programs don't support that mode of operation these days.

zw963 commented 2 years ago

Does mint format support reading/writing with stdin/stdout? That's the best solution if possible, and if not, an upstream bug report is advised. Very very few such programs don't support that mode of operation these days.

Current, mint format in replace code in file directly, it have one options for this.

(reformatter-define mint-format
  :program "mint"
  :args '("format" "--stdin")
  )

but, the issue is, the mint format --stdin must be run within the project root to make it work correct, is there any option archive this?

more context, please check this

Thank you

c4710n commented 1 year ago

https://github.com/purcell/emacs-reformatter/issues/13#issuecomment-549128423 would be helpful.