Skip to content

Instantly share code, notes, and snippets.

@wkf
Created July 31, 2015 12:53
Show Gist options
  • Save wkf/fc8a0f57f68d8454c667 to your computer and use it in GitHub Desktop.
Save wkf/fc8a0f57f68d8454c667 to your computer and use it in GitHub Desktop.
;;; packages.el --- spacemacs configuration layer for cider
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp emacs-lisp-checkdoc)
;; End:
(defvar my-cider-packages '(cider clojure-quick-repls))
(defun my-cider-nrepl-server-filter (process output)
"A process filter for the nrepl server buffer that applies ansi colors and tails"
(with-current-buffer (process-buffer process)
(let ((moving (= (point) (process-mark process))))
(save-excursion
;; Insert the text, advancing the process marker.
(goto-char (process-mark process))
(let ((begin (point)))
(insert output)
(ansi-color-apply-on-region begin (point))
(set-marker (process-mark process) (point))))
(if moving (goto-char (process-mark process))))))
(defun my-cider-repl-mode-keys ()
(dolist (m (list evil-normal-state-local-map
evil-insert-state-local-map))
(define-key m (kbd "C-n")
(lambda (count)
(interactive "p") (cider-repl-next-input)))
(define-key m (kbd "C-p")
(lambda (count)
(interactive "p") (cider-repl-previous-input)))))
(defun my-cider/init-cider ()
(use-package cider
:config (progn
(add-hook 'nrepl-connected-hook
(lambda ()
(require 'ansi-color)
;; this hook runs in the context of the connection buffer...
;; ...so we can use this local variable to find the nrepl server buffer
(with-current-buffer nrepl-server-buffer
(linum-mode)
(set (make-local-variable 'window-point-insertion-type) t)
(ansi-color-apply-on-region (point-min) (point-max))
(set-marker (process-mark (get-buffer-process (current-buffer)))
(point-max))
(goto-char (point-max))
(set-process-filter (get-buffer-process (current-buffer))
'my-cider-nrepl-server-filter))))
(add-hook 'cider-repl-mode-hook 'my-cider-repl-mode-keys)
(evil-leader/set-key-for-mode 'clojure-mode
"mes" 'eval-sexp-fu-cider-eval-sexp-inner-sexp))))
(defun my-cider/init-clojure-quick-repls ()
(use-package clojure-quick-repls
:config (progn
(require 'cider)
(setq cider-switch-to-repl-command 'clojure-quick-repls-switch-to-relevant-repl))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment