emacs.d/config.org
2020-01-28 08:36:50 -05:00

1384 lines
38 KiB
Org Mode
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

* General Emacs Configuration
** Load some libraries
Like notifications
#+BEGIN_SRC emacs-lisp
(load-library "notifications")
(notifications-notify :title "Emacs"
:body "Electronic Macros loading...")
(message "Emacs initializing...")
#+END_SRC
and sclang, if avaliable
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "/usr/local/bin/sclang")
(require 'sclang)
#+END_SRC
** Helper Functions
#+BEGIN_SRC emacs-lisp
(defun wiz-kill-all-buffers ()
(interactive)
(mapc 'kill-buffer (buffer-list)))
(defun wiz-kill-curr-buffer ()
(interactive)
(kill-buffer (current-buffer)))
#+END_SRC
** Customize file
Makes it so the customize data isn't schlunked in my init.el
#+BEGIN_SRC emacs-lisp
(setq custom-file (concat user-emacs-directory "_customize.el"))
(load custom-file t)
#+END_SRC
** Startup image
Add a fun image to the emacs startup screen
The variable is used below in Dashboard
#+BEGIN_SRC emacs-lisp
(defvar wiz-startpic (concat user-emacs-directory "pictures/startpic.png"))
(if (file-readable-p wiz-startpic)
(lambda ()
(setq fancy-splash-image wiz-startpic)
(message "Splash image loaded."))
(message "The splash image is unreadable."))
#+END_SRC
** Notifications
Enable make some tweaks
#+BEGIN_SRC emacs-lisp
(defvar wiz-notifypic (concat user-emacs-directory "pictures/notifypic.png"))
(if (file-readable-p wiz-notifypic)
(setq notifications-application-icon
(concat user-emacs-directory "pictures/notifypic.png")))
#+END_SRC
** De-clutter
Disable the useless cruft at the top of the screen
#+BEGIN_SRC emacs-lisp
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode -1)
#+END_SRC
** Show parenthesis
Shows matching parenthesis
#+BEGIN_SRC emacs-lisp
(require 'paren)
;; (set-face-background 'show-paren-match "#000")
;; (set-face-foreground 'show-paren-match "#d9f")
;; (set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(setq show-paren-delay 0)
(show-paren-mode)
#+END_SRC
** electric pairs (DISABLED in favor of smartparens)
When you open a code block, close that block.
# #+BEGIN_SRC emacs-lisp
# (setq electric-pair-pairs '(
# (?\( . ?\))
# (?\[ . ?\])
# (?\{ . ?\})
# (?\" . ?\")
# ;; (?\' . ?\')
# ))
# (setq electric-pair-preserve-balance t)
# (electric-pair-mode t)
# #+END_SRC
** Show columns
#+BEGIN_SRC emacs-lisp
(column-number-mode t)
#+END_SRC
** Fonts
Set the font to something cool
#+BEGIN_SRC emacs-lisp
;; (set-default-font "Go Mono-11")
(add-to-list 'default-frame-alist
'(font . "Go Mono-11")
'(font . "Noto Sans Mono CJK JP-11"))
#+END_SRC
** Transparency
Sets the window's transparency.
The first number in the alpha section applies when the window is
active, the second when it's inactive.
#+BEGIN_SRC emacs-lisp
(defvar wiz-default-transparency 95)
(add-to-list 'default-frame-alist `(alpha . (,wiz-default-transparency . ,wiz-default-transparency)))
;; Set transparency of emacs
(defun wiz-transparency (value)
"Sets the transparency of the frame window. 0=transparent/100=opaque"
(interactive "nTransparency Value 0 - 100 opaque:")
(set-frame-parameter (selected-frame) 'alpha value))
;; (set-frame-parameter (selected-frame) 'alpha '(100 . 100))
#+END_SRC
** Backup files
Edit backup files properties
https://www.emacswiki.org/emacs/BackupDirectory
#+BEGIN_SRC emacs-lisp
(setq
backup-by-copying t ; don't clobber symlinks
backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups"))) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups
;; Actually a lot of this doesn't work
(setq
make-backup-files nil
auto-save-default nil)
#+END_SRC
** Scrolling
#+BEGIN_SRC emacs-lisp
(setq scroll-conservatively 100) ;; don't scroll a metric boatload when bottom is hit
#+END_SRC
** Shut up Emacs
#+BEGIN_SRC emacs-lisp
(setq ring-bell-function 'ignore) ;;emacs stfu
#+END_SRC
** Show line numbers
Enable lines when editing files
#+BEGIN_SRC emacs-lisp
(unless (version< emacs-version "26.1")
(setq display-line-numbers-type 'relative)
(add-hook 'text-mode-hook 'display-line-numbers-mode)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(add-hook 'sclang-mode-hook 'display-line-numbers-mode)
(add-hook 'conf-mode-hook 'display-line-numbers-mode)
(setq display-line-numbers-grow-only t)
(setq display-line-numbers-width-start 4)
(defun wiz-disable-line-numbers ()
(interactive)
(setq display-line-numbers nil)))
#+END_SRC
** y or n prompts
#+BEGIN_SRC emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p) ;; make yes or no prompts ask for y or n
#+END_SRC
** Customize the terminal
#+BEGIN_SRC emacs-lisp
(defvar wiz-term-shell "/bin/zsh") ;; I like to utilize zsh
(defadvice ansi-term (before force-bash)
(interactive (list wiz-term-shell)))
(ad-activate 'ansi-term)
#+END_SRC
** Prettify symbols
+=|====> = CoolSword
#+BEGIN_SRC emacs-lisp
(add-to-list 'prettify-symbols-alist '("+=|====>" 🗡))
(global-prettify-symbols-mode 1)
#+END_SRC
** Tabs are spaces?!
#+BEGIN_SRC emacs-lisp
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
#+END_SRC
** org-mode
*** General org settings
Auto-indent org files nicely
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'org-indent-mode)
#+END_SRC
Highlight syntax in source blocks
#+BEGIN_SRC emacs-lisp
(setq org-src-fontify-natively t)
#+END_SRC
*** Capture Templates
Set the org mode directory and define some capture templates
#+BEGIN_SRC emacs-lisp
(setq org-directory "~/Documents/org/")
(setq org-agenda-files '("~/Documents/org/"))
(setq org-capture-templates
(quote
(("t" "Todo" entry
(file+olp "todo.org" "Tasks" "Misc")
"** TODO %^{Thing to do}\nDEADLINE: %t\nadded: %t\n")
("tm" "Music Todo" entry
(file+olp "todo.org" "Tasks" "Music")
"** TODO %^{Thing to do}\nDEADLINE: %t\nadded: %t\n")
("ts" "Server Todo" entry
(file+olp "todo.org" "Tasks" "Server")
"** TODO %^{Thing to do}\nDEADLINE: %t\nadded: %t\n")
("tp" "Program Todo" entry
(file+olp "todo.org" "Tasks" "Programming")
"** TODO %^{Thing to do}\nDEADLINE: %t\nadded: %t\n")
("tb" "Blog Todo" entry
(file+olp "todo.org" "Tasks" "Blog")
"** TODO %^{Thing to do}\nDEADLINE: %t\nadded: %t\n")
("T" "Thoughts" entry
(file+headline "thoughts.org" "Thoughts")
"** %^{Summary} %t :thoughts:\n")
("s" "School-related task" entry
(file+olp+prompt "school.org" "Todo")
"** TODO %^{What needs be done}\n DEADLINE: %t\n")
("d" "Dream Journal" entry
(file+olp+datetree "dreams.org")
"**** Dream\n")
("m" "Bookmark" entry
(file+olp "links.org" "Refile")
"** [[%^{link}][%^{description}]]\n"))))
#+END_SRC
*** Org templates
<el expands to emacs lisp code block
#+BEGIN_SRC emacs-lisp
(setq org-src-window-setup 'current-window)
(add-to-list 'org-structure-template-alist
'("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"))
#+END_SRC
*** Autocomplete todo entries
#+BEGIN_SRC emacs-lisp
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states)
; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
#+END_SRC
*** export settings
**** use latexmk
#+BEGIN_SRC emacs-lisp
(setq org-latex-to-pdf-process (list "latexmk -f -pdf %f"))
#+END_SRC
*** Keep diary
#+BEGIN_SRC emacs-lisp
(setq org-agenda-include-diary nil)
(setq org-default-notes-file "notes.org")
#+END_SRC
** set browser
Default browser should be firefox
#+BEGIN_SRC emacs-lisp
(setq browse-url-generic-program "firefox"
browse-url-browser-program 'browse-url-generic
browse-url-default-browser 'browse-url-generic
browse-url-browser-function 'browse-url-generic
;; And if I'm stuck like a rock in a hard place...
browse-url-default-windows-browser 'browse-url-firefox)
#+END_SRC
** Buffers
*** ibuffer
Expert mode to streamline stuff. Don't ask for confirmation of
"dangerous" operations.
The long variable settage is to group different types of buffers
to make it easier to navigate.
#+BEGIN_SRC emacs-lisp
(setq ibuffer-expert 1)
;; see: ibuffer-filtering-alist
(setq ibuffer-saved-filter-groups
(quote (("default"
("dired" (mode . dired-mode))
("erc" (mode . erc-mode))
;; ("org" (directory . "^~\\/Documents\\/org\\/"))
("emacs" (or
;; (directory . "^~\\/\\.emacs\\.d\\/")
(name . "^\\*scratch\\*$")
(name . "^\\*dashboard\\*$")
(mode . customize-mode)
(name . "^\\*Messages\\*$")))))))
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-switch-to-saved-filter-groups "default")))
;; Use human readable Size column instead of original one
(define-ibuffer-column size-h
(:name "Size")
(cond
((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0)))
((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
(t (format "%8d" (buffer-size)))))
;; Modify the default ibuffer-formats
(setq ibuffer-formats
'((mark modified read-only " "
(name 18 18 :left :elide)
" "
(size-h 9 -1 :right)
" "
(mode 16 16 :left :elide)
" "
filename-and-process)))
#+END_SRC
*** scratch buffer
#+BEGIN_SRC emacs-lisp
(defun wiz-scratch-buffer nil
"create a scratch buffer"
(interactive)
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))
#+END_SRC
** TODO Refresh theme on the fly
Use [[https://github.com/dylanaraps/pywal][wal]] and [[https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Notifications.html][file notifications]] to load a theme on the fly, courtesy of [[https://github.com/dylanaraps/pywal/pull/43][this pull request]].
Note: this requires base16-themes
#+BEGIN_SRC emacs-lisp
(add-to-list 'custom-theme-load-path (concat user-emacs-directory "themes/"))
(defvar wiz-theme-file (concat user-emacs-directory "themes/base16-wal-theme.el"))
(defun wiz-apply-theme ()
(interactive)
(progn
(when (file-exists-p wiz-theme-file)
(load-theme 'base16-wal t))))
(defun theme-callback (event)
(wiz-apply-theme))
;; (require 'filenotify)
;; (file-notify-add-watch
;; wiz-theme-file '(change) 'theme-callback)
;; Set the theme on startup
;; (wiz-apply-theme)
#+END_SRC
*** TODO Move this to the base16 config
** tramp
#+BEGIN_SRC emacs-lisp
(setq tramp-default-method "ssh")
#+END_SRC
** Flyspell
Enable a spellchecker
#+BEGIN_SRC emacs-lisp
(add-hook 'org-mode-hook 'flyspell-mode)
#+END_SRC
** calc
#+BEGIN_SRC emacs-lisp
;; (add-to-list 'evil-emacs-state-modes 'calc-mode)
#+END_SRC
* Package Repo Config
** Repo Location
Let's start by configuring the repositories
#+BEGIN_SRC emacs-lisp
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("marmalade" . "https://marmalade-repo.org/packages/")
;; ("melpa-stable" . "https://stable.melpa.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(setq package-enable-at-startup nil)
#+END_SRC
** use-package
use-package for installing packages
https://github.com/jwiegley/use-package
#+BEGIN_SRC emacs-lisp
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
#+END_SRC
* Package Configuration
** Keybind-related packages
*** Show key binds
Pops up a screen that helps you navigate and complete commands
#+BEGIN_SRC emacs-lisp
(use-package which-key
:ensure t
:diminish
:init
(which-key-mode))
#+END_SRC
*** General
General binds keys in a more sane way, and it integrates with
=use-package=
#+BEGIN_SRC emacs-lisp
(use-package general
:ensure t
:config
(general-create-definer wiz-leader-def
:keymaps 'override
:states '(normal insert emacs)
:prefix "SPC"
:non-normal-prefix "M-SPC")
;; Thanks to Jack for the below, smart man
(defun wiz-create-wk-prefix (desc)
"Helper for creating which-key prefix descriptions.
Bind to a key with general to make which-key show DESC
as the prefix's description"
`(:ignore t :wk ,desc))
(defmacro wiz-create-definers (definitions)
"A wrapper for general-create-definer.
For every pair in DEFINITIONS, creates a leader
with name wiz-NAME-def and keybind SPC KEY or M-SPC KEY in normal mode."
`(progn
,@(mapcan
(lambda (def)
(let ((key (car def))
(name (cdr def)))
`((general-create-definer ,(intern (concat "wiz-" name "-def"))
:keymaps 'override
:states '(normal insert emacs)
:prefix ,(concat "SPC " key)
:non-normal-prefix ,(concat "M-SPC " key))
(wiz-leader-def ,key ',(wiz-create-wk-prefix name)))))
definitions)))
(wiz-create-definers
(("b" . "buffer")
("f" . "file")
("h" . "help")
("l" . "misc")
("SPC" . "major")
("o" . "org")
("p" . "project")
("P" . "password")
("w" . "window"))))
#+END_SRC
**** A few binds
***** h - help
#+BEGIN_SRC emacs-lisp
(wiz-help-def
"?" 'help-for-help
"k" 'counsel-descbinds
"f" 'counsel-describe-function
"v" 'counsel-describe-variable
"a" 'counsel-apropos
"h" 'help-for-help)
#+END_SRC
***** b - buffer
#+BEGIN_SRC emacs-lisp
(wiz-buffer-def
"b" 'ibuffer
"S" 'wiz-scratch-buffer
"c" 'wiz-kill-curr-buffer
"C" 'wiz-kill-all-buffers)
#+END_SRC
***** f - file
#+BEGIN_SRC emacs-lisp
(wiz-file-def
"w" 'save-buffer)
#+END_SRC
****** Emacs-related
******* config edit / reload
hit =e= to do that.
#+BEGIN_SRC emacs-lisp
(defun wiz-config-visit ()
(interactive)
(find-file (concat user-emacs-directory "config.org")))
(defun wiz-config-reload ()
(interactive)
(org-babel-load-file
(expand-file-name "config.org" user-emacs-directory)))
(wiz-file-def
"e" '(:ignore t :which-key "emacs files")
"e e" 'wiz-config-visit
"e r" 'wiz-config-reload)
#+END_SRC
***** l - misc
#+BEGIN_SRC emacs-lisp
(wiz-misc-def
:keymaps 'override
:states 'normal
:prefix "SPC l")
#+END_SRC
***** w - window
#+BEGIN_SRC emacs-lisp
;; (wiz-window-def
;; :keymaps 'override
;; :states 'normal
;; :prefix "SPC w")
(wiz-window-def
"o" 'delete-other-windows)
#+END_SRC
***** ibuffer
#+BEGIN_SRC emacs-lisp
(general-define-key
:keymaps 'override
"C-x b" 'ibuffer)
#+END_SRC
***** Terminal
#+BEGIN_SRC emacs-lisp
(wiz-leader-def
"RET" 'eshell)
#+END_SRC
***** Dired
#+BEGIN_SRC emacs-lisp
(wiz-file-def
"d" 'dired)
#+END_SRC
***** sclang-mode
#+BEGIN_SRC emacs-lisp
;; (defun wiz-sclang-eval-region () "do nothing for now")
(general-define-key
:keymaps 'sclang-mode-map
"C-c C-d" 'sclang-eval-defun
"C-c C-c" 'sclang-eval-region-or-line)
(wiz-major-def
:keymaps 'sclang-mode-map
"SPC" 'sclang-eval-region-or-line)
#+END_SRC
*** Vim bindings
Let's get some vim up in here.
**** evil
Evil is pretty much the entirety of Vim in Emacs.
[[evil-collection]] provides evil in many different modes.
[[evil-org]] adds nice bindings to org-mode.
#+BEGIN_SRC emacs-lisp
(use-package evil
:ensure t
:after general
:init
(setq evil-want-integration t
evil-want-C-u-scroll t
evil-want-keybinding nil)
(defun wiz-window-split ()
(interactive)
(evil-window-split)
(evil-window-down 1))
(defun wiz-window-vsplit ()
(interactive)
(evil-window-vsplit)
(evil-window-right 1))
:general
(:keymaps 'override
:states 'normal
"U" 'undo-tree-visualize)
(wiz-window-def
"s" 'wiz-window-split
"S" 'wiz-window-vsplit
"v" 'wiz-window-vsplit
"h" 'evil-window-left
"j" 'evil-window-down
"k" 'evil-window-up
"l" 'evil-window-right
"H" 'evil-window-far-left
"J" 'evil-window-move-very-bottom
"K" 'evil-window-move-very-top
"L" 'evil-window-far-right
"<" 'evil-window-decrease-width
">" 'evil-window-increase-width
"^" 'evil-window-decrease-height
"%" 'evil-window-increase-height
"n" 'evil-window-new
"c" 'evil-window-delete
"w" 'evil-window-next
"W" 'evil-window-prev
"r" 'evil-window-rotate-downwards
"|" 'evil-window-set-width
"_" 'evil-window-set-height)
:config
(evil-mode t))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init)
(setq evil-shift-width 4))
(use-package evil-org
:ensure t
:after (org evil-collection)
:diminish
:general
(wiz-major-def
:keymaps 'evil-org-mode-map
"e" 'org-export-dispatch
"a" 'org-attach
"6" 'outline-up-heading)
(general-define-key
:states 'normal
:keymaps 'evil-org-mode-map
"^" 'evil-first-non-blank)
:hook (org-mode . evil-org-mode)
:config
(add-hook 'evil-org-mode-hook
(lambda ()
(evil-org-set-key-theme '(textobjects insert navigation
additional shift todo
calendar))))
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
;; use c-q to insert single pairs when ya want 'em
(use-package evil-smartparens
:after evil
:ensure t
:hook (smartparens-mode . evil-smartparens-mode)
:general
;; I'm still not too satisfied with these but whateves
(:keymaps '(insert normal visual)
"M-." 'sp-forward-slurp-sexp
"M-l" 'sp-backward-slurp-sexp
"M-n" 'sp-forward-barf-sexp
"M-h" 'sp-backward-barf-sexp)
:init
;; Start this shiznit when emacs starts yea boy it's good B)
;; (smartparens-global-strict-mode)
:config
(require 'smartparens-config))
#+END_SRC
**** evil-surround
You can surround in visual-state with =S<textobject>= or =gS<textobject>=
and in normal-state with =ys<textobject>= or =yS<textobject>=.
You can change a surrounding with =cs<old-textobject><new-textobject>=.
You can delete a surrounding with =ds<textobject>=.
#+BEGIN_SRC emacs-lisp
(use-package evil-surround
:after evil
:ensure t
:diminish
:config
(global-evil-surround-mode 1))
#+END_SRC
**** evil-escape
hit fd to escape pretty much everything
#+BEGIN_SRC emacs-lisp
(use-package evil-escape
:ensure t
:diminish
:config
(setq-default evil-escape-key-sequence "fd")
(evil-escape-mode))
#+END_SRC
**** evil-commentary
[[https://github.com/linktohack/evil-commentary][github here]]
Essentially:
- =gcc= comments out a line
- =gc= comments out the target of a motion
#+BEGIN_SRC emacs-lisp
(use-package evil-commentary
:after evil
:ensure t
:diminish
:hook ((prog-mode . evil-commentary-mode)
(conf-mode . evil-commentary-mode)
(org-mode . evil-commentary-mode)
(tex-mode . evil-commentary-mode)))
#+END_SRC
**** ex extras
#+BEGIN_SRC emacs-lisp
(use-package evil-expat
:ensure t
:diminish)
#+END_SRC
** Convenience
*** Automagic updates
Keep packages up to date
#+BEGIN_SRC emacs-lisp
(use-package auto-package-update
:ensure t
:config
(setq auto-package-update-delete-old-versions t)
(setq auto-package-update-hide-results t)
;; Auto update after a week
(auto-package-update-maybe))
#+END_SRC
*** shift-number
Shifts the next number on the given line
#+BEGIN_SRC emacs-lisp
(use-package shift-number
:ensure t
:general (:keymaps 'override
"M-+" 'shift-number-up
"M-_" 'shift-number-down))
#+END_SRC
*** hide minor modes on modeline
Diminish hides minor modes on the modeline.
#+BEGIN_SRC emacs-lisp
(use-package diminish
:ensure t
:config
(diminish 'undo-tree-mode))
#+END_SRC
*** rainbow
Lights up color tokens / delimiters
#+BEGIN_SRC emacs-lisp
(use-package rainbow-mode
:ensure t
:diminish
:hook ((conf-mode . rainbow-mode)
(sass-mode . rainbow-mode)
(web-mode . rainbow-mode)))
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
#+END_SRC
*** Show cursor location (DISABLED)
When a window is changed / opened, the cursor's location is visibly
pinged.
# #+BEGIN_SRC emacs-lisp
# (use-package beacon
# :ensure t
# :diminish
# :init
# (beacon-mode 1))
# #+END_SRC
*** ranger file manager (DISABLED)
Let's not use this for now
# #+BEGIN_SRC emacs-lisp
# (use-package ranger
# :ensure t
# :init
# (ranger-override-dired-mode)
# :general
# (wiz-file-def
# "d" 'ranger)
# :config
# (setq ranger-modify-header t
# ranger-hide-cursor nil
# ranger-literal-preview nil
# ranger-override-dired-mode 'ranger))
# #+END_SRC
*** w3m
#+BEGIN_SRC emacs-lisp
(use-package w3m
:ensure t)
#+END_SRC
** Autocompletion
*** Fuzzy matching
Ivy, swiper, and counsel all provide fuzzy-matching on different emacs
operations.
#+BEGIN_SRC emacs-lisp
(use-package ivy
:ensure t
:diminish
:general
(wiz-buffer-def
"s" 'ivy-switch-buffer
"v" 'ivy-push-view
"V" 'ivy-pop-view)
:config
(setq ivy-use-virtual-buffers t
ivy-count-format "%d/%d "
ivy-display-style 'fancy))
(use-package swiper
:after ivy
:ensure t
:demand t
:general
(:keymaps 'normal
"/" 'swiper
;; For some reason, searching with swiper causes these to be reversed.
"n" 'evil-search-previous
"N" 'evil-search-next))
(use-package ivy-rich
:after ivy
:ensure t
:config
(setq ivy-rich-path-style 'abbrev
ivy-virtual-abbreviate 'full
ivy-rich-switch-buffer-align-virtual-buffer t)
(ivy-rich-mode 1))
(use-package ivy-bibtex
:after ivy
:ensure t
:defer t)
(use-package counsel
:ensure t
:demand t
:general
("M-x" 'counsel-M-x)
(wiz-org-def
"c" 'counsel-org-capture)
(wiz-file-def
"f" 'counsel-find-file))
(use-package counsel-tramp
:after counsel
:ensure t)
(use-package counsel-projectile
:after counsel
:ensure t)
#+END_SRC
*** Code completion
[[https://company-mode.github.io/][company]] comlpetes anything in the buffer
#+BEGIN_SRC emacs-lisp
(use-package company
:ensure t
:hook (after-init . global-company-mode)
:general
(:keymaps 'company-active-map
"C-SPC" 'company-abort)
:config
(setq company-maximum-prefix-length 3
company-idle-delay 0.2))
;; Documentation popups with company, works best with gui
(when window-system
(use-package company-quickhelp
:ensure t
:after company
:hook (company-mode . company-quickhelp-mode)))
#+END_SRC
** Snippets
Powered by Yasnippet
Note that the =yasnippet-snippets= file may need to be manually
installed.
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:ensure t
;; :hook ((tex-mode . yas-minor-mode)
;; (php-mode . yas-minor-mode)
;; (python-mode . yas-minor-mode)
;; (emacs-lisp-mode . yas-minor-mode)
;; (c-mode . yas-minor-mode)
;; (c++-mode . yas-minor-mode)
;; (org-mode . yas.minor-mode)))
:init
(yas-global-mode))
(use-package yasnippet-snippets
:pin melpa
:after yasnippet
:config
(yas-reload-all))
#+END_SRC
** Text searching
*** deadgrep
[[https://github.com/Wilfred/deadgrep][deadgrep]] provides a frontend to ripgrep
#+BEGIN_SRC emacs-lisp
(use-package deadgrep
:ensure t
:general
(wiz-misc-def
"d" 'deadgrep))
#+END_SRC
*** avy
use =ga= and =gA= to hint letters n stuff.
#+BEGIN_SRC emacs-lisp
(use-package avy
:ensure t
:general
(:states 'normal
"ga" 'avy-goto-char-in-line
"gA" 'avy-goto-char))
(use-package link-hint
:ensure t
;; :after avy
:general
(wiz-misc-def
"l" 'link-hint-open-link
"L" 'link-hint-copy-link))
#+END_SRC
** org-mode
*** Master org package
Keep org-mode up to date straight from the cow's utters.
If the manual is not on your computer, it's [[https://orgmode.org/manual/][here]].
#+BEGIN_SRC emacs-lisp
(use-package org
:ensure t
:ensure org-plus-contrib
:pin org
:general
(wiz-major-def
:keymaps 'org-capture-mode-map
"c" 'org-capture-finalize
"w" 'org-capture-refile
"k" 'org-capture-kill)
(wiz-major-def
:keymaps 'org-mode-map
"e" 'org-export-dispatch)
(wiz-org-def
"a" 'org-agenda
"l" 'org-store-link
"b" 'org-switch))
(use-package org-contacts
:ensure nil
:after org
:custom (org-contacts-files '("~/Documents/org/contacts.org")))
#+END_SRC
*** Pretty bullets
Make bullets look choice
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
:ensure t
:hook (org-mode . org-bullets-mode))
#+END_SRC
*** org-download
For [[https://github.com/abo-abo/org-download][drag n drop]] images n stuff
# #+BEGIN_SRC emacs-lisp
# (use-package org-download
# :after org
# :pin melpa
# :ensure t
# :hook (dired-mode . org-download-enable))
# #+END_SRC
** Startup splash screen
Show a custom buffer on startup
#+BEGIN_SRC emacs-lisp
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "Electronic Macs")
(setq dashboard-startup-banner wiz-startpic)
(setq dashboard-items '((recents . 5)
(agenda)
(projects . 5)
(bookmarks . 5)
(registers . 5))))
#+END_SRC
** Tags
make tag files.
#+BEGIN_SRC emacs-lisp
(use-package ggtags
:ensure t)
#+END_SRC
*** TODO: Make tag files do stuff
** Project Management
TODO: Set this up to actually work well
#+BEGIN_SRC emacs-lisp
(use-package projectile
:ensure t
:diminish
:general
(wiz-leader-def
"p" '(:keymap projectile-command-map)))
#+END_SRC
*** [[https://ox-hugo.scripter.co/][ox-hugo]]
Allows me to write blog entries
See [[https://ox-hugo.scripter.co/doc/auto-export-on-saving/][Here]] for auto export instructions
#+BEGIN_SRC emacs-lisp
(use-package ox-hugo
:ensure t
:after ox)
#+END_SRC
** pretty-mode
[[https://github.com/pretty-mode/pretty-mode][Redisplay parts of the Emacs buffer as pretty symbols.]]
#+BEGIN_SRC emacs-lisp
(when window-system
(use-package pretty-mode
:ensure t
:config
(global-pretty-mode t)))
#+END_SRC
** Error checking
#+BEGIN_SRC emacs-lisp
(use-package flycheck
:ensure t
:defer t)
#+END_SRC
** Programming language specific stuff
*** C / C++
**** Completion
Irony handles enhanced C / C++ operations powered by clang
#+BEGIN_SRC emacs-lisp
(use-package irony
:ensure t
:defer t
:hook ((c++-mode . irony-mode)
(c-mode . irony-mode)
(irony-mode . irony-cdb-autosetup-compile-options)))
(use-package company-irony
:after (company, irony)
:ensure t
:config
(add-to-list 'company-backends 'company-irony))
#+END_SRC
*** Python
**** TODO jedi for autocompletion sources n stuff
#+BEGIN_SRC emacs-lisp
(use-package company-jedi
:ensure t
:defer t
:init
(defun wiz-python-company-mode-hook ()
(add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'wiz-python-company-mode-hook)
(setq python-environment-virtualenv '("virtualenv" "--system-site-packages" "--quiet"))
(setq jedi:environment-root "jedi") ; or any other name you like
(setq jedi:environment-virtualenv
(append python-environment-virtualenv
'("--python" "/usr/bin/python3"))))
#+END_SRC
*** Web Development
**** Web mode
Should give everything you need for a web-dev major mode, except for
company integration.
This might also provide a decent php-mode, but that might require some
testing.
#+BEGIN_SRC emacs-lisp
(use-package web-mode
:pin melpa
:ensure t
:defer t
:hook (web-mode . company-mode)
:init
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.eex\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
:config
(setq web-mode-markup-indent-offset 2))
#+END_SRC
**** Web mode completion
Web-mode completion
#+BEGIN_SRC emacs-lisp
(use-package company-web
:ensure t
:hook (web-mode . (lambda ()
(add-to-list 'company-backends 'company-web-html)
(add-to-list 'company-backends 'company-web-jade)
(add-to-list 'company-backends 'company-web-slim))))
#+END_SRC
**** JSON
Just an enhanced json mode
#+BEGIN_SRC emacs-lisp
(use-package json-mode
:ensure t
:mode (("\\.json\\'" . json-mode)
("\\manifest.webapp\\'" . json-mode )
("\\.tern-project\\'" . json-mode)))
#+END_SRC
**** PHP
Should (at least) include all standard function sources for company in
addition to some other niceties. See more on their [[https://github.com/arnested/php-extras][GitHub page]].
#+BEGIN_SRC emacs-lisp
(use-package php-extras
:pin marmalade
:defer t
:ensure t
:hook (php-mode . web-mode))
#+END_SRC
**** sass
#+BEGIN_SRC emacs-lisp
(use-package sass-mode
:pin melpa
:ensure t)
#+END_SRC
**** request
Send web requests in emacs
#+BEGIN_SRC emacs-lisp
(use-package request
:pin melpa
:ensure t)
#+END_SRC
*** LaTeX
**** Completion
#+BEGIN_SRC emacs-lisp
(use-package company-auctex
:ensure t)
(use-package company-bibtex
:ensure t
:config
(add-to-list 'company-backends 'company-bibtex))
#+END_SRC
*** Shell
Show completions for shell mode buffers
#+BEGIN_SRC emacs-lisp
(use-package readline-complete
:ensure t)
#+END_SRC
*** Music stuff
**** Supercollider
#+BEGIN_SRC emacs-lisp
(use-package sclang-snippets
:ensure t)
#+END_SRC
*** OS DSL
**** Arch Linux PKGBUILD
#+BEGIN_SRC emacs-lisp
(use-package pkgbuild-mode
:ensure t)
#+END_SRC
**** Nix
#+BEGIN_SRC emacs-lisp
(use-package nix-mode
:ensure t)
#+END_SRC
**** Puppet
#+BEGIN_SRC emacs-lisp
(use-package puppet-mode
:pin melpa
:ensure t)
#+END_SRC
#+RESULTS:
** IRC
Internet relay chat. It's where hackers go to communicate. Think of it
like two boats in a shipping channel.
#+BEGIN_SRC emacs-lisp
;; keep ERC up to date
(use-package erc
:ensure t
:defer t
:general
(wiz-major-def
:keymaps 'erc-mode
"b" 'erc-iswitchb
"c" 'erc-toggle-interpret-controls
"d" 'erc-input-action
"e" 'erc-toggle-ctcp-autoresponse
"f" 'erc-toggle-flood-control
"TAB" 'erc-invite-only-mode
"j" 'erc-join-channel
"k" 'erc-go-to-log-matches-buffer
"l" 'erc-save-buffer-in-logs
"n" 'erc-channel-names
"o" 'erc-get-channel-names-from-keypress
"p" 'erc-part-from-channel
"q" 'erc-quit-from-server
"r" 'erc-remove-text-properties-region
"t" 'erc-set-topic
"u" 'erc-kill-input)
:init
(defun wiz-irc-init ()
"Access the encrypted file storing all of your irc connection
information. It automatically connects you to a default set of
servers."
(interactive)
(if (file-exists-p
(concat user-emacs-directory "irc-servers.el.gpg"))
(load-file (concat user-emacs-directory "irc-servers.el.gpg"))))
;; Load the file containing all of my server connection info
:config
;; Enable the modules I want
(setq erc-modules '(autojoin
completion
dcc
button
fill
match
netsplit
ring
list
log
readonly
noncommands
networks
move-to-prompt
notifications
track
irccontrols
move-to-prompt
menu
stamp))
;; spellchecking :D
(erc-spelling-mode 1)
;; Use my auth-sources pl0x
(setq erc-prompt-for-nickserv-password nil
erc-prompt-for-password nil)
;; List of places to look for IRC connection info
;; irc-servers.el.gpg should now hold most of this information.
(setq auth-sources `("~/.authinfo.gpg"
,(concat user-emacs-directory ".authinfo.gpg")))
;; Append this if name is in use
(setq erc-nick-uniquifier "^")
;; De-clutter my shiznit
(setq erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
(setq erc-lurker-threshold-time 600)
;; Name buffers something logical
(setq erc-rename-buffers t)
;; Interpret mIRC-style color commands in IRC chats
(setq erc-interpret-mirc-color t)'
;; Don't focus buffer on connect
(setq erc-join-buffer 'bury)
;; Change fill to emacs buffer width
;; It's a bit buggy, so cuidado, eh?
;; Commented because of how bug this is
;; (make-variable-buffer-local 'erc-fill-column)
;; (add-hook 'window-configuration-change-hook
;; '(lambda ()
;; (save-excursion
;; (walk-windows
;; (lambda (w)
;; (let ((buffer (window-buffer w)))
;; (set-buffer buffer)
;; (when (eq major-mode 'erc-mode)
;; (setq erc-fill-column (- (window-width w) 2)))))))))
(setq erc-prompt (lambda () (concat "[" (buffer-name) "]")))
;; (defun wiz-erc-mode-hook ()
;; (setq erc-fill-column 92))
(setq erc-fill-column 92)
;; (add-hook 'erc-mode-hook 'wiz-erc-mode-hook)
(setq erc-button-url-regexp
"\\([-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]+\\.\\)+[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]*[-a-zA-Z0-9\\/]")
(setq erc-fill-static-center 15
erc-fill-function 'erc-fill-static
;; Logging
erc-log-insert-log-on-open nil
erc-log-channels t
erc-log-channels-directory "~/.irclogs/"
erc-save-buffer-on-part t
erc-hide-timestamps nil)
:config
(erc-update-modules))
;; highlight nicks
(use-package erc-hl-nicks
:after erc
:ensure t
:defer t
:init
(add-to-list 'erc-modules 'hl-nicks)
:config
(erc-update-modules))
;; Display images as links in a channel
;; (use-package erc-image
;; :after erc
;; :ensure t
;; :defer t
;; :init
;; (add-to-list 'erc-modules 'image)
;; :config
;; (erc-update-modules))
;; (use-package ercn
;; :pin melpa
;; :after erc
;; :ensure t
;; :init
;; ;; todo config this lol
;; (defun do-notify nickname message ())
;; :config
;; (setq ercn-notify-rules
;; '((current-nick . all)
;; (keyword . all)
;; ;; (pal . ("#emacs"))
;; (pal . all)
;; (query-buffer . all))))
(use-package erc-status-sidebar
:after erc
:ensure t)
#+END_SRC
** Ledger
#+BEGIN_SRC emacs-lisp
(use-package ledger-mode
:ensure t
:init
(setq ledger-clear-whole-transactions 1)
:config
(add-to-list 'evil-emacs-state-modes 'ledger-report-mode)
;; remove evil mode from ledger reports
:mode ("\\.dat\\'"
"\\.ledger\\'")
;; :general
;; (wiz-file-def
;; :keymap 'ledger-mode-map
;; "w" 'wiz-ledger-save)
:preface
(defun wiz-ledger-save ()
"Automatically clean the ledger buffer at each save."
(interactive)
(save-excursion
(when (buffer-modified-p)
(with-demoted-errors (ledger-mode-clean-buffer))
(save-buffer)))))
#+END_SRC
** pass
I use [[https://www.passwordstore.org/][=pass=]] for my password management.
#+BEGIN_SRC emacs-lisp
(use-package ivy-pass
:ensure t
:general
(wiz-leader-def
"P" 'ivy-pass))
#+END_SRC
** Git (magit)
I hear that this is one of those emacs "killer apps"
See keybindings [[https://github.com/emacs-evil/evil-magit][here.]]
#+BEGIN_SRC emacs-lisp
(use-package magit
:ensure t
:general
(wiz-leader-def
"g" 'magit))
(use-package evil-magit
:after (magit evil evil-collection)
:ensure t)
#+END_SRC
** Docker
Enables usage of docker from within emacs, and supports dockerfiles
#+BEGIN_SRC emacs-lisp
(use-package docker
:ensure t)
(use-package dockerfile-mode
:ensure t
:pin melpa)
(use-package docker-compose-mode
:ensure t
:pin melpa)
(use-package docker-tramp
:ensure t)
#+END_SRC
** Themes
#+BEGIN_SRC emacs-lisp
(use-package base16
:ensure t
:init
(load-theme 'base16-black-metal-mayhem))
#+END_SRC
* Final Touches
Display a [[https://xkcd.com/37/][sick ass-message]] on the desktop to verify that dbus is good
and all is well in the wold
#+BEGIN_SRC emacs-lisp
(notifications-notify :title "Emacs"
:body "Fully loaded & operational!")
(message "Emacs done initializing.")
#+END_SRC