Handle graphql in prettier function

This commit is contained in:
Jeremy Dormitzer 2019-12-18 11:27:11 -05:00
parent 410841f531
commit ab6c877aa6

View File

@ -1527,8 +1527,11 @@ A command to format JS via prettier:
(defun prettier ()
(interactive)
(let ((start (if (use-region-p) (region-beginning) (point-min)))
(end (if (use-region-p) (region-end) (point-max))))
(shell-command-on-region start end "prettier --parser babel" nil t)))
(end (if (use-region-p) (region-end) (point-max)))
(parser (cond
((eq major-mode 'graphql-mode) "graphql")
(t "babel"))))
(shell-command-on-region start end (concat "prettier --parser " parser) nil t)))
#+END_SRC
* LSP Mode