diff --git a/modules/lang/common-lisp/config.el b/modules/lang/common-lisp/config.el index c73333eda..ee4b2c74a 100644 --- a/modules/lang/common-lisp/config.el +++ b/modules/lang/common-lisp/config.el @@ -1,20 +1,31 @@ ;;; lang/common-lisp/config.el -*- lexical-binding: t; -*- ;; `slime' -(setq slime-contribs '(slime-fancy)) -(after! slime - (setq inferior-lisp-program (executable-find "sbcl"))) +(after! sly + (setq inferior-lisp-program "sbcl") + (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))))) -(def-package! slime-company - :when (featurep! :completion company) - :commands slime-company - :init - (push 'slime-company slime-contribs) - - ;; Don't override the global `company-backends'! - (defun +common-lisp|make-company-backends-local (&rest _) - (make-variable-buffer-local 'company-backends)) - (advice-add #'slime-company-maybe-enable - :before #'+common-lisp|make-company-backends-local)) + (defun +common-lisp|init-sly () + "Attempt to auto-start sly when opening a lisp buffer." + (cond ((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 nil t))) + ((message "WARNING: Couldn't find `inferior-lisp-program' (%s)" + inferior-lisp-program)))) + (add-hook 'sly-mode-hook #'+common-lisp|init-sly)) diff --git a/modules/lang/common-lisp/packages.el b/modules/lang/common-lisp/packages.el index 8c8d4b4af..8541ea496 100644 --- a/modules/lang/common-lisp/packages.el +++ b/modules/lang/common-lisp/packages.el @@ -1,6 +1,5 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/common-lisp/packages.el -(package! slime) -(when (featurep! :completion company) - (package! slime-company)) +(package! sly) +(package! sly-macrostep)