diff --git a/emacs/.emacs.d/GNUmakefile b/emacs/.emacs.d/GNUmakefile index abb8904..386bdb8 100644 --- a/emacs/.emacs.d/GNUmakefile +++ b/emacs/.emacs.d/GNUmakefile @@ -15,9 +15,6 @@ VENDOR_DIRS = $(wildcard vendor-lisp/*) .PHONE: all snippets all: $(SITE_LISPS) init.elc $(INIT_LISPS) $(AUTOLOADS_FILE) snippets -init.el init/oni-org-init.el init/oni-js2-init.el init/oni-gnus-init.el init/oni-cmake-init.el init/oni-cpp-init.el: init.org - $(call tangle,emacs-lisp) - %.el: %.org $(call tangle,emacs-lisp) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 5fa6186..ab4a045 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -25,113 +25,116 @@ ;;; Code: -(require 'diminish) ; To hide minor mode lighters. -(require 'package) ; To load packages installed through ELPA. - -(defalias 'yes-or-no-p 'y-or-n-p) - -;;;; Visual initialization: - -;; In order to make the change from the default visuals to my -;; preferred setings as quick as possible, I put anything that will -;; have an immediate effect first. - -(add-to-list 'custom-theme-load-path - (locate-user-emacs-file "local-lisp/yoshi-theme")) - -(setq inhibit-startup-screen t) - -(setq default-frame-alist - (append default-frame-alist - '((font . "Fantasque Sans Mono-15") - (internal-border-width . 15)))) - -(menu-bar-mode -1) -(tool-bar-mode -1) -(scroll-bar-mode -1) - -(load-theme 'yoshi :no-confirm) - -;;;; Rest: +(add-to-list 'load-path (locate-user-emacs-file "init/")) (eval-and-compile (mapc (lambda (d) (add-to-list 'load-path d)) (directory-files - (locate-user-emacs-file "vendor-lisp/") t "^[^.]")) + (locate-user-emacs-file "vendor-lisp/") t "^[^.]"))) - (add-to-list 'load-path (locate-user-emacs-file "local-lisp/")) - - (let ((loaddefs (locate-user-emacs-file "local-lisp/autoloads.el"))) +(eval-and-compile + (add-to-list 'load-path (locate-user-emacs-file "site-lisp/")) + (let ((loaddefs (locate-user-emacs-file "site-lisp/site-autoloads.el"))) (when (file-exists-p loaddefs) (load loaddefs)))) -(setq package-archives - (append package-archives - '(("melpa" . "https://melpa.org/packages/") - ("org" . "http://orgmode.org/elpa/")))) +(require 'oni-helpers) + +(require 'package) + +(eval-and-compile + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))) + +(eval-and-compile + (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))) (eval-and-compile (package-initialize)) -(defvar init--backup-directory - (locate-user-emacs-file "data/backup-files/") - "The location for backup files.") +(eval-when-compile + (let* ((not-installed (seq-remove 'package-installed-p + package-selected-packages)) + (available (seq-filter (lambda (p) + (assq p package-archive-contents)) + not-installed)) + (difference (- (length not-installed) (length available)))) + (when (> difference 0) + (silently "Refresh packages" + (package-refresh-contents))) + (when available + (mapc (lambda (p) (package-install p t)) available)))) -(defvar init--auto-save-directory - (locate-user-emacs-file "data/auto-save-files/") - "The location for auto-save files.") +(setq backup-directory-alist `((".*" . ,(oni:data-location "backup-files/")))) -(defvar init--auto-save-list-prefix - (locate-user-emacs-file "data/auto-save-list/.saves-") - "Prefix for auto-save list files.") +(add-to-list 'auto-save-file-name-transforms + `(".*" ,(oni:data-location "auto-save-files/") t) :append) + +(setq auto-save-list-file-prefix (oni:data-location "auto-save-list/.saves-")) (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)) -(add-to-list 'auto-save-file-name-transforms - `(".*" ,init--auto-save-directory t) :append) - -(setq auto-save-list-file-prefix init--auto-save-list-prefix) - -(setq backup-directory-alist `((".*" . ,init--backup-directory))) - -(setq-default cursor-type '(bar . 2)) - -(setq indent-tabs-mode nil) - -(setq require-final-newline t) - -(setq sentence-end-double-space nil) - -(setq-default tab-width 4) - -(setq-default truncate-lines t) - -(setq user-full-name "Tom Willemse") -(setq user-mail-address "tom@ryuslash.org") - (global-set-key (kbd "C-M-SPC") 'er/expand-region) -(global-set-key (kbd "C-c (") 'embrace-commander) -(global-set-key (kbd "C-c m") 'oni-hydra-magit/body) -(global-set-key (kbd "C-c o") 'oni-hydra-org/body) + (global-set-key (kbd "M-+") 'mc/mark-next-like-this) -(global-unset-key (kbd "C-z")) +(global-set-key (kbd "C-c (") 'embrace-commander) -(show-paren-mode) +(global-set-key (kbd "C-c o") 'oni-hydra-org/body) -;;;; Destroy trailing whitespace: +(global-set-key (kbd "C-c m") 'oni-hydra-magit/body) (require 'destroy-trailing-whitespace) (global-destroy-trailing-whitespace-mode) -;;;; Ivy: +(setq require-final-newline t) + +(setq-default indent-tabs-mode nil) + +(setq-default tab-width 4) + +(setq sentence-end-double-space nil) + +(setq inhibit-startup-screen t) + +(add-to-list 'default-frame-alist '(font . "Fantasque Sans Mono-15")) + +(add-to-list 'default-frame-alist '(internal-border-width . 15)) + +(menu-bar-mode -1) + +(tool-bar-mode -1) + +(scroll-bar-mode -1) + +(setq-default cursor-type '(bar . 2)) + +(setq-default truncate-lines t) + +(global-unset-key (kbd "C-z")) + +(defalias 'yes-or-no-p 'y-or-n-p) + +(show-paren-mode) + +(add-to-list 'custom-theme-load-path + (concat user-emacs-directory "vendor-lisp/yoshi-theme")) +(load-theme 'yoshi :no-confirm) + +(require 'svg-mode-line-themes) +(require 'oni-smt) + +(smt/enable) +(smt/set-theme 'oni-smt) + +(set-face-attribute 'mode-line nil :box nil) +(set-face-attribute 'mode-line-inactive nil :box nil) + +(require 'diminish) (require 'ivy) -(ivy-mode) - (diminish 'ivy-mode) -;;;; Counsel: +(ivy-mode) (require 'counsel) @@ -143,11 +146,345 @@ (diminish 'counsel-mode) -;;;; Lazy configurations: +(eval-when-compile (require 'bookmark)) +(setq bookmark-default-file (oni:data-location "bookmarks")) -(with-eval-after-load 'bookmark (load "init/oni-bookmark")) -(with-eval-after-load 'align (load "init/oni-align")) -(with-eval-after-load 'browse-url (load "init/oni-browse-url")) +(setq user-full-name "Tom Willemse" + user-mail-address "tom@ryuslash.org") + +(eval-when-compile (require 'align)) + +(with-eval-after-load 'align + ;; Keep these in order. They are each added to the _front_ of the + ;; list and are applied in order. Changing their order will change + ;; the results. + (add-to-list 'align-rules-list + `(css-closing-brace + (regexp . ,(rx (group (0+ whitespace)) "}" eol)) + (group . (1)) + (modes . '(scss-mode css-mode)))) + (add-to-list 'align-rules-list + `(css-colons + (regexp . ,(rx bol + (0+ whitespace) + (1+ (any (?a . ?z) ?- ?$)) + ":" + (group (0+ whitespace)) + (0+ nonl) + ";" + eol)) + (group . (1)) + (modes . '(scss-mode css-mode)) + (repeat . t))) + (add-to-list 'align-rules-list + `(css-opening-brace + (regexp . ,(rx bol + (0+ whitespace) + (0+ (any ?# ?. ?, ?\s ?& ?: ?- + (?a . ?z) (?A . ?Z) (?0 . ?9))) + (any (?a . ?z) (?A . ?Z) (?0 . ?9)) + (group (0+ whitespace)) + "{" + (0+ nonl))) + (group . (1)) + (modes . '(scss-mode css-mode))))) + +(with-eval-after-load 'align + (add-to-list 'align-rules-list + `(php-array-arrow + (regexp . ,(rx any (group whitespace) "=>" any)) + (group . (1)) + (modes . '(php-mode web-mode)) + (repeat . t)))) + +(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) + +(require 'shackle) +(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) + +(add-hook 'flycheck-mode-hook 'flycheck-cask-setup) + +(with-eval-after-load 'flycheck + (mapc (lambda (c) (delq c flycheck-checkers)) + '(python-pylint python-pyflakes))) + +(with-eval-after-load 'flycheck + (setq flycheck-highlighting-mode 'columns)) + +(with-eval-after-load 'flycheck + (require 'flycheck-pos-tip) + (flycheck-pos-tip-mode)) + +(with-eval-after-load 'flycheck + (setq flycheck-mode-line-prefix "✓")) + +(with-eval-after-load 'autorevert + (diminish 'auto-revert-mode + (propertize (concat " " (char-to-string #xf021)) + 'face '(:family "Font Awesome" :height 0.75)))) + +(diminish 'auto-fill-function + (propertize (concat " " (char-to-string #xf149)) + 'face '(:family "Font Awesome" :height 0.75))) + +(require 'diff-hl) +(global-diff-hl-mode) + +(defun oni:with-diff-hl-p4-args (orig-fun &rest args) + (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)) + +(diminish 'isearch-mode + (propertize (concat " " (char-to-string #xf002)) + 'face '(:family "Font Awesome" :height 0.75))) + +(setq projectile-known-projects-file + (oni:data-location "projectile-bookmarks.eld")) + +(require 'projectile) + +(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) + +(setq projectile-completion-system 'ivy) + +(add-to-list 'projectile-project-root-files "yarn.lock") + +(with-eval-after-load 'server + (diminish 'server-buffer-clients + (propertize (concat " " (char-to-string #xf233)) + 'face '(:family "Font Awesome" :height 0.75)))) + +(with-eval-after-load 'slime + (setq slime-lisp-implementations + '((sbcl ("sbcl" "--noinform") :coding-system utf-8-unix) + (clisp ("clisp") :coding-system utf-8-unix))) + (setq slime-default-lisp 'sbcl) + (slime-setup '(slime-fancy slime-company))) + +(with-eval-after-load 'js (load "oni-js-mode-init")) + +(with-eval-after-load 'php-mode (load "oni-php-mode-init")) + +(with-eval-after-load 'sh-mode (load "oni-sh-mode-init")) + +(with-eval-after-load 'css-mode (load "oni-css-mode-init")) + +(with-eval-after-load 'elisp-mode (load "oni-emacs-lisp-mode-init")) + +(with-eval-after-load 'scheme (load "oni-scheme-init")) + +(with-eval-after-load 'compile (load "oni-compilation-init")) + +(with-eval-after-load 'cc-mode (load "oni-java-init")) + +(add-hook 'ielm-mode-hook 'paredit-mode) + +(autoload 'mbsync-conf-mode "mbsync-conf-mode" + "Major mode for editing mbsync configuration files." + :interactive) + +(add-to-list 'auto-mode-alist '("\\.mbsyncrc\\'" . mbsync-conf-mode)) + +(autoload 'msmtprc-mode "msmtprc-mode" + "Major mode for editing msmtp configuration files." + :interactive) + +(add-to-list 'auto-mode-alist '("\\.msmtprc\\'" . msmtprc-mode)) + +(add-hook 'git-commit-mode-hook 'electric-quote-local-mode) + +(add-hook 'python-mode-hook 'electric-pair-local-mode) + +(add-hook 'python-mode-hook 'flycheck-mode) + +(add-hook 'web-mode-hook 'oni-whitespace-only-tabs-mode) + +(add-hook 'makefile-mode-hook 'oni-whitespace-only-tabs-mode) + +(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) + +(with-eval-after-load 'cider + (setq cider-repl-pop-to-buffer-on-connect t)) + +(setq cider-show-error-buffer t + cider-auto-select-error-buffer t) + +(setq cider-repl-history-file + (oni:data-location "cider-history")) + +(setq cider-repl-wrap-history t) + +(add-hook 'cider-repl-mode-hook 'paredit-mode) + +(add-hook 'c-mode-hook 'electric-pair-local-mode) + +(add-hook 'c-mode-hook 'electric-indent-local-mode) + +(add-hook 'lisp-mode-hook 'paredit-mode) + +(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode) + +(add-hook 'lisp-mode-hook 'company-mode) + +(with-eval-after-load 'js2-mode (load "oni-js2-init")) + +(add-hook 'html-mode-hook 'electric-pair-local-mode) + +(with-eval-after-load 'cmake-mode (load "oni-cmake-init")) + +(with-eval-after-load 'cc-mode (load "oni-cpp-init")) + +(with-eval-after-load 'dired (load "oni-dired-init")) + +(with-eval-after-load 'magit (load "oni-magit-init")) + +(with-eval-after-load 'ediff (load "oni-ediff-init")) + +(with-eval-after-load 'eshell (load "oni-eshell-init")) + +(with-eval-after-load 'slack (load "oni-slack-init")) + +(with-eval-after-load 'circe (load "oni-circe-init")) + +(eval-when-compile (require 'lui)) + +(with-eval-after-load 'lui + (setq lui-time-stamp-position 'right-margin)) + +(with-eval-after-load 'lui + (setq lui-time-stamp-format "%H:%M")) + +(defun oni:set-circe-margin-width () + (setq right-margin-width 5)) + +(add-hook 'lui-mode-hook #'oni:set-circe-margin-width) + +(defun oni:set-lui-prompt-wrap-prefix () + (setq wrap-prefix " ")) + +(add-hook 'lui-mode-hook #'oni:set-lui-prompt-wrap-prefix) + +(add-hook 'lui-mode-hook 'visual-line-mode) + +(setq lui-fill-type nil) + +(eval-when-compile (require 'jabber)) + +(setq jabber-account-list + `((,(concat "ryuslash@dukgo.com/" (system-name)) + (:connection-type . starttls)))) + +(setq jabber-avatar-cache-directory (oni:data-location "jabber/avatars/") + jabber-history-dir (oni:data-location "jabber/hist/")) + +(setq jabber-chat-buffer-format "+%n" + jabber-chat-foreign-prompt-format "%t %n " + jabber-chat-local-prompt-format "%t %n " + jabber-chat-delayed-time-format "%H:%M" + jabber-groupchat-buffer-format "++%n" + jabber-groupchat-prompt-format "%t %n ") + +(setq jabber-chat-buffer-show-avatar nil + jabber-vcard-avatars-publish nil + jabber-vcard-avatars-retrieve nil) + +(setq jabber-chat-fill-long-lines nil) + +(add-hook 'jabber-chat-mode-hook 'visual-line-mode) + +(setq jabber-chatstates-confirm nil) + +(setq jabber-muc-colorize-local t + jabber-muc-colorize-foreign t) + +(setq jabber-history-enabled t + jabber-use-global-history nil) + +(setq jabber-roster-show-bindings nil + jabber-show-offline-contacts nil) + +(add-hook 'jabber-roster-mode-hook 'oni-jabber-set-roster-mode-line) + +(add-hook 'jabber-alert-message-hooks 'jabber-message-libnotify) +(add-hook 'jabber-alert-muc-hooks 'jabber-muc-libnotify) + +(with-eval-after-load 'jabber-alert + (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo)) + +(add-hook 'jabber-alert-presence-hooks 'oni-jabber-show-status-in-buffer) + +(defun oni:set-default-directory () + (setq default-directory "~/")) + +(add-hook 'jabber-chat-mode-hook 'oni:set-default-directory) + +(with-eval-after-load 'gnus (load "oni-gnus-init")) + +(with-eval-after-load 'org (load "oni-org-init")) + +(add-to-list 'grep-files-aliases '("js" . "*.js *.jsx *.json")) + +(add-to-list 'grep-files-aliases '("css" . "*.css *.less *.sass *.scss")) + +(setq custom-file (concat user-emacs-directory "custom.el")) +(load custom-file) (provide 'init) ;;; init.el ends here diff --git a/emacs/.emacs.d/init/oni-cmake-init.el b/emacs/.emacs.d/init/oni-cmake-init.el new file mode 100644 index 0000000..b66da19 --- /dev/null +++ b/emacs/.emacs.d/init/oni-cmake-init.el @@ -0,0 +1,5 @@ +(add-hook 'cmake-mode-hook 'cmake-font-lock-activate) + +(add-hook 'cmake-mode-hook 'company-mode) + +(add-hook 'cmake-mode-hook 'electric-pair-local-mode) diff --git a/emacs/.emacs.d/init/oni-cpp-init.el b/emacs/.emacs.d/init/oni-cpp-init.el new file mode 100644 index 0000000..74b81cf --- /dev/null +++ b/emacs/.emacs.d/init/oni-cpp-init.el @@ -0,0 +1,9 @@ +(add-hook 'c++-mode-hook 'electric-pair-local-mode) + +(add-hook 'c++-mode-hook 'flycheck-mode) + +(add-hook 'c++-mode-hook 'company-mode) + +(add-hook 'c++-mode-hook 'fci-mode) + +(add-hook 'c++-mode-hook 'electric-indent-local-mode) diff --git a/emacs/.emacs.d/init/oni-gnus-init.el b/emacs/.emacs.d/init/oni-gnus-init.el new file mode 100644 index 0000000..a3369e6 --- /dev/null +++ b/emacs/.emacs.d/init/oni-gnus-init.el @@ -0,0 +1,53 @@ +(require 'gnus) +(require 'gnus-msg) +(require 'mail-source) +(require 'message) +(require 'nnfolder) +(require 'sendmail) + +(setq gnus-directory (locate-user-emacs-file "data/News") + gnus-article-save-directory gnus-directory + gnus-cache-directory gnus-directory + gnus-kill-files-directory gnus-directory) + +(setq mail-source-directory (locate-user-emacs-file "data/Mail") + message-directory mail-source-directory + nnfolder-directory mail-source-directory) + +(setq send-mail-function 'send-mail-send-it + message-send-mail-function 'message-send-mail-with-sendmail + sendmail-program "/usr/bin/msmtp") + +(setq gnus-novice-user nil) + +(defun oni-gnus-delete-forward (&optional n) + "Delete the article under point and move to the next one. +Do this N times." + (interactive "p") + (dotimes (_ (or n 1)) + (gnus-summary-delete-article) + (gnus-summary-next-subject 1))) + +(define-key gnus-summary-mode-map (kbd "M-d") #'oni-gnus-delete-forward) + +(setq gnus-group-line-format "%P%(%20G%): %-10s %S%p%B %5y %5T\n") + +(setq gnus-select-method + '(nnmaildir "ryuslash" (directory "~/documents/mail/ryuslash/"))) + +(add-to-list 'gnus-posting-styles + '(".*" + (address "tom@ryuslash.org") + (eval (setq message-sendmail-extra-arguments + '("-a" "ryuslash"))))) + +(add-to-list 'gnus-secondary-select-methods + '(nnmaildir "gmail" + (directory "~/documents/mail/gmail/"))) + +(add-to-list 'gnus-posting-styles + '("gmail:" + (name "Tom Willemse") + (address "ryuslash@gmail.com") + (eval (setq message-sendmail-extra-arguments + '("-a" "gmail"))))) diff --git a/emacs/.emacs.d/init/oni-js2-init.el b/emacs/.emacs.d/init/oni-js2-init.el new file mode 100644 index 0000000..2b9e7c8 --- /dev/null +++ b/emacs/.emacs.d/init/oni-js2-init.el @@ -0,0 +1,13 @@ +(require 'js2-mode) + +(setq js2-strict-trailing-comma-warning nil) + +(add-hook 'js2-mode-hook 'subword-mode) + +(add-hook 'js2-mode-hook 'flycheck-mode) + +(setq js2-basic-offset 2) + +(add-hook 'js2-mode-hook 'company-mode) + +(add-hook 'js2-mode-hook 'fci-mode) diff --git a/emacs/.emacs.d/init/oni-org-init.el b/emacs/.emacs.d/init/oni-org-init.el new file mode 100644 index 0000000..14caaa2 --- /dev/null +++ b/emacs/.emacs.d/init/oni-org-init.el @@ -0,0 +1,11 @@ +(require 'org) +(require 'org-bullets) +(require 'org-capture) + +(setq org-src-fontify-natively t) + +(setq org-return-follows-link t) + +(add-hook 'org-mode-hook 'auto-fill-mode) + +(add-hook 'org-mode-hook 'org-bullets-mode)