ocaml-opam / opam-user-setup

Simplify the configuration of editors for using OCaml tools
Other
81 stars 12 forks source link

Add ocamlformat for emacs setup #48

Closed sangwoo-joh closed 1 year ago

sangwoo-joh commented 4 years ago

Hi.

I've added some implementations to integrate ocamlformat into Emacs setup (#40) I only added this to Emacs setup just because my primary editor is Emacs. It binds C-c C-f to call ocamlformat for the current buffer.

Please review this pull request. Thank you.

rjbou commented 4 years ago

Thanks for the PR! as a vim user, i'll ping @AltGr for this one

jberdine commented 4 years ago

I wonder whether this should consider also setting (add-hook 'before-save-hook 'ocamlformat-before-save)?

I'm also not sure if there is a standard key binding that most use. For one data point, I shadow the keys tuareg-indent-phrase to invoke ocamlformat, so M-q and C-c C-q.

It is also not completely obvious in which mode map to put these bindings. Is it ok to hijack tuareg-mode-map with not-so-related bindings?

sangwoo-joh commented 4 years ago

@jberdine Thanks for your comment. Regarding (add-hook 'before-save-hook 'ocamlformat-before-save), I think it should also consider the setting. Regarding key bindings, I'm also not sure if there is a dominant key biding standard. I'm wondering if there is a way to get a key binding from user input. Regarding hijacking, I just added it to tuareg-mode-map because it was the way I've used for a long time. If there is a better way to do this, please let me know. Thank you.

punchagan commented 2 years ago

@rjbou @AltGr This PR seems reasonable to me. What does it need to get merged? Is it waiting on adding support to ocamlformat to the other editors as well?

I have some time in the next couple of days, if there's any thing I can do to help. :)

AltGr commented 1 year ago

Oh I am sorry this completely passed under my radar. Thanks for the contribution, and this seems good to me!