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/elixir/packages.el

212 lines
7.2 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- Elixir Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq elixir-packages
'(
alchemist
2015-06-09 03:28:27 +00:00
company
elixir-mode
flycheck
flycheck-mix
flycheck-credo
ggtags
helm-gtags
ob-elixir
2015-05-28 14:01:09 +00:00
popwin
smartparens
))
(defun elixir/post-init-company ()
Refactor and simplify company backends declaration Enabling a company backend for a specific mode was a tedious tasks with code scattered at different locations, one for local variable definitions, one for company hook function definitions and another where the backends were pushed to the local variables (which was problematic, since we ended up pushing the same backends over and over again with `SPC f e R`, pushes have been replaced by add-to-list calls in the new macro). All these steps are now put together at one place with the new macro spacemacs|add-company-backends, check its docstring for more info on its arguments. This macro also allows to define arbitrary buffer local variables to tune company for specific modes (similar to layer variables via a keyword :variables) The code related to company backends management has been moved to the auto-completion layer in the funcs.el file. A nice side effect of this move is that it enforces correct encapsulation of company backends related code. We can now easily detect if there is some configuration leakage when the auto-completion layer is not used. But we loose macro expansion at file loading time (not sue it is a big concern though). The function spacemacs|enable-auto-complete was never used so it has been deleted which led to the deletion of the now empty file core-auto-completion.el. The example in LAYERS.org regarding auto-completion is now out of date and has been deleted. An example to setup auto-completion is provided in the README.org file of the auto-completion layer.
2017-01-02 05:39:04 +00:00
(when (configuration-layer/package-usedp 'alchemist)
(spacemacs|add-company-backends
:backends alchemist-company
:modes elixir-mode alchemist-iex-mode)))
(defun elixir/init-alchemist ()
(use-package alchemist
:defer t
:init
(progn
(spacemacs/register-repl 'alchemist 'alchemist-iex-run "alchemist")
(add-hook 'elixir-mode-hook 'alchemist-mode)
(setq alchemist-project-compile-when-needed t
alchemist-test-status-modeline nil)
(add-to-list 'spacemacs-jump-handlers-elixir-mode
2016-08-13 13:43:37 +00:00
'alchemist-goto-definition-at-point))
:config
(spacemacs/declare-prefix-for-mode 'elixir-mode "mX" "hex")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mc" "compile")
(spacemacs/declare-prefix-for-mode 'elixir-mode "me" "eval")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mg" "goto")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mh" "help")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mm" "mix")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mo" "macroexpand")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mp" "project")
(spacemacs/declare-prefix-for-mode 'elixir-mode "ms" "iex")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mt" "test")
(spacemacs/declare-prefix-for-mode 'elixir-mode "mx" "execute")
(spacemacs/set-leader-keys-for-major-mode 'elixir-mode
"el" 'alchemist-eval-current-line
"eL" 'alchemist-eval-print-current-line
"er" 'alchemist-eval-region
"eR" 'alchemist-eval-print-region
"eb" 'alchemist-eval-buffer
"eB" 'alchemist-eval-print-buffer
"ej" 'alchemist-eval-quoted-current-line
"eJ" 'alchemist-eval-print-quoted-current-line
"eu" 'alchemist-eval-quoted-region
"eU" 'alchemist-eval-print-quoted-region
"ev" 'alchemist-eval-quoted-buffer
"eV" 'alchemist-eval-print-quoted-buffer
"pt" 'alchemist-project-find-test
"gt" 'alchemist-project-toggle-file-and-tests
"gT" 'alchemist-project-toggle-file-and-tests-other-window
"h:" 'alchemist-help
"hH" 'alchemist-help-history
"hh" 'alchemist-help-search-at-point
"hr" 'alchemist-help--search-marked-region
"m:" 'alchemist-mix
"mc" 'alchemist-mix-compile
"mx" 'alchemist-mix-run
"'" 'alchemist-iex-run
"sc" 'alchemist-iex-compile-this-buffer
"si" 'alchemist-iex-run
"sI" 'alchemist-iex-project-run
"sl" 'alchemist-iex-send-current-line
"sL" 'alchemist-iex-send-current-line-and-go
"sm" 'alchemist-iex-reload-module
"sr" 'alchemist-iex-send-region
"sR" 'alchemist-iex-send-region-and-go
"ta" 'alchemist-mix-test
"tb" 'alchemist-mix-test-this-buffer
"tB" 'alchemist-project-run-tests-for-current-file
"tt" 'alchemist-mix-test-at-point
"tf" 'alchemist-mix-test-file
"tn" 'alchemist-test-mode-jump-to-next-test
"tN" 'alchemist-test-mode-jump-to-previous-test
"tr" 'alchemist-mix-rerun-last-test
"ts" 'alchemist-mix-test-stale
"tR" 'alchemist-test-toggle-test-report-display
"xb" 'alchemist-execute-this-buffer
"xf" 'alchemist-execute-file
"x:" 'alchemist-execute
"cb" 'alchemist-compile-this-buffer
"cf" 'alchemist-compile-file
"c:" 'alchemist-compile
"gg" 'alchemist-goto-definition-at-point
"." 'alchemist-goto-definition-at-point
"gb" 'alchemist-goto-jump-back
"," 'alchemist-goto-jump-back
"gN" 'alchemist-goto-jump-to-previous-def-symbol
"gn" 'alchemist-goto-jump-to-next-def-symbol
"gj" 'alchemist-goto-list-symbol-definitions
"Xi" 'alchemist-hex-info-at-point
"Xr" 'alchemist-hex-releases-at-point
"XR" 'alchemist-hex-releases
"XI" 'alchemist-hex-info
"Xs" 'alchemist-hex-search
"ol" 'alchemist-macroexpand-once-current-line
"oL" 'alchemist-macroexpand-once-print-current-line
"ok" 'alchemist-macroexpand-current-line
"oK" 'alchemist-macroexpand-print-current-line
"oi" 'alchemist-macroexpand-once-region
"oI" 'alchemist-macroexpand-once-print-region
"or" 'alchemist-macroexpand-region
"oR" 'alchemist-macroexpand-print-region)
(dolist (mode (list alchemist-compile-mode-map
alchemist-eval-mode-map
alchemist-execute-mode-map
alchemist-message-mode-map
alchemist-help-minor-mode-map
alchemist-mix-mode-map
alchemist-macroexpand-mode-map
alchemist-refcard-mode-map
alchemist-test-report-mode-map))
(evil-define-key 'normal mode
(kbd "q") 'quit-window))))
(defun elixir/init-flycheck-mix ()
(use-package flycheck-mix
:commands (flycheck-mix-setup)
:init
(progn
(add-to-list 'safe-local-variable-values
(cons 'elixir-enable-compilation-checking nil))
(add-to-list 'safe-local-variable-values
(cons 'elixir-enable-compilation-checking t))
(add-hook 'elixir-mode-local-vars-hook
'spacemacs//elixir-enable-compilation-checking))))
(defun elixir/init-flycheck-credo ()
(use-package flycheck-credo
:defer t
:init (add-hook 'flycheck-mode-hook #'flycheck-credo-setup)))
(defun elixir/init-elixir-mode ()
(use-package elixir-mode
:defer t))
(defun elixir/post-init-flycheck ()
(spacemacs/enable-flycheck 'elixir-mode))
(defun elixir/pre-init-org ()
(spacemacs|use-package-add-hook org
:post-config (add-to-list 'org-babel-load-languages '(elixir . t))))
(defun elixir/init-ob-elixir ()
(spacemacs|use-package-add-hook org
:post-config
(use-package ob-elixir
:init (add-to-list 'org-babel-load-languages '(elixir . t)))))
(defun elixir/pre-init-popwin ()
(spacemacs|use-package-add-hook popwin
:post-config
(push '("*mix*" :tail t :noselect t) popwin:special-display-config)))
(defun elixir/pre-init-smartparens ()
2016-05-31 17:49:09 +00:00
(spacemacs|use-package-add-hook smartparens
:post-config
(progn
(sp-with-modes '(elixir-mode)
(sp-local-pair
"(" ")"
:unless '(:add spacemacs//elixir-point-after-fn-p))
(sp-local-pair
"fn" "end"
:when '(("SPC" "RET" "-" "("))
2016-05-31 17:49:09 +00:00
:post-handlers '(:add spacemacs//elixir-do-end-close-action)
:actions '(insert)))
(sp-with-modes '(elixir-mode)
(sp-local-pair
"do" "end"
:when '(("SPC" "RET"))
:post-handlers '(:add spacemacs//elixir-do-end-close-action)
:actions '(insert))))))
(defun elixir/post-init-ggtags ()
(add-hook 'elixir-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
(defun elixir/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'elixir-mode))