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)
|
2019-04-14 13:39:57 -04:00
|
|
|
("^\\*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.
|
|
|
|
("^\\*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
|
|
|
|
2019-07-25 19:56:20 +02:00
|
|
|
(defun +common-lisp--cleanup-sly-maybe-h ()
|
2018-06-13 22:14:22 +02:00
|
|
|
"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
|
|
|
|
2019-07-25 19:56:20 +02:00
|
|
|
(add-hook 'sly-mode-hook
|
|
|
|
(defun +common-lisp-init-sly-h ()
|
|
|
|
"Attempt to auto-start sly when opening a lisp buffer."
|
|
|
|
(cond ((or (doom-temp-buffer-p (current-buffer))
|
|
|
|
(sly-connected-p)))
|
|
|
|
((executable-find inferior-lisp-program)
|
|
|
|
(let ((sly-auto-start 'always))
|
|
|
|
(sly-auto-start)
|
|
|
|
(add-hook 'kill-buffer-hook #'+common-lisp--cleanup-sly-maybe-h nil t)))
|
|
|
|
((message "WARNING: Couldn't find `inferior-lisp-program' (%s)"
|
|
|
|
inferior-lisp-program)))))
|
|
|
|
|
|
|
|
;; REVIEW Do we still need this? Package autoloads are now wrapped in a let
|
|
|
|
;; block that letbinds `load-file-name' to their source.
|
|
|
|
(defadvice! +common-lisp--refresh-sly-version-a (version conn)
|
2018-07-30 23:02:06 +02:00
|
|
|
"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)."
|
2019-07-25 19:56:20 +02:00
|
|
|
:before #'sly-check-version
|
2018-07-30 23:02:06 +02:00
|
|
|
(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))
|
|
|
|
|
2018-12-23 23:54:27 -05:00
|
|
|
(map! :localleader
|
2019-03-28 19:05:52 -04:00
|
|
|
:map lisp-mode-map
|
2019-03-28 19:17:32 -04:00
|
|
|
:desc "Sly" "'" #'sly
|
|
|
|
:desc "Sly (ask)" ";" (λ! () (let ((current-prefix-arg '-)) (sly nil nil t)))
|
2019-03-28 19:56:00 -04:00
|
|
|
(:prefix ("g" . "Go")
|
|
|
|
:desc "Go back" "b" #'sly-pop-find-definition-stack
|
|
|
|
:desc "Go to" "d" #'sly-edit-definition
|
|
|
|
:desc "Go to (other window)" "D" #'sly-edit-definition-other-window
|
|
|
|
:desc "Next note" "n" #'sly-next-note
|
|
|
|
:desc "Previous note" "N" #'sly-previous-note
|
|
|
|
:desc "Next sticker" "s" #'sly-stickers-next-sticker
|
|
|
|
:desc "Previous sticker" "S" #'sly-stickers-prev-sticker)
|
|
|
|
(:prefix ("h" . "Help")
|
|
|
|
:desc "Who calls" "<" #'sly-who-calls
|
|
|
|
:desc "Calls who" ">" #'sly-calls-who
|
|
|
|
:desc "Lookup format directive" "~" #'hyperspec-lookup-format
|
|
|
|
:desc "Lookup reader macro" "#" #'hyperspec-lookup-reader-macro
|
|
|
|
:desc "Apropos" "a" #'sly-apropos
|
|
|
|
:desc "Who binds" "b" #'sly-who-binds
|
|
|
|
:desc "Disassemble symbol" "d" #'sly-disassemble-symbol
|
|
|
|
:desc "Describe symbol" "h" #'sly-describe-symbol
|
|
|
|
:desc "HyperSpec lookup" "H" #'sly-hyperspec-lookup
|
|
|
|
:desc "Who macro-expands" "m" #'sly-who-macroexpands
|
|
|
|
:desc "Apropos package" "p" #'sly-apropos-package
|
|
|
|
:desc "Who references" "r" #'sly-who-references
|
|
|
|
:desc "Who specializes" "s" #'sly-who-specializes
|
|
|
|
:desc "Who sets" "S" #'sly-who-sets)
|
|
|
|
(:prefix ("c" . "Compile")
|
|
|
|
:desc "Compile file" "c" #'sly-compile-file
|
|
|
|
:desc "Compile/load file" "C" #'sly-compile-and-load-file
|
|
|
|
:desc "Compile toplevel form" "f" #'sly-compile-defun
|
|
|
|
:desc "Load file" "l" #'sly-load-file
|
|
|
|
:desc "Remove notes" "n" #'sly-remove-notes
|
|
|
|
:desc "Compile region" "r" #'sly-compile-region)
|
|
|
|
(:prefix ("e" . "Evaluate")
|
|
|
|
:desc "Evaulate buffer" "b" #'sly-eval-buffer
|
|
|
|
:desc "Evaluate last" "e" #'sly-eval-last-expression
|
|
|
|
:desc "Evaluate/print last" "E" #'sly-eval-print-last-expression
|
|
|
|
:desc "Evaluate defun" "f" #'sly-eval-defun
|
|
|
|
:desc "Undefine function" "F" #'sly-undefine-function
|
|
|
|
:desc "Evaluate region" "r" #'sly-eval-region)
|
|
|
|
(:prefix ("m" . "Macro")
|
2019-03-28 20:00:50 -04:00
|
|
|
:desc "Macrostep" "e" #'macrostep-expand)
|
2019-03-28 19:56:00 -04:00
|
|
|
(:prefix ("r" . "REPL")
|
|
|
|
:desc "Clear REPL" "c" #'sly-mrepl-clear-repl
|
|
|
|
:desc "Quit connection" "q" #'sly-quit-lisp
|
|
|
|
:desc "Restart connection" "r" #'sly-restart-inferior-lisp
|
|
|
|
:desc "Sync REPL" "s" #'sly-mrepl-sync)
|
|
|
|
(:prefix ("s" . "Stickers")
|
|
|
|
:desc "Toggle breaking stickers" "b" #'sly-stickers-toggle-break-on-stickers
|
|
|
|
:desc "Clear defun stickers" "c" #'sly-stickers-clear-defun-stickers
|
|
|
|
:desc "Clear buffer stickers" "C" #'sly-stickers-clear-buffer-stickers
|
|
|
|
:desc "Fetch stickers" "f" #'sly-stickers-fetch
|
|
|
|
:desc "Replay stickers" "r" #'sly-stickers-replay
|
|
|
|
:desc "Add/remove sticker" "s" #'sly-stickers-dwim)
|
|
|
|
(:prefix ("t" . "Trace")
|
|
|
|
:desc "Toggle" "t" #'sly-toggle-trace-fdefinition
|
|
|
|
:desc "Toggle (fancy)" "T" #'sly-toggle-fancy-trace
|
|
|
|
:desc "Untrace all" "u" #'sly-untrace-all))
|
2018-10-03 01:24:29 -04:00
|
|
|
|
2019-04-21 19:59:44 -04:00
|
|
|
(when (featurep! :editor 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)
|
2019-07-25 19:56:20 +02:00
|
|
|
|
2018-06-22 01:03:26 +02:00
|
|
|
(unless evil-move-beyond-eol
|
2019-07-25 19:56:20 +02:00
|
|
|
(dolist (fn '(sly-eval-last-expression
|
|
|
|
sly-pprint-eval-last-expression
|
|
|
|
sly-eval-print-last-expression
|
|
|
|
sly-eval-last-expression-in-repl))
|
|
|
|
(advice-add fn :around #'+common-lisp--sly-last-sexp-a)))
|
2018-06-22 01:03:26 +02:00
|
|
|
(set-evil-initial-state!
|
2019-07-25 19:56:20 +02:00
|
|
|
'(sly-db-mode
|
|
|
|
sly-inspector-mode
|
|
|
|
sly-popup-buffer-mode
|
|
|
|
sly-xref-mode)
|
2018-06-22 01:03:26 +02:00
|
|
|
'normal)
|
2019-07-25 19:56:20 +02:00
|
|
|
|
2018-10-03 01:24:01 -04:00
|
|
|
(evil-define-key 'insert sly-mrepl-mode-map
|
2019-03-28 21:40:06 -04:00
|
|
|
[S-return] #'newline-and-indent
|
|
|
|
[backspace] #'sp-backward-delete-char
|
|
|
|
[up] (λ! () (evil-goto-line) (comint-previous-input 1))
|
|
|
|
[down] (λ! () (evil-goto-line) (comint-next-input 1)))
|
2018-06-22 01:03:26 +02:00
|
|
|
(evil-define-key 'normal sly-parent-map
|
|
|
|
(kbd "C-t") #'sly-pop-find-definition-stack)
|
2019-03-28 22:31:06 -04:00
|
|
|
(evil-define-key 'normal sly-popup-buffer-mode-map
|
|
|
|
(kbd "C-t") 'sly-pop-find-definition-stack
|
|
|
|
"q" 'quit-window)
|
2018-06-22 01:03:26 +02:00
|
|
|
(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
|
2019-03-28 22:31:06 -04:00
|
|
|
[remap quit-window] 'sly-db-quit
|
2018-12-02 00:42:15 -05:00
|
|
|
(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-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
|
|
|
|
2019-07-25 19:56:20 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-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))
|