Last active
December 14, 2015 11:58
-
-
Save omaciel/5082702 to your computer and use it in GitHub Desktop.
Basic Emacs configuration for Clojure hacking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Nice way to install packages by jweiss | |
(require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/") t) | |
(package-initialize) | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
;; Add in your own as you wish: | |
(defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings | |
clojure-mode ac-nrepl nrepl color-theme rainbow-delimiters auto-complete) | |
"A list of packages to ensure are installed at launch.") | |
(dolist (p my-packages) | |
(when (not (package-installed-p p)) | |
(package-install p))) | |
;; Theme selection | |
(eval-after-load "color-theme" | |
'(progn | |
(color-theme-initialize) | |
(color-theme-shaman))) | |
;; Further tweaks to Clojure mode by jmolet | |
;; Macro for face definition | |
(defmacro defcljface (name color desc &optional others) | |
`(defface ,name '((((class color)) (:foreground ,color ,@others))) | |
,desc :group 'faces)) | |
;; Define extra clojure faces | |
(defcljface clojure-keyword "#45b8f2" "Clojure keywords") | |
(defcljface clojure-special "#0074e8" "Clojure special") | |
(defcljface clojure-double-quote "#00920A" "Clojure special") | |
;; More syntax coloring | |
(defun tweak-clojure-syntax (mode) | |
(mapcar (λ (x) (font-lock-add-keywords mode x)) | |
'(((":\\w+" . 'clojure-keyword)) | |
(("#?\"" 0 'clojure-double-quote prepend)) | |
(("nil\\|true\\|false\\|%[1-9]?" . 'clojure-special)) | |
(("\\<\\(FIXME\\|TODO\\|BUG\\):" 1 'font-lock-warning-face t)) | |
(("(\\(->\\>\\)" 0 (progn (compose-region (match-beginning 1) | |
(match-end 1) "→") nil))) | |
(("(\\(->>\\>\\)" 0 (progn (compose-region (match-beginning 1) | |
(match-end 1) "↠") nil))) | |
(("(\\(complement\\>\\)" 0 (progn (compose-region | |
(match-beginning 1) | |
(match-end 1) "¬") nil))) | |
(("^[a-zA-Z0-9-.*+!_?]+?>" . 'nrepl-prompt-face))))) | |
(eval-after-load "clojure-mode" | |
'(progn | |
(tweak-clojure-syntax 'clojure-mode))) | |
(eval-after-load "nrepl" | |
'(progn | |
(tweak-clojure-syntax 'nrepl-mode))) | |
(autoload 'ac-nrepl-setup "ac-nrepl") | |
(add-hook 'nrepl-mode-hook | |
(lambda () | |
(paredit-mode) | |
(rainbow-delimiters-mode) | |
(auto-complete-mode) | |
(ac-nrepl-setup) | |
(font-lock-mode nil) | |
(clojure-mode-font-lock-setup) | |
(font-lock-mode t))) | |
;; Enable eldoc in clojure buffers | |
(add-hook 'nrepl-interaction-mode-hook | |
(lambda () | |
(nrepl-turn-on-eldoc-mode))) | |
(eval-after-load "auto-complete" | |
'(add-to-list 'ac-modes `nrepl-mode)) | |
;; hide the *nrepl-connection* and *nrepl-server* buffers from appearing in some buffer switching commands | |
(setq nrepl-hide-special-buffers t) | |
;; Start the nrepl | |
(global-set-key (kbd "<f12>") 'repl-jack-in) | |
;; auto-complete | |
(autoload 'ac-config-default "auto-complete-config") | |
(ac-config-default) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment