emacs/.emacs.d/init.el

357 lines
11 KiB
EmacsLisp

;;; Emacs Config
;;;; indentation
(setq c-default-style "linux"
c-basic-offset 4
sgml-basic-offset 4)
(c-set-offset `inline-open 0)
(setq-default tab-width 4)
(add-hook 'sh-mode-hook (lambda () (setq tab-width 4)))
;;;; various options
(setq compilation-scroll-output 1
read-file-name-completion-ignore-case t
inhibit-startup-screen t
vc-follow-symlinks t
custom-file (expand-file-name "~/.emacs.d/custom.el")
gc-cons-threshold 100000000)
(setq-default show-trailing-whitespace t)
(load-theme 'fred t)
(savehist-mode 1)
(show-paren-mode 1)
(column-number-mode 1)
(tool-bar-mode -1)
;;; enable disabled functions
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'narrow-to-region 'disabled nil)
;;;; save backups and autosaves in tmp
(setq backup-directory-alist `((".*" . ,temporary-file-directory))
auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
;;;; keybinds
(when (fboundp 'windmove-default-keybindings)
(windmove-default-keybindings))
;;; Packages
;;;; install/load quelpa
(package-initialize)
(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)))
;;;; install quelpa-use-package
(quelpa 'quelpa-use-package)
(require 'quelpa-use-package)
;;;; internal packages
(use-package ibuffer
:bind ("C-x C-b" . ibuffer)
:config
(setq ibuffer-saved-filter-groups
(quote (("default"
("emacs" (or
(name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$")))))))
(add-hook 'ibuffer-mode-hook (lambda ()
(ibuffer-auto-mode 1)
(setq ibuffer-show-empty-filter-groups nil))))
(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
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")))
(use-package tramp
:defer
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path '"/home/adam/asgoldsmith/install/bin/"))
;;;; external packages (required)
(use-package company :quelpa
:config
(global-company-mode)
(setq company-idle-delay 0.1
company-dabbrev-downcase nil
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)
(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)
(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 swiper :quelpa
:bind ("C-s" . swiper)
:bind ("C-r" . swiper)
:bind ("C-c C-r" . ivy-resume)
:init
(global-set-key (kbd "C-S-s") 'isearch-forward)
(global-set-key (kbd "C-S-r") 'isearch-backward)
:config
(ivy-mode 1)
(define-key swiper-map (kbd "C-r") 'ivy-previous-line-or-history)
(define-key ivy-minibuffer-map (kbd "C-'") 'ivy-avy))
(use-package counsel :quelpa
:bind ("M-x" . counsel-M-x)
:bind ("C-M-y" . counsel-yank-pop)
: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.)
(use-package ace-window :quelpa
:bind ("M-p" . ace-window))
(use-package undo-tree :quelpa
:config
(global-undo-tree-mode)
(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)
(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))
(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)))
(use-package dired+ :quelpa
:init
(setq diredp-hide-details-initially-flag nil)
:config
(toggle-diredp-find-file-reuse-dir 1))
(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-c-headers
:config
(add-to-list 'company-backends 'company-c-headers))
(use-package company-jedi
:init
(add-hook 'python-mode-hook (lambda()
(add-to-list 'company-backends 'company-jedi)
(jedi-mode)))
(setq jedi:use-shortcuts t
jedi:get-in-function-call-delay 500
jedi:tooltip-method nil)
:commands (jedi-mode))
(use-package company-statistics
:config
(company-statistics-mode))
(use-package dtrt-indent
:config
(dtrt-indent-mode 1))
(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"
markdown-enable-math t)
(local-set-key (kbd "<tab>") 'markdown-demote)
(local-set-key (kbd "S-<tab>") 'markdown-promote)
:mode "\\.md\\'")
(use-package projectile
:config
(projectile-global-mode)
(setq projectile-mode-line
'(:eval (if (file-remote-p default-directory)
" P"
(format " P[%s]" (projectile-project-name))))))
(use-package scad-mode
:mode "\\.scad$"
:config
(defun scad-compile (ext)
"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)))
(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
(setq todotxt-default-file (expand-file-name "~/Sync/todo/todo.txt")
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")))))
(use-package latex
:config
(setq-default TeX-command-extra-options "-shell-escape")
(defun latex-save-and-compile ()
(interactive)
(save-buffer)
(TeX-command "LaTeX" 'TeX-master-file -1))
(define-key LaTeX-mode-map (kbd "C-z") 'latex-save-and-compile)
(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 ()
"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))))))
(use-package fasd
:config
(global-set-key (kbd "C-x C-S-f") 'fasd-find-file)
(global-fasd-mode 1)
(setq fasd-enable-initial-prompt nil
fasd-completing-read-function 'ivy-completing-read))
(use-package yasnippet
: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)))
:config
(yas-reload-all)
(defun company-to-yasnippet ()
(interactive)
(company-abort)
(call-interactively 'company-yasnippet)))
(use-package highlight-indent-guides
:config
(add-hook 'prog-mode-hook 'highlight-indent-guides-mode))
(use-package helm-dash
:config
(setq helm-dash-browser-func 'eww
helm-dash-enable-debugging nil)
(add-hook 'python-mode-hook
'(lambda ()(setq-local helm-dash-docsets '("Python 3")))))
(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"))
(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))))
(use-package qml-mode
:mode "\\.qml\\'")
;;; Local Variables
(add-to-list 'safe-local-eval-forms '(outline-hide-body))
;; Local Variables:
;; indent-tabs-mode: nil
;; eval: (outline-minor-mode)
;; eval: (outline-hide-body)
;; End: