emacs/.emacs.d/init.el

548 lines
18 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)
(load-theme 'fred t)
(savehist-mode 1)
2015-06-27 15:19:40 -04:00
(show-paren-mode 1)
2016-03-01 15:19:56 -05:00
(column-number-mode 1)
(tool-bar-mode -1)
;;;; not sure where to put this
(defun open-thunar-in-current-directory ()
(interactive)
(call-process "thunar" nil 0 nil "."))
2015-04-25 21:51:54 -04:00
2016-03-01 15:18:30 -05:00
;;; 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))
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
;;; Packages
;;;; install/load quelpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(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
:bind ("C-x C-b" . ibuffer)
2015-10-04 16:32:35 -04:00
:config
(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)
("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
2016-09-19 23:43:02 -04:00
verilog-auto-newline nil
verilog-linter "verilator --lint-only")
2016-09-19 23:50:42 -04:00
(add-hook 'verilog-mode-hook (lambda () (setq indent-tabs-mode nil)))
(add-to-list 'company-keywords-alist (cons 'verilog-mode verilog-keywords)))
(use-package python
:defer
:config
2016-09-13 13:19:09 -04:00
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "-i --simple-prompt")
(add-to-list 'python-shell-completion-native-disabled-interpreters "ipython")))
(use-package tramp
2017-08-05 12:35:19 -04:00
:bind ("C-c C-f" . find-file-as-root)
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
(add-to-list 'tramp-remote-path '"/home/adam/asgoldsmith/install/bin/")
2017-08-05 12:35:19 -04:00
(setq tramp-default-method "ssh")
(defun find-file-as-root ()
(interactive)
(find-file (concat "/sudo::" (buffer-file-name)))))
(use-package comint
:config
(setq-default comint-scroll-to-bottom-on-input t ; always insert at the bottom
comint-scroll-to-bottom-on-output nil ; always add output at the bottom
comint-scroll-show-maximum-output t ; scroll to show max possible output
;; comint-completion-autolist t ; show completion list when ambiguous
comint-input-ignoredups t ; no duplicates in command history
comint-completion-addsuffix t ; insert space/slash after file completion
comint-buffer-maximum-size 20000 ; max length of the buffer in lines
comint-get-old-input (lambda () "") ; what to run when i press enter on a
; line above the current prompt
comint-input-ring-size 500) ; max shell history size
(add-hook 'comint-mode-hook
'(lambda () (setq-local show-trailing-whitespace nil))))
2016-04-25 23:54:45 -04:00
(use-package semantic
:defer
:init
(add-hook 'c-mode-hook 'semantic-mode)
2016-04-25 23:54:45 -04:00
:config
(setq semantic-default-submodes '(global-semantic-idle-scheduler-mode
global-semanticdb-minor-mode
global-semantic-decoration-mode
global-semantic-highlight-func-mode
global-semantic-show-unmatched-syntax-mode
global-semantic-idle-summary-mode
global-semantic-stickyfunc-mode
global-semantic-idle-local-symbol-highlight-mode)
semantic-idle-scheduler-idle-time 0.2)
; inhibit semantic outside of specific modes
(setq semantic-inhibit-functions
#'(lambda () (not (member major-mode '(c-mode cc-mode java-mode)))))
(eval-after-load "cc-mode"
'(define-key c-mode-map (kbd "M-.") 'semantic-ia-fast-jump)))
2016-04-25 23:54:45 -04:00
2016-04-07 20:34:51 -04:00
(use-package term
:config
(add-hook 'term-mode-hook
'(lambda () (setq-local
;if this is t, it breaks shell-command
comint-prompt-read-only nil))))
(use-package gud
:config
(add-hook 'gud-mode-hook
'(lambda () (setq-local comint-prompt-read-only t))))
2016-04-07 20:34:51 -04:00
(use-package whitespace
:config
(define-minor-mode whitespace-longlines-mode
:lighter " ll"
:init-value nil
:global nil
:group 'whitespace
(let ((whitespace-style '(face lines-tail)))
(whitespace-mode (if whitespace-longlines-mode
1 -1)))
;; sync states (running a batch job)
(setq whitespace-longlines-mode whitespace-mode))
(add-hook 'prog-mode-hook #'whitespace-longlines-mode))
2016-09-19 23:46:41 -04:00
(use-package org
:defer
:bind (:map org-mode-map ("C-z" . org-latex-export-to-pdf))
2016-09-19 23:46:41 -04:00
:config
;; Make windmove work in org-mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)
;; enable line wraping
(add-hook 'org-mode-hook '(lambda ()
(visual-line-mode)
(setq word-wrap t)))
(setq org-confirm-babel-evaluate nil)
(add-to-list 'org-babel-load-languages '(dot . t))
(add-to-list 'org-src-lang-modes '("dot" . graphviz-dot)))
(use-package windmove
:config
(windmove-default-keybindings))
(use-package help-mode
:config
; bind "g" to revert help buffers with no prompt
(bind-key "g" (lambda () (interactive) (revert-buffer t t)) help-mode-map))
(use-package files
:config
; bind a key to revert buffers with no prompt
(bind-key "C-x M-v" (lambda () (interactive) (revert-buffer t t t))))
(use-package prog-mode
:config
(add-hook 'prog-mode-hook
#'(lambda () (setq-local show-trailing-whitespace t))))
;;;; external packages (required)
(use-package company :ensure
: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)
(bind-key "<C-tab>" 'company-manual-begin))
(use-package smart-mode-line :ensure
:config
(setq sml/no-confirm-load-theme t)
(sml/setup)
(sml/apply-theme 'respectful)
(setq sml/replacer-regexp-list '(("^~/\\.dotfiles/" ":dots:")
("^:dots:emacs/\\.emacs\\.d/" ":ED:")
("^~/Documents/" ":Doc:")
("^~/Programs/" ":Prog:")
("^:Doc:WPI/" ":WPI:")
("^/sshx:ccc:" ">ccc:")
("^>ccc:/home/asgoldsmith" ":>ccc:~"))
rm-blacklist '(" company" " Undo-Tree" " ivy")))
(use-package avy :ensure
:config
(eval-after-load "isearch"
'(define-key isearch-mode-map (kbd "C-'") 'avy-isearch))
:bind (("C-;" . avy-goto-char)
("C-'" . avy-goto-char-2)))
(use-package smex :ensure
:bind ("M-X" . smex-major-mode-commands))
(use-package swiper :ensure
:bind (("C-s" . swiper)
("C-r" . swiper)
("C-c C-r" . ivy-resume)
:map swiper-map ("C-r" . ivy-previous-line-or-history)
:map ivy-minibuffer-map ("C-'" . ivy-avy))
2016-03-02 02:08:41 -05:00
:init
(bind-key "C-S-s" 'isearch-forward)
(bind-key "C-S-r" 'isearch-backward)
2016-03-02 02:15:30 -05:00
:config
(ivy-mode 1)
(defun ivy-backward-delete-char ()
"Forward to `backward-delete-char'.
Do less dumb things with directories
On error (read-only), call `ivy-on-del-error-function'."
(interactive)
(if (and ivy--directory (= (minibuffer-prompt-end) (point)))
(progn
(let ((old-dir (file-name-nondirectory
(directory-file-name
(expand-file-name
ivy--directory)))))
(ivy--cd (file-name-directory
(directory-file-name
(expand-file-name
ivy--directory))))
(insert old-dir))
(ivy--exhibit))
(condition-case nil
(backward-delete-char 1)
(error
(when ivy-on-del-error-function
(funcall ivy-on-del-error-function)))))))
2016-03-02 02:08:41 -05:00
2017-04-09 22:11:36 -04:00
(use-package ivy-hydra :ensure)
(use-package counsel :ensure
:bind (("M-x" . counsel-M-x)
("C-M-y" . counsel-yank-pop)
("C-x C-f" . counsel-find-file)
:map counsel-find-file-map ("C-M-i" . counsel-find-file-edit-path))
:init
(bind-key "C-c C-c M-x" 'execute-extended-command) ;;normal M-x.
: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)
(defun counsel-find-file-edit-path ()
"Edit the current path in ivy find-file"
(interactive)
(let ((old-path
(substring (concat (expand-file-name ivy--directory) ivy-text) 1 -1)))
(ivy--cd "/")
(insert old-path))))
(use-package ace-window :ensure
:bind ("M-p" . ace-window))
(use-package undo-tree :ensure
:config
(bind-key "M-/" 'undo-tree-visualize)
(global-undo-tree-mode))
(use-package hydra :ensure
:config
;config is in separate file because it is really big
(load-file "~/.emacs.d/init-hydra.el"))
(use-package multiple-cursors :ensure)
(use-package expand-region :ensure
2015-09-28 19:18:26 -04:00
:bind ("C-=" . er/expand-region))
(use-package company-quickhelp :ensure
:config
(company-quickhelp-mode 1)
(setq company-quickhelp-delay 0.5))
(use-package magit :ensure
:bind ("C-x g" . magit-status))
(use-package popwin :ensure
: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)
(bind-key "C-x C-M-C" 'kill-this-cat-kill-terminal)
(eval-after-load "ibuffer"
'(define-key ibuffer-mode-map (kbd "c") 'cat-set-ibuffer)))
(use-package dired+ :ensure
:init
(setq diredp-hide-details-initially-flag nil)
2015-10-07 15:09:37 -04:00
:config
(toggle-diredp-find-file-reuse-dir 1))
(use-package outline-magic :ensure
:demand
:bind (:map outline-minor-mode-map ("M-<tab>" . outline-cycle)))
;;;; optional external packages
(use-package arduino-mode
:mode "\\.pde\\'"
:mode "\\.ino\\'")
2017-02-24 01:11:33 -05:00
(use-package circe
:config
(setq circe-default-nick "ad1217"
circe-reduce-lurker-spam t)
(enable-circe-color-nicks)
(setq circe-network-options
'(("Freenode"
:tls t
:nick "ad1217"
:sasl-username "ad1217"
:sasl-password "ablablop"
:channels ("#emacs-circe" "#qutebrowser" "#archlinux" "##linux"))
2017-02-24 01:11:33 -05:00
("WPI"
:host "irc.wpiirc.net"
:port 9999
:use-tls t))
circe-default-part-message ""))
2017-02-24 01:11:33 -05:00
2016-03-01 15:13:03 -05:00
(use-package company-c-headers
:config
(add-to-list 'company-backends 'company-c-headers))
(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))
2016-03-01 15:16:35 -05:00
(use-package company-statistics
:config
(company-statistics-mode))
2016-03-01 15:16:49 -05:00
(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"
2015-11-19 16:24:55 -05:00
markdown-enable-math t)
:bind (:map markdown-mode-map
("<tab>" . markdown-demote)
("S-<tab>" . markdown-promote))
:mode "\\.md\\'")
2016-03-01 15:11:53 -05:00
(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)))))
:bind (:map projectile-mode-map ("C-S-z" . projectile-compile-project)))
2016-03-01 15:11:53 -05:00
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)))
:bind (:map scad-mode-map ("C-c z" . scad-compile)))
(use-package smart-tabs-mode
:config
(smart-tabs-insinuate 'c 'c++ 'javascript))
(use-package todotxt-mode
:commands (todotxt-open-file todotxt-mode)
:bind ("C-c t" . todotxt-open-file)
:init
(setq todotxt-base-path (expand-file-name "~/Documents/todo")
todotxt-default-file (concat todotxt-base-path "/todo.txt")
todotxt-default-archive-file (concat todotxt-base-path "/done.txt"))
(add-to-list 'auto-mode-alist `(,(concat todotxt-base-path "/.*\\.txt$") . todotxt-mode))
:config
(setq todotxt-due-tag "due"
2015-11-19 16:24:55 -05:00
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"))))
(defun todotxt-open-sub ()
"Opens the todotxt sub on current line"
(interactive)
(let ((line (thing-at-point 'line t)))
(string-match "\\([^ ]+\\)/:\\([.A-Za-z0-9_]+\\)" line)
(find-file (concat (match-string 1 line) "/" (match-string 2 line))))))
2015-10-10 14:16:56 -04:00
(use-package latex
:bind (:map LaTeX-mode-map
("C-z" . latex-save-and-compile)
("C-c e" . tex-close-latex-block))
2015-08-29 13:43:41 -04:00
:config
(setq-default TeX-command-extra-options "-shell-escape")
(defun latex-save-and-compile ()
(interactive)
(save-buffer)
(TeX-command "LaTeX" 'TeX-master-file -1))
(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-fasd-mode 1)
(bind-key "C-x C-S-f" 'fasd-find-file)
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)))
(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"
2016-03-01 15:12:30 -05:00
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))))
2016-03-01 15:23:17 -05:00
(use-package qml-mode
:mode "\\.qml\\'")
2016-11-03 23:00:44 -04:00
(use-package jdee
:defer
:config
(setq jdee-server-dir "~/.emacs.d/jdee-server/target"
jdee-mode-line-format mode-line-format))
;;; 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: