Skip to content

Instantly share code, notes, and snippets.

@ccjoel
Forked from mowat27/init.el
Created April 15, 2020 16:35
Show Gist options
  • Save ccjoel/b992e20e982af285dffb43ab5386c7da to your computer and use it in GitHub Desktop.
Save ccjoel/b992e20e982af285dffb43ab5386c7da to your computer and use it in GitHub Desktop.
Emacs config for clojure + cider + paredit + auto-complete
(require 'package)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
(package-initialize)
(defvar my-packages '(clojure-mode
cider
paredit
auto-complete
highlight-parentheses
markdown-mode
ac-nrepl
)
"A list of packages to ensure are installed at launch.")
(package-refresh-contents)
(dolist (p my-packages)
(when (not (package-installed-p p))
(print (format "Installing %s" p))
(package-install p)))
(print "Setting core emacs settings")
(setq inhibit-startup-message t) ;; No splash screen
(setq initial-scratch-message nil) ;; No scratch message
;; Create backup files in .emacs-backup instead of everywhere
(defvar user-temporary-file-directory "~/.emacs-backup")
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,user-temporary-file-directory)
(,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
(concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
`((".*" ,user-temporary-file-directory t)))
(print "Setting up autocomplete")
(require 'auto-complete-config)
(require 'ac-nrepl)
(ac-config-default)
(add-hook 'cider-repl-mode-hook 'ac-nrepl-setup)
(add-hook 'cider-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
'(add-to-list 'ac-modes 'cider-repl-mode))
(print "Adding hooks")
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'clojurescript-mode-hook 'paredit-mode)
(setq cider-repl-pop-to-buffer-on-connect nil)
(require 'highlight-parentheses)
(add-hook 'clojure-mode-hook
(lambda ()
(highlight-parentheses-mode t)))
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-repl-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
(eval-after-load "cider"
'(define-key cider-mode-map (kbd "C-c C-d") 'ac-nrepl-popup-doc))
(print "Setting global keys")
(global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#")))
(global-set-key "\C-x\C-b" 'buffer-menu)
(global-unset-key (kbd "C-z")) ; Disable minimize frame key - it's too easy to mistake it for 'undo'
(setq ns-pop-up-frames nil) ; so we can send documents to the current frame from the command line
(global-set-key [C-tab] 'other-window)
(global-set-key [M-tab] 'other-frame)
(print "Setting colour theme")
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'twilight t)
(print "Init complete!")
;; Wish List
; Copy command
; Duplicate current line
; Delete current line (not C-a C-k)
; Multi-edit
; A way to flip the current buffer into a different window
(put 'dired-find-alternate-file 'disabled nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment