purescript-emacs / purescript-mode

Emacs major mode and related tools for Purescript
20 stars 10 forks source link

Integration with `purty` #5

Open joneshf opened 5 years ago

joneshf commented 5 years ago

Howdy!

I maintain a source code formatter: purty. I'd like to add support for using it from emacs.

Is this something that could be added to purescript-mode? If so, I'd like the burden on you to be as minimal as possible, so when the API of purty changes, I expect to update whatever's necessary to work here. Would it be easier if I maintained a purty-mode and purescript-mode depended on it somehow (I don't know enough about the emacs ecosystem). If it shouldn't be added to purescript-mode, no worries.

t61j commented 4 years ago

Hi, any news on this? It would be really nice if purty integrated with purescript-mode already, even if it wouldn't have all the features wanted yet. One of the worst things to me as beginner when writing purescript occurs when I need to edit jsx style nodes (react-basic for example). When I need to wrap some long snippet with another div, moving everything correctly again by hand is very tedious). purty in those cases makes such a difference. At the moment I use:

(use-package purescript-mode
  :ensure t
  :config
  (defun format-ps ()
    (interactive)
    (set-process-sentinel
     (start-process "auto-format-purescript"
                    (current-buffer)
                    "purty"
                    "--write"
                    buffer-file-name)
     (lambda (process event)
       (revert-buffer :ignore-auto :noconfirm))))
  :bind ("C-c C-f" . format-ps)
  :mode ("\\.purs$" . purescript-mode))
kritzcreek commented 4 years ago

Can you just use https://github.com/lassik/emacs-format-all-the-code? According to the README it knows how to invoke purty on PureScript code.

t61j commented 4 years ago

Can you just use https://github.com/lassik/emacs-format-all-the-code? According to the README it knows how to invoke purty on PureScript code.

😅 Oh nice, I didn't know this package. Thanks