From b66ad7703134d8a91e8ae1fab84af3bb90fcca03 Mon Sep 17 00:00:00 2001 From: Colin Woodbury Date: Mon, 13 Mar 2023 15:54:46 +0900 Subject: [PATCH] feat(elm): add bindings for project compilation Present in basically every other language module, these were mysteriously missing for Elm. --- modules/lang/elm/autoload.el | 29 +++++++++++++++++++++++++++++ modules/lang/elm/config.el | 10 ++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 modules/lang/elm/autoload.el diff --git a/modules/lang/elm/autoload.el b/modules/lang/elm/autoload.el new file mode 100644 index 000000000..f41f9398d --- /dev/null +++ b/modules/lang/elm/autoload.el @@ -0,0 +1,29 @@ +;;; lang/elm/autoloads.el -*- lexical-binding: t; -*- + +;;;###autoload +(defun +elm/compile-html () + "Compile the current Elm project." + (interactive) + (let ((default-directory (doom-project-root))) + (compile (format "elm make %s" buffer-file-name)))) + +;;;###autoload +(defun +elm/compile-html-optimized () + "Compile the current Elm project with optimizations." + (interactive) + (let ((default-directory (doom-project-root))) + (compile (format "elm make %s --optimize" buffer-file-name)))) + +;;;###autoload +(defun +elm/compile-js () + "Compile the current Elm project to Javascript." + (interactive) + (let ((default-directory (doom-project-root))) + (compile (format "elm make %s --output=main.js" buffer-file-name)))) + +;;;###autoload +(defun +elm/compile-js-optimized () + "Compile the current Elm project to Javascript with optimizations." + (interactive) + (let ((default-directory (doom-project-root))) + (compile (format "elm make %s --output=main.js --optimize" buffer-file-name)))) diff --git a/modules/lang/elm/config.el b/modules/lang/elm/config.el index 7c5d29300..b15018765 100644 --- a/modules/lang/elm/config.el +++ b/modules/lang/elm/config.el @@ -15,10 +15,16 @@ :int "Int" :str "String" :float "Float" :bool "Bool" - :not "not" - :and "&&" :or "||")) + :and "&&" :or "||") + (map! :map elm-mode-map + :localleader + (:prefix ("m" . "elm make") + :desc "Compile HTML" "m" #'+elm/compile-html + :desc "Compile HTML (optimized)" "M" #'+elm/compile-html-optimized + :desc "Compile JS" "j" #'+elm/compile-js + :desc "Compile JS (optimized)" "J" #'+elm/compile-js-optimized))) (use-package! flycheck-elm :when (modulep! :checkers syntax)