Skip to content

Instantly share code, notes, and snippets.

@joshuaNjordan85
Created December 6, 2016 12:08
Show Gist options
  • Save joshuaNjordan85/65077d2370f5bb9c5dbcea79cd11bb4d to your computer and use it in GitHub Desktop.
Save joshuaNjordan85/65077d2370f5bb9c5dbcea79cd11bb4d to your computer and use it in GitHub Desktop.
;;; package --- init.el
;;; Commentary:
;;; Code:
(setq message-log-max 10000)
(require 'package)
(setq package-enable-at-startup nil)
(setq package-archives '(("melpa-stable" . "https://stable.melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")))
(unless (file-directory-p "~/.emacs.d/elpa/archives")
(package-refresh-contents))
(package-initialize)
(setq quelpa-update-melpa-p nil)
(unless (require 'quelpa nil t)
(with-temp-buffer
(url-insert-file-contents (concat "https://raw.github.com/quelpa"
"/quelpa/master/bootstrap.el"))
(eval-buffer)))
;; install use-package and the quelpa handler
(quelpa '(use-package
:fetcher github
:repo "jwiegley/use-package"))
(quelpa '(quelpa-use-package
:fetcher github
:repo "quelpa/quelpa-use-package"))
(require 'quelpa-use-package)
(setq use-package-always-ensure t)
(quelpa-use-package-activate-advice)
;;; Helper functions
(defun linum-off ()
"Disable line numbers in the left margin."
(linum-mode -1))
;;; Packages
;;;; settings
;;;;; global-settings
(use-package global-settings
:ensure nil
:init
(menu-bar-mode -1)
(setq inhibit-startup-message t
require-final-newline t
vc-follow-symlinks t)
(setq-default indent-tabs-mode nil)
(setq tab-width 4)
(add-hook 'before-save-hook #'delete-trailing-whitespace)
(global-auto-revert-mode)
(winner-mode)
(put 'narrow-to-region 'disabled nil)
(put 'scroll-left 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(defadvice terminal-init-screen
;; The advice is named `tmux', and is run before
;; `terminal-init-screen' runs.
(before tmux activate)
;; Docstring. This describes the advice and is made available inside
;; emacs; e.g. when doing C-h f terminal-init-screen RET
"Apply xterm keymap, allowing use of keys passed through tmux."
;; This is the elisp code that is run before `terminal-init-screen'.
(if (getenv "TMUX")
(let ((map (copy-keymap xterm-function-map)))
(set-keymap-parent map (keymap-parent input-decode-map))
(set-keymap-parent input-decode-map map))))
(define-key key-translation-map (kbd "<backtab>") (kbd "<S-tab>"))
(define-key key-translation-map (kbd "\e[9;3") (kbd "<M-tab>"))
(define-key key-translation-map (kbd "\e[44;6") (kbd "C-,"))
(define-key key-translation-map (kbd "\e[46;6") (kbd "C-."))
(define-key key-translation-map (kbd "\e[65;6") (kbd "C-S-a"))
(define-key key-translation-map (kbd "\e[68;6") (kbd "C-S-d"))
(define-key key-translation-map (kbd "\e[86;8") (kbd "C-M-S-v"))
(provide 'global-settings))
;;;;; backup-settings
(use-package backup-settings
:ensure nil
:init
(defvar --backup-directory (concat user-emacs-directory "backups"))
(if (not (file-exists-p --backup-directory))
(make-directory --backup-directory t))
(setq backup-directory-alist `(("." . ,--backup-directory))
vc-make-backup-files t ; backup versioned files
make-backup-files t ; backup of a file the first time it is saved.
backup-by-copying t ; don't clobber symlinks
version-control t ; version numbers for backup files
delete-old-versions t ; delete excess backup files silently
kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2)
kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2)
auto-save-default t ; auto-save every buffer that visits a file
auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30)
auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300)
)
(define-minor-mode sensitive-mode
"For sensitive files like password lists.
It disables backup creation and auto saving.
With no argument, this command toggles the mode.
Non-null prefix argument turns on the mode.
Null prefix argument turns off the mode."
;; The initial value.
nil
;; The indicator for the mode line.
" Sensitive"
;; The minor mode bindings.
nil
(if (symbol-value sensitive-mode)
(progn (set (make-local-variable 'backup-inhibited) t)
(if auto-save-default
(auto-save-mode -1)))
(kill-local-variable 'backup-inhibited)
(if auto-save-default
(auto-save-mode 1))))
(add-to-list 'auto-mode-alist '("\\id_rsa.*\\'" . sensitive-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(provide 'backup-settings))
;;;;; visual-settings
(use-package visual-settings
:ensure nil
:init
(line-number-mode) ; line numbers in the mode line
(column-number-mode) ; column numbers in the mode line
(global-hl-line-mode) ; highlight current line
(global-linum-mode) ; add line numbers on the left
(provide 'visual-settings))
;;;;; zenburn-theme
(use-package zenburn-theme
:quelpa (zenburn-theme :fetcher github
:repo "bbatsov/zenburn-emacs")
:config (set-face-background 'hl-line "color-240"))
;;;;; company
(use-package company
:diminish company-mode
:init (add-hook 'after-init-hook #'global-company-mode)
:bind ("<M-tab>" . company-complete))
(use-package eldoc
:ensure nil
:diminish eldoc-mode
:commands eldoc-mode
:init
(add-hook 'emacs-lisp-mode-hook #'eldoc-mode)
(add-hook 'cider-mode-hook #'eldoc-mode)
(add-hook 'cider-repl-mode-hook #'eldoc-mode)
(add-hook 'ensime-mode-hook #'eldoc-mode))
;;;;; projectile
(use-package projectile
:config (projectile-global-mode))
;;;;; helm
(use-package helm
:config
(require 'helm-config)
:bind (("C-x b" . helm-buffers-list)
("M-x" . helm-M-x)))
;;;;; helm-projectile
(use-package helm-projectile
:config
(setq projectile-switch-project-action 'helm-projectile)
(helm-projectile-on))
;;;;; rainbow-delimiters
(use-package rainbow-delimiters
:config
(add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
(add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode))
;;;;; clojure-mode
(use-package clojure-mode-extra-font-locking)
(use-package clojure-mode
:config
(defun configure-clojure-indent ()
(define-clojure-indent
(GET 'defun)
(POST 'defun)
(PUT 'defun)
(DELETE 'defun)
(HEAD 'defun)
(ANY 'defun)
(checking 'defun)))
(add-hook 'clojure-mode-hook #'configure-clojure-indent))
;;;;; cider
(use-package cider
:config
(setq cider-repl-history-size 100000
cider-repl-history-file "~/.emacs.d/cider-repl-history.eld")
(defvar cider-cljs-lein-repl
"(do (use 'figwheel-sidecar.repl-api) (start-figwheel!) (cljs-repl))")
(put 'cider-cljs-lein-repl 'safe-local-variable #'stringp))
;;;;; smartparens
(use-package smartparens
:diminish smartparens-mode
:config
(sp-use-smartparens-bindings)
(show-smartparens-global-mode)
(smartparens-global-strict-mode)
(require 'smartparens-config)
(set-face-background 'sp-show-pair-match-face "deep sky blue")
(set-face-foreground 'sp-show-pair-match-face "white"))
;;;; version control
;;;;; magit
(use-package magit
:bind ("C-x C-z" . magit-status))
;;;;; gist
(use-package gh
:quelpa (gh :fetcher github
:repo "sigma/gh.el"
:stable t))
(use-package gist
:quelpa (gist :fetcher github
:repo "defunkt/gist.el"
:stable t))
;;;;; git-gutter
(use-package git-gutter
:diminish git-gutter-mode
:init
(git-gutter:linum-setup)
(global-git-gutter-mode)
:bind (("C-x C-g" . git-gutter-mode)
("C-x v =" . git-gutter:popup-hunk)))
;;;;; pbcopy
(use-package pbcopy
:quelpa (pbcopy :fetcher github
:repo "emacsfodder/pbcopy.el")
:config (turn-on-pbcopy))
;;;; js2-mode
(use-package js2-mode
:quelpa (js2-mode :fetcher github
:repo "mooz/js2-mode"))
;;;; mocha
(use-package mocha
:quelpa (mocha :fetcher github
:repo "scottaj/mocha.el"))
;;;; go
(use-package go-mode
:quelpa (go-mode :fetcher github
:repo "dominikh/go-mode.el"
:files ("go-mode.el")))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(zenburn-theme smartparens rainbow-delimiters quelpa-use-package pbcopy magit helm-projectile git-gutter gist company clojure-mode-extra-font-locking cider))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment