This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/elm/packages.el

123 lines
3.6 KiB
EmacsLisp
Raw Normal View History

2015-08-02 13:04:12 +00:00
;;; packages.el --- elm Layer packages File for Spacemacs
;;
2020-07-15 21:04:34 +00:00
;; Copyright (c) 2012-2020 Sylvain Benner & Contributors
2015-08-02 13:04:12 +00:00
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
2020-07-15 21:04:34 +00:00
(defconst elm-packages
'(
company
elm-mode
elm-test-runner
flycheck
(flycheck-elm :requires flycheck)
popwin
smartparens))
2015-08-02 13:04:12 +00:00
(defun elm/post-init-company ()
2020-07-15 21:04:34 +00:00
(spacemacs//elm-setup-company))
(defun elm/post-init-flycheck ()
2020-07-15 21:04:34 +00:00
(spacemacs/enable-flycheck 'elm-mode))
(defun elm/init-flycheck-elm ()
"Initialize flycheck-elm"
(use-package flycheck-elm
:defer t
:init (add-hook 'flycheck-mode-hook 'flycheck-elm-setup t)))
(defun elm/init-elm-mode ()
"Initialize elm-mode"
(use-package elm-mode
:mode ("\\.elm\\'" . elm-mode)
2020-07-15 21:04:34 +00:00
:defer t
:init
(progn
(spacemacs/register-repl 'elm-mode 'elm-repl-load "elm")
2020-07-15 21:04:34 +00:00
(add-hook 'elm-mode-hook 'spacemacs//elm-setup-backend))
:config
(progn
2020-07-15 21:04:34 +00:00
;; Bind non-lsp keys
(when (eq (spacemacs//elm-backend) 'company-elm)
(spacemacs/set-leader-keys-for-major-mode 'elm-mode
;; format
"=b" 'elm-format-buffer
;; oracle
"hh" 'elm-oracle-doc-at-point
"ht" 'elm-oracle-type-at-point)
;; Bind prefixes
(dolist (x '(("m=" . "format")
("mh" . "help")
("mg" . "goto")
("mr" . "refactor")))
(spacemacs/declare-prefix-for-mode 'elm-mode (car x) (cdr x))))
;; Bind general keys
(spacemacs/set-leader-keys-for-major-mode 'elm-mode
;; refactoring
"ri" 'elm-sort-imports
;; repl
"'" 'elm-repl-load
"si" 'elm-repl-load
"sf" 'elm-repl-push-decl
"sF" 'spacemacs/elm-repl-push-decl-focus
"sr" 'elm-repl-push
"sR" 'spacemacs/elm-repl-push-focus
2020-07-15 21:04:34 +00:00
;; make
"cb" 'elm-compile-buffer
"cB" 'spacemacs/elm-compile-buffer-output
"cm" 'elm-compile-main
;; reactor
"Rn" 'elm-preview-buffer
"Rm" 'elm-preview-main
;; package
"pi" 'elm-import
"pc" 'elm-package-catalog
"pd" 'elm-documentation-lookup)
2020-07-15 21:04:34 +00:00
;; Bind prefixes
(dolist (x '(("mp" . "package")
("mc" . "compile")
("mR" . "reactor")
("ms" . "repl")))
(spacemacs/declare-prefix-for-mode 'elm-mode (car x) (cdr x)))
(evilified-state-evilify elm-package-mode elm-package-mode-map
"g" 'elm-package-refresh
"v" 'elm-package-view
"m" 'elm-package-mark
"u" 'elm-package-unmark
"x" 'elm-package-install
"q" 'quit-window))))
(defun elm/init-elm-test-runner ()
(use-package elm-test-runner
:after elm-mode
:init
(progn
(spacemacs/declare-prefix-for-mode 'elm-mode "mt" "test")
(spacemacs/set-leader-keys-for-major-mode 'elm-mode
"tb" 'elm-test-runner-run
"td" 'elm-test-runner-run-directory
"tp" 'elm-test-runner-run-project
"tr" 'elm-test-runner-rerun
"tw" 'elm-test-runner-watch
2020-07-15 21:04:34 +00:00
"t TAB" 'elm-test-runner-toggle-test-and-target))))
(defun elm/pre-init-popwin ()
(spacemacs|use-package-add-hook popwin
:post-config
(push '("*elm*" :tail t :noselect t) popwin:special-display-config)
(push '("*elm-make*" :tail t :noselect t) popwin:special-display-config)))
(defun elm/post-init-smartparens ()
(if dotspacemacs-smartparens-strict-mode
(add-hook 'elm-mode-hook #'smartparens-strict-mode)
(add-hook 'elm-mode-hook #'smartparens-mode)))