2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/emacs-lisp/config.el -*- lexical-binding: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2018-08-30 20:41:54 +02:00
|
|
|
(defvar +emacs-lisp-enable-extra-fontification t
|
|
|
|
"If non-nil, highlight special forms, and defined functions and variables.")
|
|
|
|
|
2018-09-07 19:36:16 -04:00
|
|
|
|
2018-07-31 03:48:45 +02:00
|
|
|
;;
|
|
|
|
;; elisp-mode deferral hack
|
|
|
|
|
2018-07-29 17:58:15 +02:00
|
|
|
;; `elisp-mode' is loaded at startup. In order to lazy load its config we need
|
|
|
|
;; to pretend it isn't loaded
|
2018-06-27 22:52:46 +02:00
|
|
|
(delq 'elisp-mode features)
|
2018-07-29 17:58:15 +02:00
|
|
|
;; ...until the first time `emacs-lisp-mode' runs
|
|
|
|
(advice-add #'emacs-lisp-mode :before #'+emacs-lisp|init)
|
2017-02-21 00:46:44 -05:00
|
|
|
|
2018-06-27 18:48:01 +02:00
|
|
|
(defun +emacs-lisp|init (&rest _)
|
2018-07-29 17:58:15 +02:00
|
|
|
;; Some plugins (like yasnippet) run `emacs-lisp-mode' early, to parse some
|
|
|
|
;; elisp. This would prematurely trigger this function. In these cases,
|
|
|
|
;; `emacs-lisp-mode-hook' is let-bound to nil or its hooks are delayed, so if
|
|
|
|
;; we see either, keep pretending elisp-mode isn't loaded.
|
2018-06-27 18:48:01 +02:00
|
|
|
(when (and emacs-lisp-mode-hook (not delay-mode-hooks))
|
2018-07-29 17:58:15 +02:00
|
|
|
;; Otherwise, announce to the world elisp-mode has been loaded, so `after!'
|
|
|
|
;; handlers can respond and configure elisp-mode as expected.
|
2018-06-27 22:52:46 +02:00
|
|
|
(provide 'elisp-mode)
|
2018-06-27 18:48:01 +02:00
|
|
|
(advice-remove #'emacs-lisp-mode #'+emacs-lisp|init)))
|
2017-02-03 19:22:59 -05:00
|
|
|
|
2017-02-09 04:23:25 -05:00
|
|
|
|
2018-06-27 22:52:46 +02:00
|
|
|
;;
|
|
|
|
;; Config
|
|
|
|
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.Cask\\'" . emacs-lisp-mode))
|
|
|
|
|
|
|
|
(after! elisp-mode
|
|
|
|
(set-repl-handler! 'emacs-lisp-mode #'+emacs-lisp/repl)
|
|
|
|
(set-eval-handler! 'emacs-lisp-mode #'+emacs-lisp-eval)
|
2018-08-19 00:13:18 +02:00
|
|
|
(set-lookup-handlers! 'emacs-lisp-mode
|
|
|
|
:definition #'elisp-def
|
|
|
|
:documentation #'info-lookup-symbol)
|
feature/lookup: rewrite dash docset integration
+ Uses alist variable to store config, rather than hooks
+ Added check for installed docsets in +lookup/documentation
+ Set docsets for various language modules (c-mode, c++-mode, css-mode,
scss-mode, sass-mode, web-mode, go-mode, racket-mode, emacs-lisp-mode,
js2-mode, rjsx-mode, typescript-mode, rust-mode, and php-mode)
+ Made *eww* popups for dash docsets larger
+ Renamed set-docset! => set-docsets! (set-docset! is aliased to
set-docsets!)
+ New +lookup/install-docset alias
2018-08-31 02:44:49 +02:00
|
|
|
(set-docsets! 'emacs-lisp-mode "Emacs Lisp")
|
2018-06-27 22:52:46 +02:00
|
|
|
(set-pretty-symbols! 'emacs-lisp-mode :lambda "lambda")
|
|
|
|
(set-rotate-patterns! 'emacs-lisp-mode
|
|
|
|
:symbols '(("t" "nil")
|
|
|
|
("let" "let*")
|
|
|
|
("when" "unless")
|
|
|
|
("append" "prepend")
|
|
|
|
("advice-add" "advice-remove")
|
|
|
|
("add-hook" "remove-hook")
|
|
|
|
("add-hook!" "remove-hook!")))
|
|
|
|
|
2018-07-29 02:54:19 +02:00
|
|
|
;; variable-width indentation is superior in elisp
|
|
|
|
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode nil #'eq)
|
|
|
|
|
2018-06-27 22:52:46 +02:00
|
|
|
(add-hook! 'emacs-lisp-mode-hook
|
|
|
|
#'(;; 3rd-party functionality
|
2018-08-30 20:13:43 +02:00
|
|
|
auto-compile-on-save-mode
|
2018-06-27 22:52:46 +02:00
|
|
|
;; initialization
|
2018-08-21 00:04:48 +02:00
|
|
|
+emacs-lisp|extend-imenu))
|
|
|
|
|
|
|
|
;; Flycheck produces a *lot* of false positives in emacs configs, so disable
|
|
|
|
;; it when you're editing them
|
|
|
|
(add-hook 'flycheck-mode-hook #'+emacs-lisp|disable-flycheck-maybe)
|
2018-08-10 19:39:28 +02:00
|
|
|
|
2018-08-30 20:41:54 +02:00
|
|
|
;; Special fontification for elisp
|
2018-07-29 18:24:14 +02:00
|
|
|
(font-lock-add-keywords
|
|
|
|
'emacs-lisp-mode
|
2018-08-10 19:39:28 +02:00
|
|
|
(append `(;; custom Doom cookies
|
2018-08-30 20:41:54 +02:00
|
|
|
("^;;;###\\(autodef\\|if\\)[ \n]" (1 font-lock-warning-face t)))
|
|
|
|
;; highlight defined, special variables & functions
|
|
|
|
(when +emacs-lisp-enable-extra-fontification
|
|
|
|
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
|
|
|
|
|
|
|
|
(add-hook! 'emacs-lisp-mode-hook #'(rainbow-delimiters-mode highlight-quoted-mode))
|
2018-06-27 22:52:46 +02:00
|
|
|
|
2018-08-20 23:47:16 +02:00
|
|
|
;; Recenter window after following definition
|
|
|
|
(advice-add #'elisp-def :after #'doom*recenter))
|
2018-06-25 15:43:23 +02:00
|
|
|
|
2017-02-08 02:23:06 -05:00
|
|
|
|
2017-02-03 19:22:59 -05:00
|
|
|
;;
|
2018-09-07 19:36:16 -04:00
|
|
|
;; Packages
|
2017-02-03 19:22:59 -05:00
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
;; `auto-compile'
|
|
|
|
(setq auto-compile-display-buffer nil
|
|
|
|
auto-compile-use-mode-line nil)
|
2017-02-03 19:22:59 -05:00
|
|
|
|
|
|
|
|
2018-05-29 16:00:51 +02:00
|
|
|
;; `macrostep'
|
2018-06-27 22:54:09 +02:00
|
|
|
(when (featurep! :feature evil)
|
|
|
|
(after! macrostep
|
|
|
|
(evil-define-key* 'normal macrostep-keymap
|
|
|
|
(kbd "RET") #'macrostep-expand
|
|
|
|
"e" #'macrostep-expand
|
|
|
|
"u" #'macrostep-collapse
|
|
|
|
"c" #'macrostep-collapse
|
|
|
|
|
|
|
|
[tab] #'macrostep-next-macro
|
|
|
|
"\C-n" #'macrostep-next-macro
|
|
|
|
"J" #'macrostep-next-macro
|
|
|
|
|
|
|
|
[backtab] #'macrostep-prev-macro
|
|
|
|
"K" #'macrostep-prev-macro
|
2018-06-30 02:55:45 +02:00
|
|
|
"\C-p" #'macrostep-prev-macro
|
2018-06-27 22:54:09 +02:00
|
|
|
|
|
|
|
"q" #'macrostep-collapse-all
|
|
|
|
"C" #'macrostep-collapse-all)
|
|
|
|
|
|
|
|
;; `evil-normalize-keymaps' seems to be required for macrostep or it won't
|
|
|
|
;; apply for the very first invocation
|
|
|
|
(add-hook 'macrostep-mode-hook #'evil-normalize-keymaps)))
|
2017-07-15 17:57:44 +02:00
|
|
|
|
2017-04-04 22:19:48 -04:00
|
|
|
|
2018-08-21 00:04:48 +02:00
|
|
|
;; `overseer'
|
|
|
|
(autoload 'overseer-test "overseer" nil t)
|
|
|
|
|
|
|
|
|
2017-07-17 11:33:47 +02:00
|
|
|
(def-package! flycheck-cask
|
|
|
|
:when (featurep! :feature syntax-checker)
|
2018-05-25 00:46:11 +02:00
|
|
|
:defer t
|
2017-07-17 11:33:47 +02:00
|
|
|
:init
|
2018-02-19 14:37:32 -05:00
|
|
|
(add-hook! 'emacs-lisp-mode-hook
|
2017-07-17 11:33:47 +02:00
|
|
|
(add-hook 'flycheck-mode-hook #'flycheck-cask-setup nil t)))
|
|
|
|
|
|
|
|
|
2017-04-04 22:19:48 -04:00
|
|
|
;;
|
2018-05-25 00:46:11 +02:00
|
|
|
;; Project modes
|
2017-04-04 22:19:48 -04:00
|
|
|
|
|
|
|
(def-project-mode! +emacs-lisp-ert-mode
|
|
|
|
:modes (emacs-lisp-mode)
|
2017-06-19 12:51:11 +02:00
|
|
|
:match "/test[/-].+\\.el$")
|
2018-06-15 03:31:54 +02:00
|
|
|
|
|
|
|
(associate! buttercup-minor-mode
|
|
|
|
:modes (emacs-lisp-mode)
|
|
|
|
:match "/test[/-].+\\.el$")
|
|
|
|
|
|
|
|
(after! buttercup
|
2018-06-15 18:03:11 +02:00
|
|
|
(set-yas-minor-mode! 'buttercup-minor-mode))
|
2018-06-15 03:31:54 +02:00
|
|
|
|