emacs/.emacs.d/init.el

320 lines
10 KiB
EmacsLisp
Raw Normal View History

;;; Emacs Config
;;;; indentation
2015-04-25 21:51:54 -04:00
(setq c-default-style "linux"
c-basic-offset 4
sgml-basic-offset 4)
2015-04-25 21:51:54 -04:00
(c-set-offset `inline-open 0)
(setq-default tab-width 4)
(add-hook 'sh-mode-hook (lambda () (setq tab-width 4)))
;;;; various options
2015-04-25 21:51:54 -04:00
(setq compilation-scroll-output 1
read-file-name-completion-ignore-case t
inhibit-startup-screen t
vc-follow-symlinks t
2015-11-19 16:24:55 -05:00
custom-file (expand-file-name "~/.emacs.d/custom.el")
gc-cons-threshold 100000000)
2016-01-20 21:19:21 -05:00
(setq-default show-trailing-whitespace t)
(load-theme 'fred t)
(savehist-mode 1)
2015-06-27 15:19:40 -04:00
(show-paren-mode 1)
(tool-bar-mode -1)
2015-04-25 21:51:54 -04:00
;;;; save backups and autosaves in tmp
(setq backup-directory-alist `((".*" . ,temporary-file-directory))
2015-11-19 16:24:55 -05:00
auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
2015-04-25 21:51:54 -04:00
;;;; keybinds
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
2015-04-25 21:51:54 -04:00
;;; Packages
;;;; install/load quelpa
(package-initialize)
2016-02-29 22:50:53 -05:00
(setq quelpa-update-melpa-p nil)
(unless (require 'quelpa nil t)
(with-temp-buffer
(url-insert-file-contents "https://raw.github.com/quelpa/quelpa/master/bootstrap.el")
(eval-buffer)))
2015-04-25 21:51:54 -04:00
;;;; install quelpa-use-package
(quelpa 'quelpa-use-package)
(require 'quelpa-use-package)
2015-04-25 21:51:54 -04:00
;;;; internal packages
2015-10-04 16:32:35 -04:00
(use-package ibuffer
:config
(global-set-key (kbd "C-x C-b") `ibuffer)
(setq ibuffer-saved-filter-groups
2015-11-19 16:24:55 -05:00
(quote (("default"
("emacs" (or
(name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$")))))))
2015-10-04 16:32:35 -04:00
(add-hook 'ibuffer-mode-hook (lambda ()
2015-11-19 16:24:55 -05:00
(ibuffer-auto-mode 1)
(setq ibuffer-show-empty-filter-groups nil))))
2015-10-04 16:32:35 -04:00
(use-package compile
:commands (compile recompile)
:bind ("C-z" . recompile)
:bind ("C-S-z" . compile)
:config
(add-hook 'compilation-start-hook (lambda (x) (setq-local scroll-up-aggressively 0))))
(use-package verilog-mode
:defer
:config
(setq verilog-indent-level 4
2015-11-19 16:24:55 -05:00
verilog-indent-level-behavioral 4
verilog-indent-level-declaration 4
verilog-indent-level-module 4
verilog-auto-newline nil)
(add-hook 'verilog-mode-hook (lambda () (setq indent-tabs-mode nil))))
(use-package python
:defer
:config
(if (executable-find "ipython")
(setq python-shell-interpreter "ipython")))
;;;; external packages (required)
(use-package company :quelpa
:config
(global-company-mode)
(setq company-idle-delay 0.1
2015-11-19 16:24:55 -05:00
company-dabbrev-downcase nil
2016-02-29 13:22:29 -05:00
company-dabbrev-ignore-case nil)
(global-set-key (kbd "<C-tab>") 'company-manual-begin))
(use-package smart-mode-line :quelpa
:config
(setq sml/no-confirm-load-theme t)
(sml/setup)
(sml/apply-theme 'respectful)
(add-to-list 'sml/replacer-regexp-list '("^~/Programs/" ":Prog:") t)
(add-to-list 'sml/replacer-regexp-list '("^:Doc:Google Drive/" ":GDrive:") t)
2016-02-18 23:42:31 -05:00
(add-to-list 'sml/replacer-regexp-list '("^:Doc:WPI/" ":WPI:") t)
(add-to-list 'sml/replacer-regexp-list '("^/sshx:ccc:" ":ccc:") t)
(add-to-list 'sml/replacer-regexp-list '("^:ccc:/home/asgoldsmith" ":ccc:~") t)
2016-03-01 15:03:28 -05:00
(setq rm-blacklist '(" company" " Undo-Tree" " ivy")))
(use-package avy :quelpa
:config
(eval-after-load "isearch"
'(define-key isearch-mode-map (kbd "C-'") 'avy-isearch))
:bind ("C-;" . avy-goto-char)
:bind ("C-'" . avy-goto-char-2))
(use-package smex :quelpa
:bind ("M-X" . smex-major-mode-commands))
(use-package counsel :quelpa
:config
(setq ivy-re-builders-alist
'((counsel-M-x . ivy--regex-fuzzy)
(t . ivy--regex-plus)))
(assq-delete-all 'counsel-M-x ivy-initial-inputs-alist)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command) ;;normal M-x.
2016-02-29 13:16:14 -05:00
:bind ("M-x" . counsel-M-x)
:bind ("C-M-y" . counsel-yank-pop))
(use-package ace-window :quelpa
:bind ("M-p" . ace-window))
(use-package undo-tree :quelpa
:config
(global-undo-tree-mode)
2015-08-25 12:09:10 -04:00
(global-set-key (kbd "M-/") 'undo-tree-visualize))
(use-package hydra :quelpa
:config
;config is in separate file because it is really big
(load-file "~/.emacs.d/init-hydra.el"))
(use-package multiple-cursors :quelpa)
2015-09-28 19:18:26 -04:00
(use-package expand-region :quelpa
:bind ("C-=" . er/expand-region))
(use-package company-quickhelp :quelpa
:config
(company-quickhelp-mode 1)
(setq company-quickhelp-delay 0.5))
(use-package magit :quelpa
:bind ("C-x g" . magit-status))
(use-package popwin :quelpa
:config
(popwin-mode 1))
2015-10-05 18:22:21 -04:00
(use-package cat-mode :quelpa
(cat-mode :fetcher github :repo "ad1217/emacs-cat-mode")
:config
(cat-mode 1)
(eval-after-load "ibuffer"
'(define-key ibuffer-mode-map (kbd "c") 'cat-set-ibuffer)))
2015-10-07 15:09:37 -04:00
(use-package dired+ :quelpa
:init
(setq diredp-hide-details-initially-flag nil)
2015-10-07 15:09:37 -04:00
:config
(toggle-diredp-find-file-reuse-dir 1))
2015-10-10 12:55:14 -04:00
(use-package outline-magic :quelpa
:config
(define-key outline-minor-mode-map (kbd "M-<tab>") 'outline-cycle))
;;;; optional external packages
(use-package arduino-mode
:mode "\\.pde\\'"
:mode "\\.ino\\'")
(use-package company-jedi
2015-11-17 16:12:00 -05:00
:init
(add-hook 'python-mode-hook (lambda()
(add-to-list 'company-backends 'company-jedi)
(jedi-mode)))
(setq jedi:use-shortcuts t
2015-11-19 16:24:55 -05:00
jedi:get-in-function-call-delay 500
jedi:tooltip-method nil)
2015-11-17 16:12:00 -05:00
:commands (jedi-mode))
(use-package gnuplot-mode
:mode ("\\.gp$" . gnuplot-mode))
(use-package markdown-mode
:config
(setq markdown-command "markdown_py -x markdown.extensions.wikilinks -x markdown.extensions.smarty -x markdown.extensions.extra -x latex -x markdown.extensions.sane_lists -x markdown.extensions.toc -x markdown_checklist.extension -c ~/.emacs.d/markdownConfig.yml"
2015-11-19 16:24:55 -05:00
markdown-enable-math t)
(local-set-key (kbd "<tab>") 'markdown-demote)
(local-set-key (kbd "S-<tab>") 'markdown-promote)
:mode "\\.md\\'")
2015-08-25 12:04:23 -04:00
(use-package scad-mode
2015-11-17 16:12:47 -05:00
:mode "\\.scad$"
:config
(defun scad-compile (ext)
2015-11-19 16:24:55 -05:00
"Compile current buffer using 'scad-command' and the extention 'ext'"
(interactive (list (completing-read "Extension: " '("stl" "off" "amf" "dxf" "svg" "csg" "png"))))
(compile (concat scad-command " -o " (file-name-sans-extension buffer-file-name) "." ext " " buffer-file-name)))
2015-11-17 16:12:47 -05:00
(define-key scad-mode-map (kbd "C-c z") 'scad-compile))
(use-package smart-tabs-mode
:config
(smart-tabs-insinuate 'c 'c++ 'javascript))
(use-package todotxt-mode
:config
2015-10-11 22:16:11 -04:00
(setq todotxt-default-file (expand-file-name "~/Sync/todo/todo.txt")
2015-11-19 16:24:55 -05:00
todotxt-default-archive-file (expand-file-name "~/Sync/todo/done.txt")
todotxt-due-tag "due"
todotxt-mode-keywords
'(("^x .*$" 0 '(:foreground "gray80" :strike-through t))
("^(A) " 0 '(:foreground "red"))
("^(B) " 0 '(:foreground "orange"))
("^(C) " 0 '(:foreground "teal"))
("^(D) " 0 '(:foreground "light green"))
("^(Y) " 0 '(:foreground "light grey"))
("([A-Z]+)" . font-lock-builtin-face)
("\\([a-zA-Z0-9_-]+\\):\\([a-zA-Z0-9._-]+\\)" . font-lock-variable-name-face)
("+\\w+" . font-lock-function-name-face)
("@\\w+" . font-lock-type-face)
("#important" 0 '(:foreground "orange red")) ; special tag
("#waiting" 0 '(:foreground "dark orange")) ; special tag
("#\\w+" . font-lock-comment-face)
("-\\([a-zA-Z_-]+\\)" . font-lock-variable-name-face)
("^[0-9]+-[0-9]+-[0-9]+" 0 '(:foreground "gray90")))))
2015-10-10 14:16:56 -04:00
(use-package latex
2015-08-29 13:43:41 -04:00
:config
(setq TeX-command-extra-options "-shell-escape")
(define-key LaTeX-mode-map (kbd "C-z")
2015-11-19 16:24:55 -05:00
'(lambda () (interactive)
(save-buffer)
(TeX-command "LaTeX" 'TeX-master-file -1)))
(define-key LaTeX-mode-map (kbd "C-c e") 'tex-close-latex-block)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(defun latex-tsv-to-table ()
2015-11-19 16:24:55 -05:00
"Converts tab-seperated-values to a LaTeX table."
(interactive)
(let ((beg (region-beginning)) (end-line (line-number-at-pos (region-end))))
(save-excursion
(goto-line end-line)
(indent-region beg (point-at-eol))
(replace-regexp "\t" " & " nil beg (point-at-eol))
(replace-regexp "$" " \\\\\\\\" nil beg (point-at-eol))
(align beg (point))))))
2015-09-28 19:21:04 -04:00
(use-package fasd
:config
(global-set-key (kbd "C-x C-S-f") 'fasd-find-file)
(global-fasd-mode 1)
2016-02-29 13:38:18 -05:00
(setq fasd-enable-initial-prompt nil
fasd-completing-read-function 'ivy-completing-read))
2015-09-17 12:52:19 -04:00
(use-package yasnippet
2015-12-17 00:20:12 -05:00
:defer
:init
(add-hook 'LaTeX-mode-hook
'(lambda ()
(yas-minor-mode)
(define-key company-active-map "<backtab>" 'company-to-yasnippet)
(define-key (current-local-map) "<backtab>" 'company-yasnippet)))
2015-09-17 12:52:19 -04:00
:config
2015-12-17 00:20:12 -05:00
(yas-reload-all)
2015-09-17 12:52:19 -04:00
(defun company-to-yasnippet ()
2015-11-19 16:24:55 -05:00
(interactive)
(company-abort)
2015-12-17 00:20:12 -05:00
(call-interactively 'company-yasnippet)))
2015-11-17 10:59:29 -05:00
(use-package swiper
:init
(global-set-key (kbd "C-S-s") 'isearch-forward)
(global-set-key (kbd "C-S-r") 'isearch-backward)
(ivy-mode 1)
:bind ("C-s" . swiper)
:bind ("C-r" . swiper))
(use-package highlight-indent-guides
:config
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode))
2015-12-17 00:03:25 -05:00
(use-package helm-dash
:config
(setq helm-dash-browser-func 'eww
2015-11-19 16:24:55 -05:00
helm-dash-enable-debugging nil)
2015-12-17 00:03:25 -05:00
(add-hook 'python-mode-hook
2015-11-19 16:24:55 -05:00
'(lambda ()(setq-local helm-dash-docsets '("Python 3")))))
2016-01-19 10:02:29 -05:00
(use-package pkgbuild-mode
:config
(setq pkgbuild-user-full-name "Adam Goldsmith"
pkgbuild-user-mail-address "contact@adamgoldsmith.name"
pkgbuild-makepkg-command "PKGEXT='.pkg.tar' makepkg -mf"))
2016-01-31 19:44:10 -05:00
(use-package mmm-mode
:config
(mmm-add-classes
'((latex-python
:submode python-mode
; :creation-hook (lambda () (local-set-key (kbd "C-z") 'latex-save-and-compile))
:face mmm-code-submode-face
:front "\\\\begin{python}\n"
:back "\\\\end{python}$")))
(mmm-add-mode-ext-class 'latex-mode nil 'latex-python)
(defun python-shell-send-overlay ()
(interactive)
(python-shell-send-region (previous-overlay-change (point)) (next-overlay-change (point))))
(add-hook 'mmm-python-submode-hook
(lambda ()
(local-set-key (kbd "C-c C-c") 'python-shell-send-overlay))))
;;; Local Variables
(add-to-list 'safe-local-eval-forms '(outline-hide-body))
;; Local Variables:
2015-11-19 16:26:59 -05:00
;; indent-tabs-mode: nil
;; eval: (outline-minor-mode)
;; eval: (outline-hide-body)
;; End: