mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 12:00:24 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -7,6 +7,14 @@
|
||||
"Regexp to use for `outline-regexp' in `emacs-lisp-mode'.
|
||||
This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
|
||||
(defvar +emacs-lisp-disable-flycheck-in-dirs
|
||||
(list doom-emacs-dir doom-private-dir)
|
||||
"List of directories to disable `emacs-lisp-checkdoc' in.
|
||||
|
||||
This checker tends to produce a lot of false positives in your .emacs.d and
|
||||
private config, so it is mostly useless there. However, special hacks are
|
||||
employed so that flycheck still does *some* helpful linting.")
|
||||
|
||||
|
||||
;; `elisp-mode' is loaded at startup. In order to lazy load its config we need
|
||||
;; to pretend it isn't loaded
|
||||
@@ -19,18 +27,19 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
(use-package! elisp-mode
|
||||
:mode ("\\.Cask\\'" . emacs-lisp-mode)
|
||||
:config
|
||||
(set-repl-handler! 'emacs-lisp-mode #'+emacs-lisp/open-repl)
|
||||
(set-eval-handler! 'emacs-lisp-mode #'+emacs-lisp-eval)
|
||||
(set-lookup-handlers! 'emacs-lisp-mode
|
||||
:definition #'elisp-def
|
||||
(set-repl-handler! '(emacs-lisp-mode lisp-interaction-mode) #'+emacs-lisp/open-repl)
|
||||
(set-eval-handler! '(emacs-lisp-mode lisp-interaction-mode) #'+emacs-lisp-eval)
|
||||
(set-lookup-handlers! '(emacs-lisp-mode lisp-interaction-mode helpful-mode)
|
||||
:definition #'+emacs-lisp-lookup-definition
|
||||
:documentation #'+emacs-lisp-lookup-documentation)
|
||||
(set-docsets! 'emacs-lisp-mode "Emacs Lisp")
|
||||
(set-docsets! '(emacs-lisp-mode lisp-interaction-mode) "Emacs Lisp")
|
||||
(set-pretty-symbols! 'emacs-lisp-mode :lambda "lambda")
|
||||
(set-rotate-patterns! 'emacs-lisp-mode
|
||||
:symbols '(("t" "nil")
|
||||
("let" "let*")
|
||||
("when" "unless")
|
||||
("advice-add" "advice-remove")
|
||||
("defadvice!" "undefadvice!")
|
||||
("add-hook" "remove-hook")
|
||||
("add-hook!" "remove-hook!")
|
||||
("it" "xit")
|
||||
@@ -42,39 +51,60 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
mode-name "Elisp"
|
||||
;; Don't treat autoloads or sexp openers as outline headers, we have
|
||||
;; hideshow for that.
|
||||
outline-regexp +emacs-lisp-outline-regexp)
|
||||
outline-regexp +emacs-lisp-outline-regexp
|
||||
;; Fixed indenter that intends plists sensibly.
|
||||
lisp-indent-function #'+emacs-lisp-indent-function)
|
||||
|
||||
;; variable-width indentation is superior in elisp
|
||||
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode nil #'eq)
|
||||
|
||||
;; Use helpful instead of describe-* from `company'
|
||||
(advice-add #'elisp--company-doc-buffer :around #'doom-use-helpful-a)
|
||||
;; variable-width indentation is superior in elisp. Otherwise, `dtrt-indent'
|
||||
;; and `editorconfig' would force fixed indentation on elisp.
|
||||
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode)
|
||||
|
||||
(add-hook! 'emacs-lisp-mode-hook
|
||||
;; Allow folding of outlines in comments
|
||||
#'outline-minor-mode
|
||||
;; fontificiation
|
||||
;; Make parenthesis depth easier to distinguish at a glance
|
||||
#'rainbow-delimiters-mode
|
||||
;; Make quoted symbols easier to distinguish from free variables
|
||||
#'highlight-quoted-mode
|
||||
;; initialization
|
||||
#'+emacs-lisp-extend-imenu-h)
|
||||
;; Extend imenu support to Doom constructs
|
||||
#'+emacs-lisp-extend-imenu-h
|
||||
;; Ensure straight sees modifications to installed packages
|
||||
#'+emacs-lisp-init-straight-maybe-h)
|
||||
|
||||
;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in
|
||||
;; emacs configs, so we disable `emacs-lisp-checkdoc' and reduce the
|
||||
;; `emacs-lisp' checker's verbosity.
|
||||
(add-hook 'flycheck-mode-hook #'+emacs-lisp-reduce-flycheck-errors-in-emacs-config-h)
|
||||
|
||||
;; Special syntax highlighting for elisp...
|
||||
;; Enhance elisp syntax highlighting, by highlighting Doom-specific
|
||||
;; constructs, defined symbols, and truncating :pin's in `package!' calls.
|
||||
(font-lock-add-keywords
|
||||
'emacs-lisp-mode
|
||||
(append `(;; custom Doom cookies
|
||||
("^;;;###\\(autodef\\|if\\|package\\)[ \n]" (1 font-lock-warning-face t)))
|
||||
;; Shorten the :pin of `package!' statements to 10 characters
|
||||
`(("(package!\\_>" (0 (+emacs-lisp-truncate-pin))))
|
||||
;; highlight defined, special variables & functions
|
||||
(when +emacs-lisp-enable-extra-fontification
|
||||
`((+emacs-lisp-highlight-vars-and-faces . +emacs-lisp--face)))))
|
||||
|
||||
|
||||
;; Recenter window after following definition
|
||||
(advice-add #'elisp-def :after #'doom-recenter-a)
|
||||
|
||||
(defadvice! +emacs-lisp-append-value-to-eldoc-a (orig-fn sym)
|
||||
"Display variable value next to documentation in eldoc."
|
||||
:around #'elisp-get-var-docstring
|
||||
(when-let (ret (funcall orig-fn sym))
|
||||
(concat ret " "
|
||||
(let* ((truncated " [...]")
|
||||
(print-escape-newlines t)
|
||||
(str (symbol-value sym))
|
||||
(str (prin1-to-string str))
|
||||
(limit (- (frame-width) (length ret) (length truncated) 1)))
|
||||
(format (format "%%0.%ds%%s" limit)
|
||||
(propertize str 'face 'warning)
|
||||
(if (< (length str) limit) "" truncated))))))
|
||||
|
||||
(map! :localleader
|
||||
:map emacs-lisp-mode-map
|
||||
:desc "Expand macro" "m" #'macrostep-expand
|
||||
@@ -92,7 +122,15 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
"v" #'find-variable
|
||||
"l" #'find-library)))
|
||||
|
||||
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/
|
||||
(use-package! ielm
|
||||
:defer t
|
||||
:config
|
||||
(set-lookup-handlers! 'inferior-emacs-lisp-mode
|
||||
:definition #'+emacs-lisp-lookup-definition
|
||||
:documentation #'+emacs-lisp-lookup-documentation))
|
||||
|
||||
;; Adapted from http://www.modernemacs.com/post/comint-highlighting/ to add
|
||||
;; syntax highlighting to ielm REPLs.
|
||||
(add-hook! 'ielm-mode-hook
|
||||
(defun +emacs-lisp-init-syntax-highlighting-h ()
|
||||
(font-lock-add-keywords
|
||||
@@ -117,11 +155,12 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
|
||||
;;;###package overseer
|
||||
(autoload 'overseer-test "overseer" nil t)
|
||||
(remove-hook 'emacs-lisp-mode-hook 'overseer-enable-mode)
|
||||
;; Properly lazy load overseer by not loading it so early:
|
||||
(remove-hook 'emacs-lisp-mode-hook #'overseer-enable-mode)
|
||||
|
||||
|
||||
(use-package! flycheck-cask
|
||||
:when (featurep! :tools flycheck)
|
||||
:when (featurep! :checkers syntax)
|
||||
:defer t
|
||||
:init
|
||||
(add-hook! 'emacs-lisp-mode-hook
|
||||
@@ -167,8 +206,8 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
||||
(set-yas-minor-mode! 'buttercup-minor-mode)
|
||||
(when (featurep 'evil)
|
||||
(add-hook 'buttercup-minor-mode-hook #'evil-normalize-keymaps))
|
||||
(map! :map buttercup-minor-mode-map
|
||||
:localleader
|
||||
(map! :localleader
|
||||
:map buttercup-minor-mode-map
|
||||
:prefix "t"
|
||||
"t" #'+emacs-lisp/buttercup-run-file
|
||||
"a" #'+emacs-lisp/buttercup-run-project
|
||||
|
||||
Reference in New Issue
Block a user