Last active
November 30, 2016 03:44
-
-
Save efranford/f50837e18db6ae1694cdd822b3f57c5e to your computer and use it in GitHub Desktop.
My emacs init.el. I'll try to keep it updated :)
This file contains hidden or 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
;;; init.el --- Satisfy flycheck | |
;;; Commentary: | |
;;; Code: | |
;;;; | |
;;;; cygwin support | |
;;;; | |
;; Sets your shell to use cygwin's bash, if Emacs finds it's running | |
;; under Windows and c:\cygwin exists. Assumes that C:\cygwin\bin is | |
;; not already in your Windows Path (it generally should not be). | |
;; | |
(add-to-list 'load-path "~/.emacs.d/lisp") | |
(require 'package) | |
(add-to-list 'package-archives | |
'("melpa-stable" . "https://stable.melpa.org/packages/") t) | |
(add-to-list 'package-archives | |
'("melpa" . "https://melpa.org/packages/")) | |
(package-initialize) | |
(add-hook 'dired-load-hook '(lambda () (require 'dired-x))) | |
(setq dired-omit-mode t) | |
(setq dired-omit-files "^\.$|.*~$") | |
(setq completion-ignored-extensions | |
(append completion-ignored-extensions (quote ("~" ".pyc")))) | |
(autoload | |
'ace-jump-mode | |
"ace-jump-mode" | |
"Emacs quick move minor mode" | |
t) | |
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode) | |
;; describe-unbound-keys | |
(eval-when-compile (require 'cl)) ; for `dotimes', `push' (Emacs 21) | |
(defcustom unbound-modifiers '(control meta shift) | |
"Modifiers to consider when searching for unbound keys." | |
:type '(set (const control) (const meta) (const shift) | |
(const super) (const hyper) (const alt))) | |
(defvar unbound-key-list | |
(let (keys) | |
(dotimes (i (- ?\d ?\ -1)) | |
(push (+ i ?\ ) keys)) | |
(dotimes (i 12) | |
(push (intern (format "f%s" (1+ i))) keys)) | |
(append '(?\t ?\r ?\e) (nreverse keys) | |
'(insert delete home end prior next up down left right))) | |
"Keys to consider when searching for unbound keys.") | |
(defun key-complexity (key) | |
"Return a complexity score for key sequence KEY. | |
Currently KEY must be of the [(control shift ?s) ...] format." | |
(let ((ret 0)) | |
(dotimes (i (length key) ret) | |
(setq ret (+ ret (* i 2) (key-complexity-1 (aref key i))))))) | |
;; This is somewhat biased for US keyboards. | |
(defun key-complexity-1 (key) ; key:=(modifiers... key) | |
(+ (if (memq 'control key) 1 0) | |
(if (memq 'meta key) 2 0) | |
(if (memq 'shift key) 3 0) | |
(if (memq 'super key) 4 0) | |
(if (memq 'hyper key) 4 0) | |
(if (memq 'alt key) 3 0) | |
(* 2 (1- (length key))) | |
(progn | |
(setq key (car (last key))) | |
(if (integerp key) | |
(cond ((and (>= key ?a) (<= key ?z)) 0) | |
((and (>= key ?A) (<= key ?Z)) 6) ; capitals are weird | |
((and (>= key ?0) (<= key ?9)) 2) | |
((memq key '(?\b ?\r ?\ )) 1) | |
;; Unshifted punctuation (US keyboards) | |
((memq key '(?` ?- ?= ?\t ?[ ?] ?\\ ?\; ?' ?, ?. ?/)) 3) | |
;; Other letters -- presume that one's keyboard has them if | |
;; we're going to consider binding them. | |
((let (case-fold-search) | |
(string-match | |
"[016A]" (category-set-mnemonics | |
(char-category-set key)))) 2) | |
(t 5)) | |
7)))) | |
(add-to-list 'package-archives | |
'("melpa" . "https://melpa.org/packages/") t) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))) | |
(package-initialize) | |
(defun copy-from-osx () | |
(shell-command-to-string "pbpaste")) | |
(defun paste-to-osx (text &optional push) | |
(let ((process-connection-type nil)) | |
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy"))) | |
(process-send-string proc text) | |
(process-send-eof proc)))) | |
(setq interprogram-cut-function 'paste-to-osx) | |
(setq interprogram-paste-function 'copy-from-osx) | |
(require 'helm-config) | |
(require 'yaml-mode) | |
(require 'helm-ls-git) | |
(global-set-key (kbd "C-<f6>") 'helm-ls-git-ls) | |
(global-set-key (kbd "M-x") 'helm-M-x) | |
(global-set-key (kbd "M-y") 'helm-show-kill-ring) | |
(global-set-key (kbd "C-x b") 'helm-mini) | |
(global-set-key (kbd "C-x C-f") 'helm-find-files) | |
(setq helm-M-x-fuzzy-match t) ;; optional fuzzy matching for helm-M-x | |
(setq helm-buffers-fuzzy-matching t | |
helm-recentf-fuzzy-match t) | |
(helm-mode 1) | |
(window-numbering-mode 1) | |
(when (memq window-system '(mac ns)) | |
(exec-path-from-shell-initialize)) | |
;; (exec-path-from-shell-copy-env "PYTHONPATH") | |
;; (exec-path-from-shell-copy-env "PATH") | |
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)) | |
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode)) | |
(load-theme 'tsdh-dark) | |
(setq backup-directory-alist `(("." . "~/.saves"))) | |
;; get rid of that damn menubar | |
(menu-bar-mode -1) | |
(require 'json) | |
(require 'cl-lib) | |
(require 'files) | |
(require 'ido) | |
(require 'thingatpt) | |
(require 'dash) | |
(require 'compile) | |
(require 'dired) | |
(require 'popup) | |
(require 'etags) | |
(require 'flycheck) | |
(require 's) | |
(require 'multi-term) | |
(require 'nose) | |
(global-flycheck-mode) | |
(add-to-list 'load-path (expand-file-name (concat (file-name-directory (or load-file-name buffer-file-name)) "/src/"))) | |
(add-to-list 'load-path (expand-file-name (concat (file-name-directory (or load-file-name buffer-file-name)) "/src/actions"))) | |
;; (require 'omnisharp-utils) | |
;; (require 'omnisharp-server-actions) | |
;; (require 'omnisharp-auto-complete-actions) | |
;; (require 'omnisharp-settings) | |
(require 'flymake-jslint) | |
(require 'flymake-json) | |
(require 'highlight-parentheses) | |
(add-hook 'json-mode 'flymake-json-load) | |
(add-hook 'find-file-hook 'flymake-json-maybe-load) | |
(add-hook 'js-mode-hook 'flymake-jslint-load) | |
(setq web-mode-markup-indent-offset 2 | |
web-mode-css-indent-offset 2 | |
web-mode-code-indent-offset 2) | |
(setq js-indent-level 2) | |
(add-hook 'projectile-after-switch-project-hook 'mjs/setup-local-eslint) | |
(eval-after-load 'js-mode | |
'(add-hook 'js-mode-hook #'add-node-modules-path)) | |
(eval-after-load 'js2-mode | |
'(add-hook 'js2-mode-hook #'add-node-modules-path)) | |
(with-eval-after-load 'flycheck | |
(push 'web-mode (flycheck-checker-get 'javascript-eslint 'modes))) | |
(defun mjs/setup-local-eslint () | |
(interactive) | |
(let ((local-eslint (expand-file-name "./node_modules/.bin/eslint"))) | |
(setq flycheck-javascript-eslint-executable | |
(and (file-exists-p local-eslint) local-eslint)))) | |
;; Quiet the byte compiler | |
(defvar unbound-keys nil | |
"Used internally by `unbound-keys'.") | |
(defun unbound-keys (max) | |
"Return a list of unbound keystrokes of complexity no greater than MAX. | |
Keys are sorted by their complexity; `key-complexity' determines it." | |
(let (unbound-keys) | |
(unbound-keys-1 max nil nil) | |
(mapcar 'car (sort unbound-keys (lambda (k l) (< (cdr k) (cdr l))))))) | |
;; Adds to `unbound-keys'. | |
(defun unbound-keys-1 (max map pfx) | |
(dolist (base unbound-key-list) | |
(dotimes (modi (lsh 1 (length unbound-modifiers))) | |
(let ((key (list base))) | |
(dotimes (j (length unbound-modifiers)) | |
(unless (zerop (logand modi (lsh 1 j))) | |
(push (nth j unbound-modifiers) key))) | |
(let ((total (vconcat pfx (list key))) comp) | |
;; Don't use things that get translated and bound. This isn't | |
;; perfect: it assumes that the entire key sequence is translated. | |
(unless (or (let ((trans (lookup-key function-key-map total))) | |
(and (vectorp trans) (key-binding trans))) | |
;; Don't add `shift' to any graphic character; can't | |
;; type it, or it's redundant. | |
(and (memq 'shift key) (integerp base) | |
(> base ?\ ) (<= base ?~)) | |
;; Don't add `control' when it generates another | |
;; character we use: | |
(and (memq 'control key) (integerp base) | |
(< base ?`) | |
(memq (- base 64) unbound-key-list)) | |
;; Limit the total complexity: | |
(> (setq comp (key-complexity total)) max)) | |
(let ((res (if map (lookup-key map (vector key)) | |
(key-binding (vector (if (cdr key) key (car key))))))) | |
(cond ((keymapp res) | |
;; Don't add anything after an ESC, to avoid Meta | |
;; confusion. | |
(unless (eq base ?\e) | |
(unbound-keys-1 max res total))) | |
(res) | |
(t (push (cons total comp) unbound-keys)))))))))) | |
;;;###autoload | |
(defun describe-unbound-keys (max) | |
"Display a list of unbound keystrokes of complexity no greater than MAX. | |
Keys are sorted by their complexity; `key-complexity' determines it." | |
(interactive "nMaximum key complexity: ") | |
(with-output-to-temp-buffer "*Unbound Keys*" | |
(let ((keys (unbound-keys max))) | |
(princ (format "%s unbound keys with complexity at most %s:\n" | |
(length keys) max)) | |
(princ (mapconcat 'key-description keys "\n"))))) | |
(setq-default fill-column 80) | |
(add-hook 'js-mode-hook | |
'(lambda () (setq indent-tabs-mode nil))) | |
(add-hook 'python-mode-hook | |
'(lambda () (setq indent-tabs-mode nil))) | |
(add-hook 'python-mode-hook | |
'(lambda () (setq tab-width 8))) | |
(add-hook 'go-mode-hook | |
'(lambda () (setq tab-width 4))) | |
(setq-default buffer-file-coding-system 'utf-8-unix) | |
(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. | |
'(column-number-mode t) | |
'(custom-enabled-themes (quote (zenburn))) | |
'(custom-safe-themes | |
(quote | |
("c4465c56ee0cac519dd6ab6249c7fd5bb2c7f7f78ba2875d28a50d3c20a59473" "001d6425a6e5180a5e966d5be64b983e82dbf3fd92592f3637baa47ee59ba59e" default))) | |
'(fill-column 80) | |
'(inhibit-startup-screen t) | |
'(initial-scratch-message nil) | |
'(menu-bar-mode nil) | |
'(scroll-bar-mode nil) | |
'(tool-bar-mode nil)) | |
(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. | |
) | |
(provide 'init) | |
(osx-clipboard-mode +1) | |
(add-to-list 'load-path "/path/to/frame-tag") | |
;;; init.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment