2018-05-28 18:23:25 +02:00
|
|
|
;;; init.el --- Tom-Emacs Interface -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;; Copyright (C) 2018 Tom Willemse
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
;; Keywords: local
|
|
|
|
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; This is my Emacs configuration. It has gone through many iterations
|
|
|
|
;; before and may yet go through many more iterations.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
;;;; Load path and autoloads
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(eval-and-compile
|
2018-06-07 09:57:28 +02:00
|
|
|
(let ((load-directory
|
|
|
|
(file-name-directory
|
|
|
|
(or load-file-name byte-compile-current-file))))
|
|
|
|
(add-to-list 'load-path (format "%sinit/" load-directory))
|
|
|
|
(add-to-list 'load-path (format "%ssite-lisp/" load-directory))
|
2018-07-20 08:22:22 +02:00
|
|
|
(add-to-list 'load-path (format "%sos-lisp/" load-directory))
|
2018-06-07 05:54:46 +02:00
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
(mapc (lambda (d) (add-to-list 'load-path d))
|
|
|
|
(directory-files
|
|
|
|
(format "%svendor-lisp/" load-directory) t "^[^.]"))))
|
2018-06-19 19:43:05 +02:00
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
(load "oni-site-autoloads" :noerror :nomessage)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
;;;; Package
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(require 'package)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(eval-and-compile
|
2019-01-17 10:47:36 +01:00
|
|
|
;; Add MELPA because it's the biggest package repository for Emacs.
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("melpa" . "https://melpa.org/packages/"))
|
|
|
|
;; Add the Org package archive to be able to install the bleeding
|
|
|
|
;; edge Org mode.
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("org" . "http://orgmode.org/elpa/"))
|
|
|
|
;; Add my personal package archive so I can upload custom libraries
|
|
|
|
;; and stuff there.
|
|
|
|
(add-to-list 'package-archives
|
|
|
|
'("oni" . "https://ryuslash.org/elpa/"))
|
|
|
|
(package-initialize))
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-10 19:54:42 +02:00
|
|
|
(add-hook 'package-menu-mode-hook 'hl-line-mode)
|
|
|
|
|
2019-01-17 10:47:36 +01:00
|
|
|
(with-eval-after-load 'package (require 'oni-package-x))
|
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
;;;; Dependencies
|
|
|
|
|
|
|
|
(require 'counsel)
|
|
|
|
(require 'destroy-trailing-whitespace)
|
|
|
|
(require 'diff-hl)
|
|
|
|
(require 'diminish)
|
|
|
|
(require 'ivy)
|
|
|
|
(require 'ivy-hydra)
|
|
|
|
(require 'oni-helpers)
|
|
|
|
(require 'projectile)
|
|
|
|
(require 'shackle)
|
|
|
|
|
|
|
|
;;;; Settings
|
|
|
|
|
2018-07-15 09:47:07 +02:00
|
|
|
(setq backup-directory-alist
|
|
|
|
`((".*" . ,(oni:data-location "backup-files/"))))
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'auto-save-file-name-transforms
|
|
|
|
`(".*" ,(oni:data-location "auto-save-files/") t) :append)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-07-15 09:47:07 +02:00
|
|
|
(setq auto-save-list-file-prefix
|
|
|
|
(oni:data-location "auto-save-list/.saves-"))
|
|
|
|
|
|
|
|
(setq delete-old-versions t)
|
|
|
|
(setq kept-new-versions 20)
|
|
|
|
(setq kept-old-versions 20)
|
|
|
|
(setq vc-make-backup-files t)
|
|
|
|
(setq version-control t)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(global-set-key (kbd "C-M-SPC") 'er/expand-region)
|
|
|
|
(global-set-key (kbd "M-+") 'mc/mark-next-like-this)
|
|
|
|
(global-set-key (kbd "C-c (") 'embrace-commander)
|
|
|
|
(global-set-key (kbd "C-c o") 'oni-hydra-org/body)
|
2018-07-10 04:39:11 +02:00
|
|
|
(global-set-key (kbd "C-c v") 'oni-hydra-magit/body)
|
2018-07-10 04:04:15 +02:00
|
|
|
(global-set-key (kbd "C-x f") 'ffap)
|
2018-07-10 04:42:56 +02:00
|
|
|
(global-set-key (kbd "C-x C-b") 'ibuffer)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(global-destroy-trailing-whitespace-mode)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq require-final-newline t)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq-default indent-tabs-mode nil)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq-default tab-width 4)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq sentence-end-double-space nil)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq inhibit-startup-screen t)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'default-frame-alist '(font . "Fantasque Sans Mono-15"))
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'default-frame-alist '(internal-border-width . 15))
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(menu-bar-mode -1)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(tool-bar-mode -1)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(scroll-bar-mode -1)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq-default cursor-type '(bar . 2))
|
2018-07-10 05:16:53 +02:00
|
|
|
(setq-default cursor-in-non-selected-windows 'box)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq-default truncate-lines t)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
|
|
|
(global-unset-key (kbd "C-z"))
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
2018-05-28 18:23:25 +02:00
|
|
|
(show-paren-mode)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'custom-theme-load-path
|
|
|
|
(concat user-emacs-directory "vendor-lisp/yoshi-theme"))
|
|
|
|
(load-theme 'yoshi :no-confirm)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
|
|
|
(diminish 'ivy-mode)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(ivy-mode)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
|
|
|
(setq counsel-find-file-ignore-regexp
|
|
|
|
(rx (or (and bos ".")
|
|
|
|
(and ".zwc" eos))))
|
|
|
|
|
|
|
|
(counsel-mode)
|
|
|
|
|
|
|
|
(diminish 'counsel-mode)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(eval-when-compile (require 'bookmark))
|
|
|
|
(setq bookmark-default-file (oni:data-location "bookmarks"))
|
|
|
|
|
|
|
|
(setq user-full-name "Tom Willemse"
|
|
|
|
user-mail-address "tom@ryuslash.org")
|
|
|
|
|
|
|
|
(eval-when-compile (require 'browse-url))
|
|
|
|
|
|
|
|
(with-eval-after-load 'browse-url
|
|
|
|
(setq browse-url-browser-function 'browse-url-firefox))
|
|
|
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
|
|
|
|
|
|
|
|
(shackle-mode)
|
|
|
|
|
|
|
|
(with-eval-after-load 'shr (load "oni-shr-init"))
|
|
|
|
|
|
|
|
(with-eval-after-load 'company (load "oni-company-init"))
|
|
|
|
|
|
|
|
(with-eval-after-load 'paredit
|
|
|
|
(diminish 'paredit-mode))
|
|
|
|
|
|
|
|
(electric-indent-mode -1)
|
|
|
|
|
|
|
|
(defun oni:switch-newline-keys ()
|
|
|
|
"Switch the C-j and RET keys in the local buffer."
|
|
|
|
(if electric-indent-mode
|
|
|
|
(progn
|
|
|
|
(local-set-key (kbd "C-j") 'newline)
|
|
|
|
(local-set-key (kbd "RET") 'electric-newline-and-maybe-indent))
|
|
|
|
(local-unset-key (kbd "C-j"))
|
|
|
|
(local-unset-key (kbd "RET"))))
|
|
|
|
|
|
|
|
(add-hook 'electric-indent-local-mode-hook #'oni:switch-newline-keys)
|
|
|
|
|
|
|
|
(global-diff-hl-mode)
|
2018-07-10 05:11:46 +02:00
|
|
|
(blink-cursor-mode -1)
|
2018-06-05 17:36:53 +02:00
|
|
|
|
|
|
|
(defun oni:with-diff-hl-p4-args (orig-fun &rest args)
|
2018-07-10 04:52:06 +02:00
|
|
|
"Add Perforce-specific command-line arguments to `diff-hl-mode'.
|
|
|
|
|
|
|
|
ORIG-FUN is the function being wrapped, ARGS are the arguments specified"
|
2018-06-05 17:36:53 +02:00
|
|
|
(let ((p4-lowlevel-diff-switches '("-du0")))
|
|
|
|
(apply orig-fun args)))
|
|
|
|
|
|
|
|
(with-eval-after-load 'vc-p4
|
|
|
|
(add-function :around (symbol-function 'diff-hl-changes-buffer)
|
|
|
|
#'oni:with-diff-hl-p4-args))
|
|
|
|
|
|
|
|
(setq projectile-known-projects-file
|
|
|
|
(oni:data-location "projectile-bookmarks.eld"))
|
|
|
|
|
|
|
|
(with-eval-after-load 'projectile
|
|
|
|
(setq projectile-mode-line
|
|
|
|
'(:eval
|
|
|
|
(if (file-remote-p default-directory)
|
|
|
|
" P"
|
|
|
|
(let ((name (projectile-project-name)))
|
|
|
|
(if (string= "-" name)
|
|
|
|
""
|
|
|
|
(format " P[%s]" name)))))))
|
|
|
|
|
|
|
|
(setq projectile-cache-file
|
|
|
|
(oni:data-location "projectile.cache"))
|
|
|
|
|
|
|
|
(projectile-mode)
|
|
|
|
|
2018-08-11 00:04:43 +02:00
|
|
|
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq projectile-completion-system 'ivy)
|
|
|
|
|
|
|
|
(add-to-list 'projectile-project-root-files "yarn.lock")
|
2018-07-17 05:50:10 +02:00
|
|
|
(add-to-list 'projectile-project-root-files "fabfile.py")
|
2018-06-05 17:36:53 +02:00
|
|
|
|
2018-07-17 11:21:22 +02:00
|
|
|
;; (with-eval-after-load 'server
|
|
|
|
;; (diminish 'server-buffer-clients
|
|
|
|
;; (propertize (concat " " (char-to-string #xf233))
|
|
|
|
;; 'face '(:family "Font Awesome" :height 0.75))))
|
2018-06-05 17:36:53 +02:00
|
|
|
|
2018-09-12 07:51:35 +02:00
|
|
|
(with-eval-after-load 'cider (load "oni-cider-init"))
|
2018-09-12 07:22:20 +02:00
|
|
|
(with-eval-after-load 'align (load "oni-align"))
|
|
|
|
(with-eval-after-load 'cc-mode (load "oni-cpp-init"))
|
|
|
|
(with-eval-after-load 'circe (load "oni-circe-init"))
|
|
|
|
(with-eval-after-load 'cmake-mode (load "oni-cmake-init"))
|
|
|
|
(with-eval-after-load 'compile (load "oni-compilation-init"))
|
2018-06-05 17:36:53 +02:00
|
|
|
(with-eval-after-load 'css-mode (load "oni-css-mode-init"))
|
2018-09-12 07:22:20 +02:00
|
|
|
(with-eval-after-load 'dired (load "oni-dired-init"))
|
|
|
|
(with-eval-after-load 'ediff (load "oni-ediff-init"))
|
|
|
|
(with-eval-after-load 'elec-pair (load "oni-elec-pair-init"))
|
2018-06-05 17:36:53 +02:00
|
|
|
(with-eval-after-load 'elisp-mode (load "oni-emacs-lisp-mode-init"))
|
2018-09-12 07:22:20 +02:00
|
|
|
(with-eval-after-load 'eshell (load "oni-eshell-init"))
|
|
|
|
(with-eval-after-load 'flycheck (load "oni-flycheck-init"))
|
|
|
|
(with-eval-after-load 'gnus (load "oni-gnus-init"))
|
|
|
|
(with-eval-after-load 'jabber (load "oni-jabber-init"))
|
|
|
|
(with-eval-after-load 'js (load "oni-js-mode-init"))
|
|
|
|
(with-eval-after-load 'js2-mode (load "oni-js2-init"))
|
|
|
|
(with-eval-after-load 'lui (load "oni-lui-init"))
|
|
|
|
(with-eval-after-load 'magit (load "oni-magit-init"))
|
|
|
|
(with-eval-after-load 'org (load "oni-org-init"))
|
|
|
|
(with-eval-after-load 'php-mode (load "oni-php-mode-init"))
|
2018-07-10 04:04:15 +02:00
|
|
|
(with-eval-after-load 'python-mode (load "oni-python-init"))
|
2018-07-10 04:18:16 +02:00
|
|
|
(with-eval-after-load 'ruby-mode (load "oni-ruby-init"))
|
2018-09-12 07:22:20 +02:00
|
|
|
(with-eval-after-load 'scheme (load "oni-scheme-init"))
|
|
|
|
(with-eval-after-load 'sh-mode (load "oni-sh-mode-init"))
|
2018-07-10 05:04:19 +02:00
|
|
|
(with-eval-after-load 'shackle (load "oni-shackle-init"))
|
2018-09-12 07:22:20 +02:00
|
|
|
(with-eval-after-load 'slack (load "oni-slack-init"))
|
2018-09-12 07:29:17 +02:00
|
|
|
(with-eval-after-load 'slime (load "oni-slime-init"))
|
2018-07-10 05:09:02 +02:00
|
|
|
(with-eval-after-load 'yasnippet (load "oni-yasnippet-init"))
|
2018-11-26 01:07:33 +01:00
|
|
|
(with-eval-after-load 'rust-mode (load "oni-rust-init"))
|
2018-07-10 04:04:15 +02:00
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-hook 'ielm-mode-hook 'paredit-mode)
|
2018-09-12 07:24:54 +02:00
|
|
|
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
|
2018-06-05 17:36:53 +02:00
|
|
|
|
|
|
|
(autoload 'mbsync-conf-mode "mbsync-conf-mode"
|
|
|
|
"Major mode for editing mbsync configuration files."
|
|
|
|
:interactive)
|
|
|
|
|
|
|
|
(autoload 'msmtprc-mode "msmtprc-mode"
|
|
|
|
"Major mode for editing msmtp configuration files."
|
|
|
|
:interactive)
|
|
|
|
|
2018-06-14 00:38:07 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.blade\\.php\\'" . web-mode))
|
2018-06-19 19:45:30 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.inc\\'" . php-mode))
|
2018-06-14 00:35:46 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
|
2018-06-14 00:38:07 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.jsx\\'" . rjsx-mode))
|
2018-06-14 00:35:46 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.mbsyncrc\\'" . mbsync-conf-mode))
|
2018-06-19 19:45:30 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.module\\'" . php-mode))
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.msmtprc\\'" . msmtprc-mode))
|
2018-11-14 22:56:46 +01:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.targets\\'" . nxml-mode))
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.proj\\'" . nxml-mode))
|
2018-06-05 17:36:53 +02:00
|
|
|
|
|
|
|
(add-hook 'git-commit-mode-hook 'electric-quote-local-mode)
|
|
|
|
|
2018-07-10 04:23:29 +02:00
|
|
|
(add-hook 'makefile-mode-hook 'whitespace-only-tabs-mode)
|
2018-06-05 17:36:53 +02:00
|
|
|
|
|
|
|
(add-hook 'makefile-mode-hook 'electric-pair-local-mode)
|
|
|
|
|
|
|
|
(with-eval-after-load 'clojure-mode
|
|
|
|
(require 'clojure-mode-extra-font-locking))
|
|
|
|
|
|
|
|
(add-hook 'clojure-mode-hook 'paredit-mode)
|
|
|
|
|
|
|
|
(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode)
|
|
|
|
|
|
|
|
(eval-when-compile (require 'inf-lisp))
|
|
|
|
|
|
|
|
(defun oni:clojure-set-inferior-lisp ()
|
|
|
|
(setq inferior-lisp-program "lein repl"))
|
|
|
|
|
|
|
|
(add-hook 'clojure-mode-hook 'oni-clojure-add-font-lock)
|
|
|
|
(add-hook 'clojure-mode-hook 'oni-clojure-add-indent)
|
|
|
|
|
|
|
|
(add-hook 'c-mode-hook 'electric-pair-local-mode)
|
|
|
|
|
|
|
|
(add-hook 'c-mode-hook 'electric-indent-local-mode)
|
|
|
|
|
2018-08-14 07:12:19 +02:00
|
|
|
(add-hook 'c-mode-hook 'flycheck-mode)
|
|
|
|
|
|
|
|
(add-hook 'c-mode-hook 'fci-mode)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-hook 'lisp-mode-hook 'paredit-mode)
|
|
|
|
|
|
|
|
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
|
|
|
|
|
|
|
|
(add-hook 'lisp-mode-hook 'company-mode)
|
|
|
|
|
|
|
|
(add-hook 'html-mode-hook 'electric-pair-local-mode)
|
|
|
|
|
2019-01-17 10:51:47 +01:00
|
|
|
(add-hook 'before-save-hook 'time-stamp)
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json"))
|
|
|
|
(add-to-list 'grep-files-aliases '("css" . "*.css *.less *.sass *.scss"))
|
2018-06-27 19:53:44 +02:00
|
|
|
(add-to-list 'grep-files-aliases '("php" . "*.php *.inc *.module"))
|
2018-11-15 20:04:33 +01:00
|
|
|
(add-to-list 'grep-files-aliases '("msbuild" . "*.targets *.proj"))
|
2018-05-28 18:23:25 +02:00
|
|
|
|
2018-07-20 09:24:41 +02:00
|
|
|
(if (eq system-type 'windows-nt)
|
|
|
|
(require 'oni-windows-nt))
|
|
|
|
|
2018-06-05 17:36:53 +02:00
|
|
|
(setq custom-file (concat user-emacs-directory "custom.el"))
|
2018-06-13 20:06:46 +02:00
|
|
|
(load custom-file t)
|
2018-05-28 18:23:25 +02:00
|
|
|
|
|
|
|
(provide 'init)
|
|
|
|
;;; init.el ends here
|