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

301 lines
11 KiB
EmacsLisp
Raw Normal View History

2015-05-07 04:31:13 +00:00
;;; packages.el --- Emacs Lisp Layer packages File for Spacemacs
;;
2018-01-04 07:00:25 +00:00
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
2015-05-07 04:31:13 +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
(setq emacs-lisp-packages
'(
auto-compile
company
(debug :location built-in)
(edebug :location built-in)
eldoc
elisp-slime-nav
(emacs-lisp :location built-in)
evil
evil-cleverparens
2018-06-11 03:24:44 +00:00
eval-sexp-fu
flycheck
flycheck-package
ggtags
counsel-gtags
helm-gtags
(ielm :location built-in)
macrostep
nameless
overseer
parinfer
semantic
smartparens
srefactor
))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/init-ielm ()
(use-package ielm
:defer t
:init
(progn
(spacemacs/register-repl 'ielm 'ielm)
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/declare-prefix-for-mode mode "ms" "ielm")
(spacemacs/set-leader-keys-for-major-mode mode
"'" 'ielm
"si" 'ielm)))
:config
(defun ielm-indent-line ()
(interactive)
(let ((current-point (point)))
(save-restriction
(narrow-to-region (search-backward-regexp "^ELISP>") (goto-char current-point))
(lisp-indent-line))))))
(defun emacs-lisp/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
(spacemacs|add-company-backends :backends company-capf
:modes emacs-lisp-mode)
(spacemacs|add-company-backends :backends (company-files company-capf)
:modes ielm-mode))
2015-06-14 13:55:24 +00:00
(defun emacs-lisp/init-debug ()
(use-package debug
:defer t
:init (dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/declare-prefix-for-mode mode "md" "debug")
(spacemacs/set-leader-keys-for-major-mode mode
"dt" 'spacemacs/elisp-toggle-debug-expr-and-eval-func))
:config (evilified-state-evilify-map debugger-mode-map
:mode debugger-mode)))
(defun emacs-lisp/init-edebug ()
(use-package edebug
:defer t
:init
(progn
2017-02-12 17:50:07 +00:00
;; key bindings
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/set-leader-keys-for-major-mode mode
"df" 'spacemacs/edebug-instrument-defun-on
"dF" 'spacemacs/edebug-instrument-defun-off))
2017-02-12 17:50:07 +00:00
;; since we evilify `edebug-mode-map' we don't need to intercept it to
;; make it work with evil
(evil-set-custom-state-maps
'evil-intercept-maps
'evil-pending-intercept-maps
'intercept-state
'evil-make-intercept-map
(delq (assq 'edebug-mode-map evil-intercept-maps)
evil-intercept-maps))
(evilified-state-evilify-map edebug-mode-map
:eval-after-load edebug
:bindings
"a" 'edebug-stop
"c" 'edebug-go-mode
"s" 'edebug-step-mode
"S" 'edebug-next-mode)
(evilified-state-evilify-map edebug-eval-mode-map
:eval-after-load edebug
:bindings
"a" 'edebug-stop
"c" 'edebug-go-mode
"s" 'edebug-step-mode
"S" 'edebug-next-mode)
2017-02-12 17:50:07 +00:00
(advice-add 'edebug-mode :after 'spacemacs//edebug-mode))))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/post-init-eldoc ()
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode))
(defun emacs-lisp/init-auto-compile ()
(use-package auto-compile
:defer (spacemacs/defer)
:init
(progn
(spacemacs|require 'auto-compile)
(setq auto-compile-display-buffer nil
;; lets spaceline manage the mode-line
auto-compile-use-mode-line nil
auto-compile-mode-line-counter t)
(add-hook 'emacs-lisp-mode-hook 'auto-compile-mode))
:config
(progn
(spacemacs|hide-lighter auto-compile-mode)
(spacemacs/set-leader-keys-for-major-mode 'emacs-lisp-mode
"cl" 'auto-compile-display-log))))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/init-elisp-slime-nav ()
;; Elisp go-to-definition with M-. and back again with M-,
(use-package elisp-slime-nav
:defer (spacemacs/defer)
2015-05-07 04:31:13 +00:00
:init
(progn
(spacemacs|require 'elisp-slime-nav)
2015-05-07 04:31:13 +00:00
(add-hook 'emacs-lisp-mode-hook 'elisp-slime-nav-mode)
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/declare-prefix-for-mode mode "mg" "find-symbol")
(spacemacs/set-leader-keys-for-major-mode mode
"gb" 'xref-pop-marker-stack)
(spacemacs/declare-prefix-for-mode mode "mh" "help")
(spacemacs/set-leader-keys-for-major-mode mode
"hh" 'elisp-slime-nav-describe-elisp-thing-at-point)
(let ((jumpl (intern (format "spacemacs-jump-handlers-%S" mode))))
(add-to-list jumpl 'elisp-slime-nav-find-elisp-thing-at-point))))
:config (spacemacs|hide-lighter elisp-slime-nav-mode)
))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/init-emacs-lisp ()
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/declare-prefix-for-mode mode "mc" "compile")
(spacemacs/declare-prefix-for-mode mode "me" "eval")
(spacemacs/declare-prefix-for-mode mode "mt" "tests")
(spacemacs/set-leader-keys-for-major-mode mode
"cc" 'emacs-lisp-byte-compile
"e$" 'lisp-state-eval-sexp-end-of-line
"eb" 'eval-buffer
"eC" 'spacemacs/eval-current-form
"ee" 'eval-last-sexp
"er" 'eval-region
"ef" 'eval-defun
"el" 'lisp-state-eval-sexp-end-of-line
"gG" 'spacemacs/nav-find-elisp-thing-at-point-other-window
"," 'lisp-state-toggle-lisp-state
"tb" 'spacemacs/ert-run-tests-buffer
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
"tq" 'ert)))
(defun emacs-lisp/init-macrostep ()
(use-package macrostep
:defer t
2017-09-24 15:04:59 +00:00
:mode (("\\*.el\\'" . emacs-lisp-mode)
("Cask\\'" . emacs-lisp-mode))
:init
(progn
(evil-define-key 'normal macrostep-keymap "q" 'macrostep-collapse-all)
2016-01-20 02:55:38 +00:00
(spacemacs|define-transient-state macrostep
:title "MacroStep Transient State"
:doc "\n[_e_] expand [_c_] collapse [_n_/_N_] next/previous [_q_] quit"
:foreign-keys run
:bindings
("e" macrostep-expand)
("c" macrostep-collapse)
("n" macrostep-next-macro)
("N" macrostep-prev-macro)
("q" macrostep-collapse-all :exit t))
(spacemacs/set-leader-keys-for-major-mode 'emacs-lisp-mode
2016-01-20 02:55:38 +00:00
"dm" 'spacemacs/macrostep-transient-state/body))))
(defun emacs-lisp/init-nameless ()
(use-package nameless
:defer (spacemacs/defer)
:init
(progn
(spacemacs|require 'nameless)
(setq
;; always show the separator since it can have a semantic purpose
;; like in Spacemacs where - is variable and / is a function.
;; moreover it makes nameless work for all kind of separators.
nameless-separator nil
;; Use > as the defautl prefix : is already used for
;; keywords
nameless-prefix ">")
;; some default aliases for Spacemacs source code
(setq nameless-global-aliases '(("SB" . "spacemacs-buffer")
("S" . "spacemacs")
(".S" . "dotspacemacs")
("CL" . "configuration-layer")))
;; make `nameless-current-name' safe as a local variable for string values
(put 'nameless-current-name 'safe-local-variable #'stringp)
(spacemacs|diminish nameless-mode " 🅽" " [n]")
(spacemacs|add-toggle nameless
:status nameless-mode
:on (nameless-mode)
:off (nameless-mode -1)
:documentation "Hide package namespaces in your emacs-lisp code."
:evil-leader-for-mode (emacs-lisp-mode . "Tn"))
;; activate nameless only when in a GUI
;; in a terminal nameless triggers all sorts of graphical glitches.
(spacemacs|do-after-display-system-init
(when emacs-lisp-hide-namespace-prefix
(spacemacs/toggle-nameless-on-register-hook-emacs-lisp-mode))))))
(defun emacs-lisp/init-overseer ()
(use-package overseer
:defer t
:init (spacemacs/set-leader-keys-for-major-mode 'emacs-lisp-mode
"ta" 'overseer-test
"tt" 'overseer-test-run-test
"tb" 'overseer-test-this-buffer
"tf" 'overseer-test-file
"tg" 'overseer-test-tags
"tp" 'overseer-test-prompt
"tA" 'overseer-test-debug
"tq" 'overseer-test-quiet
"tv" 'overseer-test-verbose
"th" 'overseer-help)))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/post-init-evil ()
(add-hook 'emacs-lisp-mode-hook #'spacemacs//define-elisp-comment-text-object))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/pre-init-evil-cleverparens ()
(spacemacs|use-package-add-hook evil-cleverparens
:pre-init
(add-to-list 'evil-lisp-safe-structural-editing-modes 'emacs-lisp-mode)))
2018-06-11 03:24:44 +00:00
(defun emacs-lisp/post-init-eval-sexp-fu ()
(add-hook 'emacs-lisp-mode-hook 'eval-sexp-fu-flash-mode))
(defun emacs-lisp/post-init-flycheck ()
;; Don't activate flycheck by default in elisp
;; because of too much false warnings
;; (spacemacs/enable-flycheck 'emacs-lisp-mode)
;; Make flycheck recognize packages in loadpath
;; i.e (require 'company) will not give an error now
(setq flycheck-emacs-lisp-load-path 'inherit))
(defun emacs-lisp/init-flycheck-package ()
(use-package flycheck-package
:hook (emacs-lisp-mode . flycheck-package-setup)))
(defun emacs-lisp/post-init-counsel-gtags ()
(spacemacs/counsel-gtags-define-keys-for-mode 'emacs-lisp-mode))
(defun emacs-lisp/post-init-helm-gtags ()
(spacemacs/helm-gtags-define-keys-for-mode 'emacs-lisp-mode))
(defun emacs-lisp/post-init-ggtags ()
(add-hook 'emacs-lisp-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))
(defun emacs-lisp/post-init-parinfer ()
(add-hook 'emacs-lisp-mode-hook 'parinfer-mode))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/post-init-semantic ()
(add-hook 'emacs-lisp-mode-hook 'semantic-mode)
(with-eval-after-load 'semantic
(semantic-default-elisp-setup)))
2015-05-07 04:31:13 +00:00
(defun emacs-lisp/post-init-srefactor ()
(add-hook 'emacs-lisp-mode-hook 'spacemacs/load-srefactor)
2015-05-07 04:31:13 +00:00
(use-package srefactor-lisp
:commands (srefactor-lisp-format-buffer
srefactor-lisp-format-defun
srefactor-lisp-format-sexp
srefactor-lisp-one-line)
:init
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
2016-05-07 12:02:17 +00:00
(spacemacs/declare-prefix-for-mode mode "m=" "srefactor")
(spacemacs/set-leader-keys-for-major-mode mode
"=b" 'srefactor-lisp-format-buffer
"=d" 'srefactor-lisp-format-defun
"=o" 'srefactor-lisp-one-line
"=s" 'srefactor-lisp-format-sexp))))
(defun emacs-lisp/post-init-smartparens ()
(dolist (mode '(emacs-lisp-mode lisp-interaction-mode))
(spacemacs/set-leader-keys-for-major-mode mode
"ec" 'spacemacs/eval-current-form-sp
"es" 'spacemacs/eval-current-symbol-sp)))