Skip to content

Instantly share code, notes, and snippets.

@DogLooksGood
Created October 12, 2016 17:37
Show Gist options
  • Save DogLooksGood/654cf6e66937eb42929784e2fe3033b3 to your computer and use it in GitHub Desktop.
Save DogLooksGood/654cf6e66937eb42929784e2fe3033b3 to your computer and use it in GitHub Desktop.
My emacs config file.
;; Minimal setup for Clojure development & Org document.
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives
'(("gnu-cn" . "http://elpa.zilongshanren.com/gnu/")
("melpa-cn" . "http://elpa.zilongshanren.com/melpa/")
("melpa-stable-cn" . " http://elpa.zilongshanren.com/melpa-stable/")
("marmalade-cn" . "http://elpa.zilongshanren.com/marmalade/")
("org-cn" . " http://elpa.zilongshanren.com/org/")))
(package-initialize)
(require 'benchmark-init)
(benchmark-init/activate)
;; -----------------------------------------------------------------------------
;; Use Package
;; -----------------------------------------------------------------------------
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(setq use-package-always-ensure t
use-package-always-defer t)
(require 'use-package)
;; -----------------------------------------------------------------------------
;; Basics
;; -----------------------------------------------------------------------------
(setq mac-option-modifier 'meta)
(setq frame-title-format "emacs")
(setq column-number-mode t)
(setq-default line-spacing 2)
(setq-default cursor-type 'bar)
(global-hl-line-mode -1)
(setq-default indent-tabs-mode nil)
(setq ring-bell-function 'ignore)
(setq inhibit-startup-screen t)
(tool-bar-mode -1)
(unless window-system
(menu-bar-mode -1))
(scroll-bar-mode -1)
(global-auto-revert-mode 5)
(setq-default indicate-empty-lines t)
(add-hook 'prog-mode-hook #'linum-mode)
(use-package ediff
:init
(setq ediff-window-setup-function 'ediff-setup-windows-plain))
(setq speedbar-tag-hierarchy-method nil)
;; --- Scroll ------------------------------------------------------------------
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))
mouse-wheel-progressive-speed nil
mouse-wheel-follow-mouse 't)
;; --- Encoding ----------------------------------------------------------------
(prefer-coding-system 'utf-8)
(setq buffer-file-coding-system 'utf-8-unix
default-file-name-coding-system 'utf-8-unix
default-keyboard-coding-system 'utf-8-unix
default-process-coding-system '(utf-8-unix . utf-8-unix)
default-sendmail-coding-system 'utf-8-unix
default-terminal-coding-system 'utf-8-unix)
;; --- Plugins -----------------------------------------------------------------
(when (memq window-system '(mac ns))
(use-package exec-path-from-shell
:init
(exec-path-from-shell-initialize)))
(use-package counsel
:bind
(("C-c g" . counsel-git)
("C-c G" . counsel-git-grep)
("C-c s" . swiper)
("C-c A" . counsel-ag)))
(use-package ivy
:init
(ivy-mode 1))
(use-package multiple-cursors
:bind
(("M-[" . mc/mark-next-like-this)
("M-]" . mc/skip-to-next-like-this)
("M-\\" . mc/mark-previous-like-this))
:init
(setq mc/always-run-for-all t))
(use-package highlight-symbol
:bind
(("M-p" . highlight-symbol-prev)
("M-n" . highlight-symbol-next))
:init
(add-hook 'prog-mode-hook #'highlight-symbol-mode))
(use-package projectile
:defer nil
:init
(projectile-global-mode 1))
(use-package company
:bind
(:map company-active-map
("C-n" . company-select-next)
("C-p" . company-select-previous))
:init
(add-hook 'eshell-mode-hook
(lambda ()
(bind-key "<tab>" 'company-complete-common eshell-mode-map)
(bind-key "TAB" 'company-complete-common eshell-mode-map)))
(add-hook 'clojure-mode-hook
(lambda ()
(bind-key "<tab>" 'company-indent-or-complete-common clojure-mode-map)
(bind-key "TAB" 'company-indent-or-complete-common clojure-mode-map)))
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(bind-key "<tab>" 'company-indent-or-complete-common emacs-lisp-mode-map)
(bind-key "TAB" 'company-indent-or-complete-common emacs-lisp-mode-map)))
(setq company-idle-delay nil)
(global-company-mode))
;; -----------------------------------------------------------------------------
;; Lisp
;; -----------------------------------------------------------------------------
(show-paren-mode t)
(use-package lispy
:init
(setq lispy-eval-display-style 'overlay))
(use-package rainbow-delimiters)
(use-package key-seq
:init
(key-chord-mode 1)
(add-hook 'clojure-mode-hook
(lambda ()
(key-seq-define clojure-mode-map ",." 'parinfer-lispy:forward)
(key-seq-define clojure-mode-map ".," 'parinfer-lispy:backward)))
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(key-seq-define emacs-lisp-mode-map ",." 'parinfer-lispy:forward)
(key-seq-define emacs-lisp-mode-map ".," 'parinfer-lispy:backward))))
(use-package parinfer
:bind
(:map parinfer-mode-map
("C-'" . parinfer-toggle-mode))
:init
(setq parinfer-lighters '(" PI:->" . " PI:()"))
(setq parinfer-extensions '(company pretty-parens smart-tab smart-yank))
(add-hook 'emacs-lisp-mode-hook 'parinfer-mode)
(add-hook 'clojure-mode-hook 'parinfer-mode))
;; -----------------------------------------------------------------------------
;; Clojure
;; -----------------------------------------------------------------------------
(use-package clojure-mode
:init
(add-hook 'clojure-mode-hook #'eldoc-mode))
;; -----------------------------------------------------------------------------
;; Cider
;; -----------------------------------------------------------------------------
(use-package cider
:init
(setq cider-lein-command "/usr/local/bin/lein")
(setq cider-boot-command "/usr/local/bin/boot")
(setq cider-cljs-lein-repl "(do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))")
(setq cider-use-overlays t))
;; -----------------------------------------------------------------------------
;; Clj Refactor
;; -----------------------------------------------------------------------------
(use-package yasnippet
:init
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
:config
(unbind-key "<tab>" yas-minor-mode-map))
(use-package clj-refactor
:init
(cljr-add-keybindings-with-prefix "C-.")
(add-hook 'clojure-mode-hook #'clj-refactor-mode)
(add-hook 'clojure-mode-hook #'yas-minor-mode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment