2018-06-13 20:10:20 +02:00
|
|
|
;;; lang/common-lisp/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2018-12-05 19:01:17 -05:00
|
|
|
;; `lisp-mode' is loaded at startup. In order to lazy load its config we need to
|
|
|
|
;; pretend it isn't loaded
|
|
|
|
(defer-feature! lisp-mode)
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; packages
|
|
|
|
|
2018-10-16 02:15:25 -04:00
|
|
|
(defvar inferior-lisp-program "sbcl")
|
2018-12-05 19:01:17 -05:00
|
|
|
|
|
|
|
(after! lisp-mode
|
|
|
|
(set-repl-handler! 'lisp-mode #'sly-mrepl)
|
|
|
|
(set-eval-handler! 'lisp-mode #'sly-eval-region)
|
|
|
|
(set-lookup-handlers! 'lisp-mode
|
|
|
|
:definition #'sly-edit-definition
|
|
|
|
:documentation #'sly-describe-symbol)
|
|
|
|
|
|
|
|
(add-hook 'lisp-mode-hook #'rainbow-delimiters-mode))
|
2018-10-03 01:41:33 -04:00
|
|
|
|
2018-10-16 02:15:25 -04:00
|
|
|
|
2018-06-13 22:14:22 +02:00
|
|
|
(after! sly
|
2018-10-16 02:15:25 -04:00
|
|
|
(setq sly-mrepl-history-file-name (concat doom-cache-dir "sly-mrepl-history")
|
|
|
|
sly-kill-without-query-p t
|
2018-10-17 15:01:03 -04:00
|
|
|
sly-net-coding-system 'utf-8-unix
|
|
|
|
;; Change this to `sly-flex-completions' for fuzzy completion
|
|
|
|
sly-complete-symbol-function 'sly-simple-completions)
|
2018-06-13 20:10:20 +02:00
|
|
|
|
2018-09-10 12:50:45 -04:00
|
|
|
(set-popup-rules!
|
|
|
|
'(("^\\*sly-mrepl" :vslot 2 :quit nil :ttl nil)
|
2018-10-07 21:50:46 -04:00
|
|
|
("^\\*sly-compilation" :vslot 3 :ttl nil)
|
|
|
|
("^\\*sly-traces" :vslot 4 :ttl nil)))
|
|
|
|
|
|
|
|
;; Do not display debugger or inspector buffers in a popup window.
|
|
|
|
;; These buffers are meant to be displayed with sufficient vertical space.
|
|
|
|
(set-popup-rule! "^\\*sly-\\(db\\|inspector\\)" :ignore t)
|
2018-09-10 12:50:45 -04:00
|
|
|
|
2018-10-06 00:27:52 -04:00
|
|
|
(sp-with-modes '(sly-mrepl-mode)
|
2018-10-07 00:35:25 -04:00
|
|
|
(sp-local-pair "'" "'" :actions nil)
|
|
|
|
(sp-local-pair "`" "`" :actions nil))
|
2018-10-03 01:25:50 -04:00
|
|
|
|
2018-06-13 22:14:22 +02:00
|
|
|
(defun +common-lisp|cleanup-sly-maybe ()
|
|
|
|
"Kill processes and leftover buffers when killing the last sly buffer."
|
|
|
|
(unless (cl-loop for buf in (delq (current-buffer) (buffer-list))
|
|
|
|
if (and (buffer-local-value 'sly-mode buf)
|
|
|
|
(get-buffer-window buf))
|
|
|
|
return t)
|
|
|
|
(dolist (conn (sly--purge-connections))
|
|
|
|
(sly-quit-lisp-internal conn 'sly-quit-sentinel t))
|
|
|
|
(let (kill-buffer-hook kill-buffer-query-functions)
|
|
|
|
(mapc #'kill-buffer
|
|
|
|
(cl-loop for buf in (delq (current-buffer) (buffer-list))
|
|
|
|
if (buffer-local-value 'sly-mode buf)
|
|
|
|
collect buf)))))
|
2018-06-13 20:10:20 +02:00
|
|
|
|
2018-06-13 22:14:22 +02:00
|
|
|
(defun +common-lisp|init-sly ()
|
|
|
|
"Attempt to auto-start sly when opening a lisp buffer."
|
2018-10-07 00:33:58 -04:00
|
|
|
(cond ((or (doom-temp-buffer-p (current-buffer))
|
|
|
|
(sly-connected-p)))
|
2018-06-13 22:14:22 +02:00
|
|
|
((executable-find inferior-lisp-program)
|
|
|
|
(let ((sly-auto-start 'always))
|
|
|
|
(sly-auto-start)
|
|
|
|
(add-hook 'kill-buffer-hook #'+common-lisp|cleanup-sly-maybe nil t)))
|
|
|
|
((message "WARNING: Couldn't find `inferior-lisp-program' (%s)"
|
|
|
|
inferior-lisp-program))))
|
2018-06-22 01:03:26 +02:00
|
|
|
(add-hook 'sly-mode-hook #'+common-lisp|init-sly)
|
2018-06-13 20:10:20 +02:00
|
|
|
|
2018-07-30 23:02:06 +02:00
|
|
|
(defun +common-lisp*refresh-sly-version (version conn)
|
|
|
|
"Update `sly-protocol-version', which will likely be incorrect or nil due to
|
|
|
|
an issue where `load-file-name' is incorrect. Because Doom's packages are
|
|
|
|
installed through an external script (bin/doom), `load-file-name' is set to
|
|
|
|
bin/doom while packages at compile-time (not a runtime though)."
|
|
|
|
(unless sly-protocol-version
|
|
|
|
(setq sly-protocol-version (sly-version nil (locate-library "sly.el"))))
|
|
|
|
(advice-remove #'sly-check-version #'+common-lisp*refresh-sly-version))
|
|
|
|
(advice-add #'sly-check-version :before #'+common-lisp*refresh-sly-version)
|
|
|
|
|
2018-12-23 23:54:27 -05:00
|
|
|
(map! :localleader
|
|
|
|
:map sly-mode-map
|
|
|
|
"'" #'sly
|
2018-12-01 15:25:12 -05:00
|
|
|
(:prefix "g"
|
2018-12-23 23:54:27 -05:00
|
|
|
"b" #'sly-pop-find-definition-stack
|
|
|
|
"d" #'sly-edit-definition
|
|
|
|
"D" #'sly-edit-definition-other-window
|
|
|
|
"n" #'sly-next-note
|
|
|
|
"N" #'sly-previous-note
|
|
|
|
"s" #'sly-stickers-next-sticker
|
|
|
|
"S" #'sly-stickers-prev-sticker)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "h"
|
2018-12-23 23:54:27 -05:00
|
|
|
"<" #'sly-who-calls
|
|
|
|
">" #'sly-calls-who
|
|
|
|
"~" #'hyperspec-lookup-format
|
|
|
|
"#" #'hyperspec-lookup-reader-macro
|
|
|
|
"a" #'sly-apropos
|
|
|
|
"b" #'sly-who-binds
|
|
|
|
"d" #'sly-disassemble-symbol
|
|
|
|
"h" #'sly-describe-symbol
|
|
|
|
"H" #'sly-hyperspec-lookup
|
|
|
|
"m" #'sly-who-macroexpands
|
|
|
|
"p" #'sly-apropos-package
|
|
|
|
"r" #'sly-who-references
|
|
|
|
"s" #'sly-who-specializes
|
|
|
|
"S" #'sly-who-sets)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "c"
|
2018-12-23 23:54:27 -05:00
|
|
|
"c" #'sly-compile-file
|
|
|
|
"C" #'sly-compile-and-load-file
|
|
|
|
"f" #'sly-compile-defun
|
|
|
|
"l" #'sly-load-file
|
|
|
|
"n" #'sly-remove-notes
|
|
|
|
"r" #'sly-compile-region)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "e"
|
2018-12-23 23:54:27 -05:00
|
|
|
"b" #'sly-eval-buffer
|
|
|
|
"e" #'sly-eval-last-expression
|
|
|
|
"E" #'sly-eval-print-last-expression
|
|
|
|
"f" #'sly-eval-defun
|
|
|
|
"F" #'sly-undefine-function
|
|
|
|
"r" #'sly-eval-region)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "m"
|
2018-12-23 23:54:27 -05:00
|
|
|
"e" #'+common-lisp/macrostep/body
|
|
|
|
"E" #'macrostep-expand)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "r"
|
2018-12-23 23:54:27 -05:00
|
|
|
"c" #'sly-mrepl-clear-repl
|
|
|
|
"q" #'sly-quit-lisp
|
|
|
|
"r" #'sly-restart-inferior-lisp
|
|
|
|
"s" #'sly-mrepl-sync)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "s"
|
2018-12-23 23:54:27 -05:00
|
|
|
"b" #'sly-stickers-toggle-break-on-stickers
|
|
|
|
"c" #'sly-stickers-clear-defun-stickers
|
|
|
|
"C" #'sly-stickers-clear-buffer-stickers
|
|
|
|
"f" #'sly-stickers-fetch
|
|
|
|
"r" #'sly-stickers-replay
|
|
|
|
"s" #'sly-stickers-dwim)
|
2018-10-07 21:32:42 -04:00
|
|
|
(:prefix "t"
|
2018-12-23 23:54:27 -05:00
|
|
|
"t" #'sly-toggle-trace-fdefinition
|
|
|
|
"T" #'sly-toggle-fancy-trace
|
|
|
|
"u" #'sly-untrace-all))
|
2018-10-03 01:24:29 -04:00
|
|
|
|
2018-06-22 01:03:26 +02:00
|
|
|
(when (featurep! :feature evil +everywhere)
|
2018-10-07 00:47:14 -04:00
|
|
|
(add-hook 'sly-mode-hook #'evil-normalize-keymaps)
|
2018-06-22 01:03:26 +02:00
|
|
|
(add-hook 'sly-popup-buffer-mode-hook #'evil-normalize-keymaps)
|
|
|
|
(unless evil-move-beyond-eol
|
2018-07-19 03:40:31 +02:00
|
|
|
(advice-add #'sly-eval-last-expression :around #'+common-lisp*sly-last-sexp)
|
|
|
|
(advice-add #'sly-pprint-eval-last-expression :around #'+common-lisp*sly-last-sexp)
|
|
|
|
(advice-add #'sly-eval-print-last-expression :around #'+common-lisp*sly-last-sexp)
|
|
|
|
(advice-add #'sly-eval-last-expression-in-repl :around #'+common-lisp*sly-last-sexp))
|
2018-06-22 01:03:26 +02:00
|
|
|
(set-evil-initial-state!
|
|
|
|
'(sly-db-mode sly-inspector-mode sly-popup-buffer-mode sly-xref-mode)
|
|
|
|
'normal)
|
2018-10-03 01:24:01 -04:00
|
|
|
(evil-define-key 'insert sly-mrepl-mode-map
|
|
|
|
[S-return] #'newline-and-indent)
|
2018-06-22 01:03:26 +02:00
|
|
|
(evil-define-key 'normal sly-parent-map
|
|
|
|
(kbd "C-t") #'sly-pop-find-definition-stack)
|
|
|
|
(evil-define-key 'normal sly-db-mode-map
|
|
|
|
[follow-link] 'mouse-face
|
2018-12-02 00:42:15 -05:00
|
|
|
[mouse-2] 'sly-db-default-action/mouse
|
|
|
|
(kbd "C-i") 'sly-db-cycle
|
2018-06-22 01:03:26 +02:00
|
|
|
(kbd "C-j") 'sly-db-down
|
|
|
|
(kbd "C-k") 'sly-db-up
|
2018-12-02 00:42:15 -05:00
|
|
|
(kbd "C-m") 'sly-db-default-action
|
2018-06-22 01:03:26 +02:00
|
|
|
(kbd "C-S-j") 'sly-db-details-down
|
|
|
|
(kbd "C-S-k") 'sly-db-details-up
|
2018-12-02 00:42:15 -05:00
|
|
|
"]" 'sly-db-details-down
|
|
|
|
"[" 'sly-db-details-up
|
2018-06-22 01:03:26 +02:00
|
|
|
"0" 'sly-db-invoke-restart-0
|
|
|
|
"1" 'sly-db-invoke-restart-1
|
|
|
|
"2" 'sly-db-invoke-restart-2
|
|
|
|
"3" 'sly-db-invoke-restart-3
|
|
|
|
"4" 'sly-db-invoke-restart-4
|
|
|
|
"5" 'sly-db-invoke-restart-5
|
|
|
|
"6" 'sly-db-invoke-restart-6
|
|
|
|
"7" 'sly-db-invoke-restart-7
|
|
|
|
"8" 'sly-db-invoke-restart-8
|
2018-12-02 00:42:15 -05:00
|
|
|
"9" 'sly-db-invoke-restart-9
|
|
|
|
"a" 'sly-db-abort
|
|
|
|
"A" 'sly-db-break-with-system-debugger
|
|
|
|
"b" 'sly-db-break-on-return
|
|
|
|
"B" 'sly-db-break-with-default-debugger
|
|
|
|
"c" 'sly-db-continue
|
|
|
|
"C" 'sly-db-inspect-condition
|
|
|
|
"d" 'sly-db-pprint-eval-in-frame
|
|
|
|
"D" 'sly-db-disassemble
|
|
|
|
"e" 'sly-db-eval-in-frame
|
|
|
|
"g:" 'sly-interactive-eval
|
|
|
|
"g?" 'describe-mode
|
|
|
|
"gg" 'sly-db-beginning-of-backtrace
|
|
|
|
"gj" 'sly-db-down
|
|
|
|
"gk" 'sly-db-up
|
|
|
|
"gr" 'sly-db-restart-frame
|
|
|
|
"G" 'sly-db-end-of-backtrace
|
|
|
|
"i" 'sly-db-inspect-in-frame
|
|
|
|
"I" 'sly-db-invoke-restart-by-name
|
|
|
|
"n" 'sly-db-next
|
|
|
|
"o" 'sly-db-out
|
|
|
|
"P" 'sly-db-print-condition
|
|
|
|
"q" 'sly-db-quit
|
|
|
|
"R" 'sly-db-return-from-frame
|
|
|
|
"s" 'sly-db-step
|
2018-12-02 01:51:48 -05:00
|
|
|
"S" 'sly-db-show-frame-source
|
2018-12-02 00:42:15 -05:00
|
|
|
"t" 'sly-db-toggle-details)
|
2018-06-22 01:03:26 +02:00
|
|
|
(evil-define-key 'normal sly-inspector-mode-map
|
2019-03-28 16:39:15 -04:00
|
|
|
[backtab] 'backward-button
|
|
|
|
[return] 'push-button
|
|
|
|
[(shift tab)] 'backward-button
|
2018-12-02 01:51:48 -05:00
|
|
|
(kbd "<M-return>") 'sly-mrepl-copy-part-to-repl
|
2019-03-28 16:39:15 -04:00
|
|
|
(kbd "C-i") 'next-button
|
|
|
|
(kbd "C-m") 'push-button
|
2018-12-02 00:42:15 -05:00
|
|
|
"e" 'sly-inspector-eval
|
2018-12-02 01:51:48 -05:00
|
|
|
"gb" 'sly-inspector-pop
|
2018-06-22 01:03:26 +02:00
|
|
|
"gj" 'sly-inspector-next
|
2018-12-02 00:42:15 -05:00
|
|
|
"gr" 'sly-inspector-reinspect
|
|
|
|
"gR" 'sly-inspector-fetch-all
|
|
|
|
"gv" 'sly-inspector-toggle-verbose
|
|
|
|
"h" 'sly-inspector-history
|
2019-03-28 16:39:15 -04:00
|
|
|
"k" 'backward-button
|
|
|
|
"K" 'sly-inspector-describe-inspectee
|
|
|
|
"p" 'sly-button-pretty-print
|
2018-12-02 01:51:48 -05:00
|
|
|
"q" 'sly-inspector-quit)
|
2018-06-22 01:03:26 +02:00
|
|
|
(evil-define-key 'normal sly-mode-map
|
|
|
|
(kbd "C-t") 'sly-pop-find-definition-stack)
|
|
|
|
(evil-define-key 'normal sly-popup-buffer-mode-map
|
2019-03-28 16:39:15 -04:00
|
|
|
(kbd "C-t") 'sly-pop-find-definition-stack
|
|
|
|
"q" 'quit-window)
|
2018-06-22 01:03:26 +02:00
|
|
|
(evil-define-key 'normal sly-xref-mode-map
|
2018-12-02 01:51:48 -05:00
|
|
|
[return] 'sly-goto-xref
|
|
|
|
(kbd "S-<return>") 'sly-show-xref
|
2018-06-22 01:03:26 +02:00
|
|
|
(kbd "C-j") 'sly-xref-next-line
|
|
|
|
(kbd "C-k") 'sly-xref-prev-line
|
|
|
|
"]" 'sly-xref-next-line
|
|
|
|
"[" 'sly-xref-prev-line
|
2018-12-02 00:42:15 -05:00
|
|
|
"gj" 'sly-xref-next-line
|
|
|
|
"gk" 'sly-xref-prev-line
|
|
|
|
"go" 'sly-show-xref
|
2018-06-22 01:03:26 +02:00
|
|
|
"gr" 'sly-recompile-xref
|
|
|
|
"gR" 'sly-recompile-all-xrefs
|
2019-01-14 20:48:03 -05:00
|
|
|
"q" 'quit-window
|
2018-06-22 01:03:26 +02:00
|
|
|
"r" 'sly-xref-retract)))
|
2018-12-01 15:26:44 -05:00
|
|
|
|
2018-12-05 21:45:22 -05:00
|
|
|
|
2018-12-01 15:26:44 -05:00
|
|
|
(def-package! sly-repl-ansi-color
|
2018-12-05 21:45:22 -05:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(add-to-list 'sly-contribs 'sly-repl-ansi-color nil #'eq))
|