nixfleet/users/profiles/emacs/emacs.d/config/config-purescript.el
Andrea Ciceri ecb7bc935b
Many things:
- updated inputs
- added new host `hs`
- workflows to check and release new host `hs`
- chrome instead of chromium (if not on aarch64)
- fixed bud configuration error for `pc` host
- fixed Emacs purescript format on save
2021-11-13 19:01:43 +01:00

47 lines
1.6 KiB
EmacsLisp

(use-package psc-ide
:custom
(psc-ide-rebuild-on-save t)
:config
;; The following is stolen from the Spacemacs purescript layer
(defun purescript-purs-tidy-format-buffer ()
"Format buffer with purs-tidy."
(interactive)
(if (executable-find "purs-tidy")
(let* ((extension (file-name-extension (or buffer-file-name "tmp.purs") t))
(tmpfile (make-temp-file "~fmt-tmp" nil extension))
(coding-system-for-read 'utf-8)
(coding-system-for-write 'utf-8)
(outputbuf (get-buffer-create "*~fmt-tmp.purs*")))
(unwind-protect
(progn
(with-current-buffer outputbuf (erase-buffer))
(write-region nil nil tmpfile)
(if (zerop (apply #'call-process-region nil nil "purs-tidy" nil
`(,outputbuf ,tmpfile) nil
`("format")))
(let ((p (point)))
(save-excursion
(with-current-buffer (current-buffer)
(replace-buffer-contents outputbuf)))
(goto-char p)
(message "formatted.")
(kill-buffer outputbuf))
(message "Formatting failed!")
(display-buffer outputbuf)))
(delete-file tmpfile)))
(error "purs-tidy not found")))
:hook
(purescript-mode . (lambda ()
(add-hook 'before-save-hook purescript-purs-tidy-format-buffer nil 'make-it-local)
(psc-ide-mode)
(company-mode)
(flycheck-mode)
(turn-on-purescript-indentation)
)))
(use-package psci)
(provide 'config-purescript)