lang/common-lisp: replace slime with sly

Also add sly server auto-start and cleanup hooks.
This commit is contained in:
Henrik Lissner 2018-06-13 22:14:22 +02:00
parent 8889d5cc2b
commit 6a6652d394
2 changed files with 27 additions and 17 deletions

View file

@ -1,20 +1,31 @@
;;; lang/common-lisp/config.el -*- lexical-binding: t; -*- ;;; lang/common-lisp/config.el -*- lexical-binding: t; -*-
;; `slime' ;; `slime'
(setq slime-contribs '(slime-fancy)) (after! sly
(after! slime (setq inferior-lisp-program "sbcl")
(setq inferior-lisp-program (executable-find "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 (defun +common-lisp|init-sly ()
:when (featurep! :completion company) "Attempt to auto-start sly when opening a lisp buffer."
:commands slime-company (cond ((sly-connected-p))
:init ((executable-find inferior-lisp-program)
(push 'slime-company slime-contribs) (let ((sly-auto-start 'always))
(sly-auto-start)
;; Don't override the global `company-backends'! (add-hook 'kill-buffer-hook #'+common-lisp|cleanup-sly-maybe nil t)))
(defun +common-lisp|make-company-backends-local (&rest _) ((message "WARNING: Couldn't find `inferior-lisp-program' (%s)"
(make-variable-buffer-local 'company-backends)) inferior-lisp-program))))
(advice-add #'slime-company-maybe-enable (add-hook 'sly-mode-hook #'+common-lisp|init-sly))
:before #'+common-lisp|make-company-backends-local))

View file

@ -1,6 +1,5 @@
;; -*- no-byte-compile: t; -*- ;; -*- no-byte-compile: t; -*-
;;; lang/common-lisp/packages.el ;;; lang/common-lisp/packages.el
(package! slime) (package! sly)
(when (featurep! :completion company) (package! sly-macrostep)
(package! slime-company))