2018-10-15 18:28:02 -04:00
* Emacs Config
** Font
Set the font to something nice that will display ligntures
#+BEGIN_SRC emacs-lisp
(add-to-list 'default-frame-alist '(font . "Fira Code 12"))
(set-face-attribute 'default t :font "Fira Code 12")
#+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
** Remove menu bar
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 matching parenthesis
Shows matching parenthesis
#+BEGIN_SRC emacs-lisp
2018-12-08 11:13:52 -05:00
(require 'paren)
(setq show-paren-delay 0)
(show-paren-mode)
2018-10-15 18:28:02 -04:00
#+END_SRC
** Show columns
#+BEGIN_SRC emacs-lisp
(setq column-number-mode t)
#+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
(set-frame-parameter (selected-frame) 'alpha 85)
(add-to-list 'default-frame-alist '(alpha . 85))
#+END_SRC
** Scrolling
#+BEGIN_SRC emacs-lisp
(setq scroll-conservatively 100) ;; don't scroll a metric boatload when bottom is hit
#+END_SRC
** Disable bell
Shut up, emacs.
#+BEGIN_SRC emacs-lisp
(setq ring-bell-function 'ignore)
#+END_SRC
2018-10-16 22:02:11 -04:00
** Relative line numbers
Use the default emacs relative line numbers, but switch to absolute lines when in insert mode.
2018-10-15 18:28:02 -04:00
#+BEGIN_SRC emacs-lisp
(setq linum-format " %3d ")
2018-10-16 22:02:11 -04:00
(setq-default display-line-numbers 'relative
display-line-numbers-widen t
display-line-numbers-current-absolute t)
(defun foltz-relative-numbers ()
(setq-local display-line-numbers 'relative))
(defun foltz-absolute-numbers ()
(setq-local display-line-numbers t))
(add-hook 'evil-insert-state-entry-hook #'foltz-absolute-numbers)
(add-hook 'evil-insert-state-exit-hook #'foltz-relative-numbers)
(global-display-line-numbers-mode t)
2018-10-15 18:28:02 -04:00
#+END_SRC
** y or n prompts
Make yes-or-no prompts ask for y or n instead
#+BEGIN_SRC emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p)
#+END_SRC
2018-12-12 16:57:04 -05:00
** Keep backup files and lockfiles out of the way
2018-10-15 18:28:02 -04:00
By default, emacs makes files like =file~= and =#file#= and clutters up
my projects. Instead, store them in =/tmp= !
#+BEGIN_SRC emacs-lisp
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
2018-12-12 16:57:04 -05:00
(setq create-lockfiles nil)
2018-10-15 18:28:02 -04:00
#+END_SRC
2018-10-18 10:29:46 -04:00
** Customize the terminal
Use fish shell in ansi-term
#+BEGIN_SRC emacs-lisp
(defadvice ansi-term (before force-bash)
(interactive '("/usr/bin/fish")))
(ad-activate 'ansi-term)
#+END_SRC
2018-12-08 16:19:55 -05:00
** Theme
#+BEGIN_SRC emacs-lisp
(defvar foltz-wal-theme-path "~/.cache/wal/colors.el")
(defun foltz-apply-theme ()
(interactive)
(load-file foltz-wal-theme-path))
(defun foltz-theme-callback (event)
(foltz-apply-theme))
(if (file-exists-p foltz-wal-theme-path)
(progn
(require 'filenotify)
(file-notify-add-watch foltz-wal-theme-path '(change) 'foltz-theme-callback)
(foltz-apply-theme))
(load-theme spacemacs-dark))
#+END_SRC
2018-12-21 11:54:00 -05:00
** Auth storage location
Set stored auth tokens to be encrypted into emacs directory
#+BEGIN_SRC emacs-lisp
(setq auth-sources '("~/.emacs.d/authinfo.gpg"))
#+END_SRC
2019-02-05 23:47:18 -05:00
* Package Management
2018-10-15 18:28:02 -04:00
** 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)
(package-initialize)
#+END_SRC
2019-02-06 18:47:02 -05:00
** Use-Package
2018-10-15 18:28:02 -04:00
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))
(setq use-package-compute-statistics t)
(setq use-package-always-ensure t)
(setq use-package-always-pin "melpa-stable")
(setq use-package-verbose t)
#+END_SRC
2019-02-06 18:47:02 -05:00
** Use-Package Extensions
2019-02-05 23:47:18 -05:00
*** Utilities
Some functions to help with creating custom use-package keywords
#+BEGIN_SRC emacs-lisp
(defun foltz-add-use-package-keyword (keyword deferring)
2019-02-06 18:47:02 -05:00
"Add the keyword to use-package at the proper index,
and to the deferring keywords list if necessary"
(setq use-package-keywords
2019-02-06 18:48:50 -05:00
(let ((idx (+ 1 (cl-position :hook use-package-keywords))))
2019-02-06 18:47:02 -05:00
(append
(seq-subseq use-package-keywords 0 idx)
(list keyword)
(nthcdr idx use-package-keywords))))
(when deferring
(setq use-package-deferring-keywords
(append use-package-deferring-keywords (list keyword)))))
2019-02-05 23:47:18 -05:00
#+END_SRC
*** :company
#+BEGIN_SRC emacs-lisp
(defun use-package-normalize/:company (name keyword args)
2019-02-06 18:47:02 -05:00
(use-package-as-one (symbol-name keyword) args
(lambda (label arg)
(unless (or (consp arg) (use-package-non-nil-symbolp arg))
(use-package-error
(concat
label
"<symbol > or "
"(<symbol or list of symbols > . <symbol or function >) or "
"a list of these")))
(use-package-normalize-pairs
(lambda (k)
(or (use-package-non-nil-symbolp k)
(and (consp k)
(not (cdr (last k)))
(seq-every-p 'use-package-non-nil-symbolp k))))
#'use-package-recognize-function
name label arg))))
(defun use-package-handler/:company (name keyword args rest state)
(use-package-concat
(use-package-process-keywords name rest state)
(mapcan
(lambda (def)
(let ((modes (car def))
(backend (cdr def))
(fun (intern (concat "foltz-company-add-" (symbol-name (cdr def))))))
(when backend
(append
`((defun ,fun ()
(let ((backend ,(append (list backend) '(:with company-yasnippet))))
(unless (member backend company-backends)
(add-to-list 'company-backends backend)))))
(mapcar
(lambda (mode)
`(add-hook
',(intern (concat (symbol-name mode) use-package-hook-name-suffix))
#',fun))
(if (use-package-non-nil-symbolp modes) (list modes) modes))))))
(use-package-normalize-commands args))))
(defalias 'use-package-autoloads/:company 'use-package-autoloads-mode)
(foltz-add-use-package-keyword :company nil)
2019-02-05 23:47:18 -05:00
#+END_SRC
2018-10-15 18:28:02 -04:00
* General Packages Configuration
** Modeline cleanup
Adds support for =:diminish= in use-package declarations,
basically hides a mode from the modeline.
#+BEGIN_SRC emacs-lisp
(use-package diminish)
#+END_SRC
** Keybind completion
Pops up a buffer that helps you navigate and complete commands
#+BEGIN_SRC emacs-lisp
(use-package which-key
:diminish
:config
(which-key-mode))
#+END_SRC
** Keybind Manager
General manages my keybindings.
#+BEGIN_SRC emacs-lisp
(use-package general
:pin melpa)
#+END_SRC
*** Leader definitions
Create a leader key, like the \ in vim.
In this case, =SPC= is used as a leader. Following the leader,
different buttons bring you to different options.
See [[https://github.com/noctuid/general.el#which-key-integration ][here ]] for which-key integration information
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-leader-def
:keymaps 'override
:states 'normal
:prefix "SPC"
"m" '(:ignore t :which-key "major-mode...")
"o" '(:ignore t :which-key "org-mode...")
2018-10-16 22:02:11 -04:00
"p" '(:ignore t :which-key "projectile-mode...")
2018-10-15 18:28:02 -04:00
"g" '(:ignore t :which-key "git...")
"h" '(:ignore t :which-key "help...")
"b" '(:ignore t :which-key "buffer...")
"w" '(:ignore t :which-key "window...")
"f" '(:ignore t :which-key "file..."))
#+END_SRC
**** m - major-modes
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-major-def
:states 'normal
:prefix "SPC m")
#+END_SRC
**** o - org-mode
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-org-def
:keymaps 'override
:states
'normal
:prefix "SPC o")
#+END_SRC
2018-10-16 22:02:11 -04:00
**** p - projectile-mode
Since we will be binding the entire projectile-mode
keymap to this, we don't actually need a definer.
2018-10-15 18:28:02 -04:00
**** g - git
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-git-def
:states 'normal
:keymaps 'override
:prefix "SPC g")
#+END_SRC
**** h - help
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-help-def
:states 'normal
:keymaps 'override
:prefix "SPC h")
(foltz-help-def
"?" 'help-for-help
"h" 'help-for-help
2019-02-01 09:57:34 -05:00
"k" 'describe-key
"m" 'describe-mode)
2018-10-15 18:28:02 -04:00
#+END_SRC
**** b - buffer
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-buffer-def
:states 'normal
:keymaps 'override
:prefix "SPC b")
(foltz-buffer-def
"i" 'ibuffer)
#+END_SRC
**** w - window
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-window-def
:states 'normal
:keymaps 'override
:prefix "SPC w")
(foltz-window-def
"o" 'delete-other-windows)
#+END_SRC
**** f - file
#+BEGIN_SRC emacs-lisp
(general-create-definer foltz-file-def
:states 'normal
:keymaps 'override
:prefix "SPC f")
(defun foltz-config-visit ()
(interactive)
(find-file (concat user-emacs-directory "config.org")))
(defun foltz-config-reload ()
(interactive)
(org-babel-load-file
(expand-file-name "config.org" user-emacs-directory)))
(foltz-file-def
"w" 'save-buffer
"r" 'revert-buffer
"e" '(:ignore t :which-key "emacs files")
"e e" 'foltz-config-visit
"e r" 'foltz-config-reload)
#+END_SRC
** Vim
Evil is pretty much the entirety of Vim in Emacs.
[[https://github.com/Somelauw/evil-org-mode ][evil-org ]] adds nice bindings to org-mode.
#+BEGIN_SRC emacs-lisp
(use-package evil
:after general
:diminish undo-tree-mode
:init
(setq evil-want-integration nil)
(setq evil-want-keybinding nil)
:config
(evil-mode t)
:custom
(evil-shift-width 4 "Set indent to 4 spaces"))
(use-package evil-leader
:after evil
:init
(defun foltz-window-split ()
(interactive)
(evil-window-split)
(evil-window-down 1))
(defun foltz-window-vsplit ()
(interactive)
(evil-window-vsplit)
(evil-window-right 1))
:general
(:keymaps 'override
:states 'normal
"U" 'undo-tree-visualize)
(foltz-window-def
"-" 'foltz-window-split
"=" 'foltz-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
(global-evil-leader-mode))
(use-package evil-org
:after (evil org)
:hook (org-mode . evil-org-mode)
:config
(add-hook 'evil-org-mode (lambda ()
(evil-org-set-key-theme
'(textobjects insert navigation
additional shift todo calendar)))))
#+END_SRC
** Startup dashboard
Show a cool custom buffer on startup
#+BEGIN_SRC emacs-lisp
(use-package dashboard
:diminish page-break-lines-mode
:config
(dashboard-setup-startup-hook)
2019-02-04 23:50:16 -05:00
(setq initial-buffer-choice (lambda ()
(if (get-buffer "*scratch* ")
(kill-buffer "*scratch* "))
(get-buffer "*dashboard* ")))
2018-10-15 18:28:02 -04:00
:custom
(dashboard-startup-banner 'logo)
(dashboard-banner-logo-title "Welcome to Electronic Macs")
(dashboard-items
'((recents . 5)
(agenda)
(bookmarks . 5)
(registers . 5))))
#+END_SRC
** Folder tree
A cool toggleable directory structure sidebar
It also needs icon fonts, installed with =M-x all-the-icons-install-fonts=
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons)
(use-package neotree
:after all-the-icons
:commands neotree-toggle
:general
2018-10-27 10:59:12 -04:00
(:keymaps 'neotree-mode-map
:states 'normal
"RET" 'neotree-enter
"TAB" 'neotree-quick-look
"q" 'neotree-hide
"g" 'neotree-refresh
"A" 'neotree-stretch-toggle
"H" 'neotree-hidden-file-toggle)
2018-10-15 18:28:02 -04:00
(foltz-leader-def
:states 'normal
"t" 'neotree-toggle)
:custom
(neo-theme (if (display-graphic-p) 'icons 'arrow)))
#+END_SRC
** Organization
2018-10-27 01:04:21 -04:00
*** Capture Templates
All of my capture templates, from tasks to bookmarks.
**** Refile Targets
Goodize the refiling targets to allow moving to subtrees
#+BEGIN_SRC emacs-lisp
(defun foltz-org-capture-refile ()
(interactive)
(setq-local org-refile-targets '((nil :maxlevel . 5)))
(setq-local org-refile-use-outline-path t)
(org-refile))
#+END_SRC
2018-10-27 13:05:58 -04:00
2018-10-27 01:04:21 -04:00
**** Tasks
#+BEGIN_SRC emacs-lisp
2018-10-27 13:05:58 -04:00
(setq foltz-org-capture-task-templates
'(("t" "Todo")
2018-10-27 01:04:21 -04:00
("tg" "General" entry
(file+headline "notes.org" "Todo")
2018-11-05 16:58:07 -05:00
"** TODO %^{todo}\nNotes: %?\n")
2018-10-27 01:04:21 -04:00
("tt" "General (Date)" entry
(file+olp+datetree "notes.org")
2018-10-27 10:54:15 -04:00
"*** TODO %^{todo}\nDue: %^t\nNotes: %?\n")
2018-10-27 01:04:21 -04:00
("tT" "General (Date+Time)" entry
(file+olp+datetree "notes.org")
2018-10-27 10:54:15 -04:00
"*** TODO %^{todo}\nDue: %^T\nNotes: %?\n")
2018-10-27 01:04:21 -04:00
("ts" "School (Date)" entry
(file+olp+datetree "notes.org")
2018-10-27 10:54:15 -04:00
"*** TODO %^{todo}\nDue: %^t\nClass: %^{class}\nNotes: %?\n")
2018-10-27 01:04:21 -04:00
("tS" "School (Date+Time)" entry
(file+olp+datetree "notes.org")
2018-10-27 10:54:15 -04:00
"*** TODO %^{todo}\nDue: %^T\nClass: %^{class}\nNotes: %?\n")))
2018-10-27 01:04:21 -04:00
#+END_SRC
**** Bookmarks
#+BEGIN_SRC emacs-lisp
2018-10-27 13:05:58 -04:00
(setq foltz-org-capture-bookmark-templates
'(("b" "Bookmark" entry
2018-10-27 01:04:21 -04:00
(file+headline "links.org" "Unsorted Links")
2018-10-27 10:54:15 -04:00
"** [[%^{link} ][%^{name} ]]\nCreated: %U\nAbout: %^{description}%?\n")))
2018-10-27 01:04:21 -04:00
#+END_SRC
**** Personal
#+BEGIN_SRC emacs-lisp
2018-10-27 13:05:58 -04:00
(setq foltz-org-capture-personal-templates
'(("j" "Journal")
2018-10-27 01:04:21 -04:00
("jj" "Journal Entry" entry
(file+olp+datetree "journal.org")
2018-10-27 10:54:15 -04:00
"**** Today's Events\n%?")
2018-10-27 01:04:21 -04:00
("jt" "Thoughts" entry
(file+headline "notes.org" "Thoughts")
2018-10-27 10:54:15 -04:00
"** %^{summary}\n%U\n%?")
2018-10-27 01:04:21 -04:00
("jd" "Dream Journal Entry" entry
(file+olp+datetree "dreams.org")
2018-10-27 10:54:15 -04:00
"**** Dream\n%?")))
2018-10-27 01:04:21 -04:00
#+END_SRC
2018-10-27 13:05:58 -04:00
**** Protocol
#+BEGIN_SRC emacs-lisp
(setq foltz-org-capture-protocol-templates
'(("w" "Website" entry
(file+headline "sites.org" "Unsorted Sites")
"** [[%:link ][%:description%? ]]\nCreated: %U\nAbout: %^{description}%?\n%:initial")))
#+END_SRC
2018-10-27 01:04:21 -04:00
**** All
Tie it all together.
#+BEGIN_SRC emacs-lisp
(setq foltz-org-capture-templates
(append
foltz-org-capture-task-templates
foltz-org-capture-personal-templates
2018-10-27 13:05:58 -04:00
foltz-org-capture-bookmark-templates
foltz-org-capture-protocol-templates))
2018-10-27 01:04:21 -04:00
#+END_SRC
2018-10-27 13:05:58 -04:00
2018-10-27 01:04:21 -04:00
*** Structure Templates
Defines expansions with =<= followed by a string in org-mode.
**** Source Blocks
#+BEGIN_SRC emacs-lisp
(setq foltz-org-source-structure-templates '(
("el" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC")))
#+END_SRC
**** All
Tie it all together.
#+BEGIN_SRC emacs-lisp
(setq foltz-org-structure-templates
(append
foltz-org-source-structure-templates))
#+END_SRC
*** Org-mode
2018-10-15 18:28:02 -04:00
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
:pin org
:mode ("\\.org\\'" . org-mode)
2018-10-27 10:54:15 -04:00
:hook ((org-mode . org-indent-mode)
(org-capture-mode . evil-insert-state))
2018-10-15 18:28:02 -04:00
:general
(foltz-major-def
:keymaps 'org-mode-map
"e" 'org-export-dispatch
"a" 'org-attach)
(foltz-org-def
"a" 'org-agenda
"c" 'org-capture
"l" 'org-store-link
2018-10-27 01:18:42 -04:00
"b" 'org-switchb
"r" 'foltz-org-capture-refile)
2018-10-27 01:04:21 -04:00
2018-10-15 18:28:02 -04:00
:custom
(org-directory "~/Documents/org")
(org-agenda-files '("~/Documents/org/ "))
(org-default-notes-file "notes.org")
(org-agenda-include-diary t)
(org-src-window-setup 'current-window "Edit source code in the current window")
(org-src-fontify-natively t "Highlight syntax in source blocks")
(org-latex-to-pdf-process '("latexmk -f pdf %f") "Use pdflatex for export")
2018-10-27 01:04:21 -04:00
(org-capture-templates foltz-org-capture-templates)
2018-11-05 17:27:57 -05:00
(org-structure-template-alist (append org-structure-template-alist foltz-org-structure-templates)))
2018-10-15 18:28:02 -04:00
#+END_SRC
*** Pretty org-mode bullets
Make bullets look choice
#+BEGIN_SRC emacs-lisp
(use-package org-bullets
:hook (org-mode . org-bullets-mode))
#+END_SRC
** Fuzzy Matching
Ivy, swiper, and counsel all provide fuzzy-matching on different
emacs operations.
#+BEGIN_SRC emacs-lisp
(use-package ivy
:init
; Define some functions to bind to
(defun foltz-kill-curr-buffer ()
(interactive)
(kill-buffer (current-buffer)))
(defun foltz-kill-all-buffers ()
(interactive)
(mapc 'kill-buffer (buffer-list)))
:general
(foltz-buffer-def
"b" 'ivy-switch-buffer
"v" 'ivy-push-view
"V" 'ivy-pop-view
2018-10-27 01:04:21 -04:00
"c" 'foltz-kill-curr-buffer
"C" 'foltz-kill-all-buffers)
(:keymaps 'org-capture-mode-map
:states 'normal
"C-c C-w" 'foltz-org-capture-refile)
2018-10-15 18:28:02 -04:00
:custom
(ivy-use-virtual-buffers t)
(ivy-count-format "%d/%d"))
(use-package swiper
:after evil
:general
(:keymaps 'override
:states 'normal
"/" 'swiper
"n" 'evil-search-previous
"N" 'evil-search-next))
(use-package counsel
:general
("M-x" 'counsel-M-x)
(foltz-leader-def
:states 'normal
"x" 'counsel-M-x)
(foltz-file-def
"f" 'counsel-find-file)
(foltz-help-def
"k" 'counsel-descbinds
"f" 'counsel-describe-function
"v" 'counsel-describe-variable
"l" 'counsel-find-library
"a" 'counsel-apropos
"s" 'counsel-info-lookup-symbol
"u" 'counsel-unicode-char))
#+END_SRC
** Avy
Hotkeys for jumping to characters with =f=
#+BEGIN_SRC emacs-lisp
(use-package avy
:general
(:keymaps 'override
:states 'normal
"f" 'avy-goto-char-in-line
"F" 'avy-goto-char))
#+END_SRC
2019-02-04 23:50:28 -05:00
** Discord Rich Presence
#+BEGIN_SRC emacs-lisp
(use-package elcord
:pin melpa
:commands elcord-mode
:general
(foltz-major-def
:keymaps 'prog-mode-map
"d" #'elcord-mode))
#+END_SRC
2018-10-15 18:28:02 -04:00
* Programming Packages Configuration
2019-02-06 18:33:46 -05:00
** General Configuration
Everything the light touches is prog-mode's kingdom.
#+BEGIN_SRC emacs-lisp
; Default to 4 space indent
(add-hook 'prog-mode-hook #'foltz-indent-4-spaces)
#+END_SRC
** Formatting
*** Indentation
Set some *sane* defaults
#+BEGIN_SRC emacs-lisp
(setq foltz-tab-width 4)
(setq-default python-indent-offset foltz-tab-width)
(setq-default evil-shift-width foltz-tab-width)
(setq-default c-basic-offset foltz-tab-width)
; Disable annoying electric indent of previous lines
(setq-default electric-indent-inhibit t)
; Eat the whole tab when I press backspace
(setq backward-delete-char-untabify-method 'hungry)
#+END_SRC
Define some *useful* helper functions
#+BEGIN_SRC emacs-lisp
(defun foltz-indent-tabs ()
(interactive)
(setq tab-width foltz-tab-width)
(local-set-key (kbd "TAB") 'tab'to-tab-stop)
(setq indent-tabs-mode t))
(defun foltz-indent-spaces (num-spaces)
(interactive)
(setq tab-width num-spaces)
(setq indent-tabs-mode nil))
(defun foltz-indent-2-spaces ()
(foltz-indent-spaces 2))
(defun foltz-indent-4-spaces ()
(foltz-indent-spaces 4))
(defun foltz-indent-8-spaces ()
(foltz-indent-spaces 8))
(foltz-indent-4-spaces)
(setq whitespace-style '(face tabs tab-mark trailing))
(custom-set-faces
'(whitespace-tab ((t (:foreground "#636363")))))
(setq whitespace-display-mappings
'((tab-mark 9 [124 9] [92 9])))
(add-hook 'prog-mode-hook #'whitespace-mode)
#+END_SRC
2018-10-15 18:28:02 -04:00
*** Company
company auto-completes stuff in the buffer,
company-quickhelp shows documentation popups
when idling on a completion candidate.
#+BEGIN_SRC emacs-lisp
(use-package company
2019-02-06 18:47:02 -05:00
:hook ((prog-mode cdlatex-mode) . company-mode)
2018-10-15 18:28:02 -04:00
:general
(:keymaps 'company-active-map
"C-SPC" 'company-abort)
:custom
(company-maximum-prefix-length 2)
(company-idle-delay 0.2 "Decrease idle delay"))
2019-02-06 18:47:02 -05:00
2018-10-15 18:28:02 -04:00
(use-package company-quickhelp
:hook (company-mode . company-quickhelp-mode))
#+END_SRC
2018-12-21 12:51:30 -05:00
*** Smart Parentheses
2018-12-21 12:39:15 -05:00
smartparens handles parens for languages that aren't lispy,
and paredit handles the rest.
Keybinds in =M-x sp-cheat-sheet= .
#+BEGIN_SRC emacs-lisp
(use-package paredit
:diminish
:commands enable-paredit-mode)
(use-package smartparens
:diminish
:commands smartparens-strict-mode
:config
(require 'smartparens-config))
(use-package evil-smartparens
:hook (smartparens-enabled . evil-smartparens-mode))
2018-12-21 12:51:30 -05:00
#+END_SRC
*** Smart Parentheses Modes
Picks a suitable parenthesis editing mode for the
current major mode when entering any prog-mode.
#+BEGIN_SRC emacs-lisp
2018-12-21 12:39:15 -05:00
(defun foltz-paren-mode ()
(if (member major-mode
'(emacs-lisp-mode
lisp-mode
lisp-interaction-mode
scheme-mode))
(enable-paredit-mode)
(smartparens-strict-mode)))
2018-12-21 12:51:30 -05:00
(add-hook 'prog-mode-hook #'foltz-paren-mode)
2018-12-21 12:39:15 -05:00
#+END_SRC
*** evil-surround
Use =S= and a delimiter to surround in visual mode.
#+BEGIN_SRC emacs-lisp
(use-package evil-surround
:after evil
:diminish
:config
(global-evil-surround-mode 1))
#+END_SRC
2018-12-21 12:47:29 -05:00
*** ws-butler
Unobtrusively cleans up whitespace before EOLs
as you edit, stopping the noisy commits generated
from blanket trimming entire files.
#+BEGIN_SRC emacs-lisp
(use-package ws-butler
:hook (prog-mode . ws-butler-mode))
#+END_SRC
2018-10-15 18:28:02 -04:00
** Prettification
*** pretty-mode
[[https://github.com/pretty-mode/pretty-mode ][Redisplay parts of the Emacs buffer as pretty symbols. ]]
#+BEGIN_SRC emacs-lisp
(use-package pretty-mode
:hook (prog-mode . pretty-mode)
:config
(pretty-deactivate-groups
'(:equality :sub-and-superscripts))
(pretty-activate-groups
'(:greek :arithmetic-nary
:ordering :ordering-double :ordering-triple
:arrows :arrows-twoheaded :punctuation :logic :sets)))
#+END_SRC
*** prettify-symbols-mode
Built into emacs since 24.1
#+BEGIN_SRC emacs-lisp
2018-10-18 10:29:46 -04:00
(add-hook 'python-mode-hook 'prettify-symbols-mode)
2018-10-15 18:28:02 -04:00
(add-hook 'python-mode-hook (lambda ()
(mapc (lambda (pair) (push pair prettify-symbols-alist))
'(;; Syntax
("in" . #x2208)
("not in" . #x2209)
("return" . #x27fc)
("yield" . #x27fb)
("for" . #x2200)
;; Base Types
("int" . #x2124)
("float" . #x211d)
("str" . #x1d54a)
("True" . #x1d54b)
("False" . #x1d53d)))))
#+END_SRC
2018-11-05 15:55:41 -05:00
** Debugging and Disassembly
*** Realgud
2018-10-18 10:29:46 -04:00
[[https://github.com/realgud/realgud ][Realgud ]] is a modular frontend for many debuggers
2018-10-15 18:28:02 -04:00
#+BEGIN_SRC emacs-lisp
(use-package realgud
:commands
(realgud:gdb
realgud:lldb
realgud:node-inspect
realgud:pdb
realgud:trepan3k))
#+END_SRC
2018-11-05 15:55:41 -05:00
*** RMSBolt
#+BEGIN_SRC emacs-lisp
(use-package rmsbolt
:pin melpa
2018-11-05 16:48:52 -05:00
:commands rmsbolt-mode)
2018-11-05 15:55:41 -05:00
#+END_SRC
2018-10-15 18:28:02 -04:00
** Syntax checking
2018-10-18 10:29:46 -04:00
*** Flycheck
2018-10-15 18:28:02 -04:00
Flycheck does syntax highlighting in a few languages
#+BEGIN_SRC emacs-lisp
(use-package flycheck
:hook (prog-mode . flycheck-mode))
#+END_SRC
2018-10-18 10:29:46 -04:00
*** Column 80 Highlight
Add a hotkey for highlighting column 80
and activate it in =prog-mode=
#+BEGIN_SRC emacs-lisp
(use-package fill-column-indicator
:init
(setq fci-rule-use-dashes t)
(setq fci-rule-column 80)
:general
(foltz-major-def
:keymaps 'prog-mode-map
2019-02-01 09:23:54 -05:00
"l" 'fci-mode
"f" 'toggle-truncate-lines))
2018-10-18 10:29:46 -04:00
#+END_SRC
2018-10-15 18:28:02 -04:00
** Snippets
Yasnippet adds support for custom snippets
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
2018-12-21 11:02:05 -05:00
:commands yas-minor-mode
2018-10-15 18:28:02 -04:00
:hook (prog-mode . yas-minor-mode)
:custom
(yas-snippet-dirs
2018-12-21 11:02:05 -05:00
'("~/.emacs.d/snippets"
"~/.emacs.d/elpa/yasnippet-snippets-0.6/snippets")))
;;;(use-package yasnippet-snippets)
2018-10-15 18:28:02 -04:00
#+END_SRC
** Git
2018-12-21 11:54:00 -05:00
*** magit
2018-10-15 18:28:02 -04:00
It's magic git!
2018-12-08 05:47:00 -05:00
Keybinds [[https://github.com/emacs-evil/evil-magit ][here ]]
2018-10-15 18:28:02 -04:00
#+BEGIN_SRC emacs-lisp
(use-package magit
:general
(foltz-git-def
"s" 'magit-status
"c" 'magit-commit
"d" 'magit-diff
"g" 'magit-grep)
:config
(use-package evil-magit
:after evil))
#+END_SRC
2018-12-21 11:54:00 -05:00
*** magithub
Magic GitHub facilities for magit!
#+BEGIN_SRC emacs-lisp
(use-package magithub
:after magit
:config
(magithub-feature-autoinject t)
:custom
(magithub-clone-default-directory "~/Documents/dev"))
#+END_SRC
2018-10-16 22:02:11 -04:00
** Projects
Projectile provides project-level features like
make shortcuts and file switching
#+BEGIN_SRC emacs-lisp
(use-package projectile
2019-02-01 09:17:35 -05:00
:pin melpa
2018-10-27 11:05:29 -04:00
:init
(defun foltz-projectile-neotree () "Open NeoTree in the project root"
(interactive)
(let
((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-toggle)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-find file-name))))))
2019-02-01 09:17:35 -05:00
(defun foltz-projectile-discover-projects (directory) "Add projects in dir to projectile cache"
(interactive
(list (read-directory-name "Starting directory: ")))
(let ((subdirs (directory-files directory t)))
(mapcar (lambda (dir)
(when
(and
(file-directory-p dir)
(not (member (file-name-nondirectory dir) '(".." "."))))
(let ((default-directory dir) (projectile-cached-project-root dir))
(when (projectile-project-p)
(projectile-add-known-project (projectile-project-root))))))
subdirs)))
:config
(projectile-mode 1)
(foltz-projectile-discover-projects "~/Documents/dev")
2018-10-16 22:02:11 -04:00
:general
2018-10-27 11:05:29 -04:00
(:keymaps 'projectile-command-map
"t" 'foltz-projectile-neotree)
2018-10-16 22:02:11 -04:00
(foltz-leader-def
:states 'normal
2018-10-18 10:29:46 -04:00
"p" '(:keymap projectile-command-map))
:custom
2019-02-01 09:17:35 -05:00
(projectile-completion-system 'ivy)
2018-10-18 10:29:46 -04:00
(projectile-project-search-path '("~/Documents/dev")))
2018-10-16 22:02:11 -04:00
#+END_SRC
2018-10-15 18:28:02 -04:00
** Languages
*** Fish
Beter editing of scripts for the fish shell
#+BEGIN_SRC emacs-lisp
(use-package fish-mode
:mode "\\.fish\\'")
#+END_SRC
*** Markdown
#+BEGIN_SRC emacs-lisp
(use-package markdown-mode
:mode "\\.md\\'")
#+END_SRC
*** Python
Jedi for autocompletion sources
#+BEGIN_SRC emacs-lisp
(use-package company-jedi
2019-02-06 18:47:02 -05:00
:company python-mode)
2018-10-15 18:28:02 -04:00
#+END_SRC
*** Javascript
[[https://github.com/mooz/js2-mode ][js2-mode ]] improves the default js mode. Keybindings in [[https://github.com/emacs-evil/evil-collection/blob/master/evil-collection-js2-mode.el ][this file ]].
#+BEGIN_SRC emacs-lisp
(use-package js2-mode
:mode "\\.js\\'"
:interpreter "node")
#+END_SRC
*** Web-dev
Web-mode should give everything you need for a web-dev major mode.
Company integration is done with company-web
#+BEGIN_SRC emacs-lisp
(use-package web-mode
:pin melpa
:mode ("\\.html\\'"
"\\.php\\'"
"\\.blade\\.")
:custom
(web-mode-code-indent-offset 4)
(web-mode-indent-style 4))
2019-02-06 18:47:02 -05:00
2018-10-15 18:28:02 -04:00
(use-package company-web
2019-02-06 18:47:02 -05:00
:company web-mode)
2018-10-15 18:28:02 -04:00
#+END_SRC
*** JSON
Just an enhanced json mode
#+BEGIN_SRC emacs-lisp
(use-package json-mode
:mode "\\.json\\'")
#+END_SRC
*** YAML
Enhanced yaml mode
#+BEGIN_SRC emacs-lisp
(use-package yaml-mode
:mode "\\.yaml\\'")
#+END_SRC
*** Arch PKGBUILD
For editing PKGBUILD files
#+BEGIN_SRC emacs-lisp
(use-package pkgbuild-mode
:mode ".*PKGBUILD\\'")
#+END_SRC
*** LaTeX
2018-11-05 16:58:07 -05:00
**** AUCTeX
2018-10-15 18:28:02 -04:00
AUCTeX is a major mode for editing tex,
CDLaTeX adds some minor niceities to it.
company-auctex for completion.
#+BEGIN_SRC emacs-lisp
(use-package tex
:defer t
:ensure auctex
2018-10-18 10:29:46 -04:00
:general
(foltz-major-def
:keymaps 'TeX-mode-map
"e" 'TeX-command-run-all)
2018-10-15 18:28:02 -04:00
:custom
(TeX-auto-save t))
2019-02-06 18:47:02 -05:00
2018-10-15 18:28:02 -04:00
(use-package company-auctex
:pin melpa
2019-02-06 18:47:02 -05:00
:company LaTeX-mode)
2018-10-18 10:29:46 -04:00
(use-package company-math
2019-02-06 18:47:02 -05:00
:company ((TeX-mode . company-math-symbols-latex)
(TeX-mode . company-math-symbols-unicode)
(TeX-mode . company-latex-commands)))
2018-10-15 18:28:02 -04:00
#+END_SRC
2018-11-05 16:58:07 -05:00
**** cdlatex
2018-11-05 17:27:57 -05:00
***** Environment
#+BEGIN_SRC emacs-lisp
(setq foltz-cdlatex-envs nil)
#+END_SRC
***** Commands
#+BEGIN_SRC emacs-lisp
(setq foltz-cdlatex-commands nil)
#+END_SRC
***** Math Symbols
#+BEGIN_SRC emacs-lisp
(setq foltz-cdlatex-symbols
'((?I ("\\infty"))))
#+END_SRC
***** cdlatex
2018-11-05 16:58:07 -05:00
cdlatex adds better TeX-specific template expansions and other niceties.
#+BEGIN_SRC emacs-lisp
(use-package cdlatex
2018-11-05 17:27:57 -05:00
:hook (LaTeX-mode . cdlatex-mode)
:custom
(cdlatex-env-alist foltz-cdlatex-envs)
(cdlatex-command-alist foltz-cdlatex-commands)
(cdlatex-math-symbol-alist foltz-cdlatex-symbols))
2018-11-05 16:58:07 -05:00
#+END_SRC
2018-12-01 14:44:54 -05:00
*** Rust
#+BEGIN_SRC emacs-lisp
(use-package rust-mode
2018-12-21 11:02:05 -05:00
:mode "\\.rs\\'"
:general
(foltz-major-def
:keymaps 'rust-mode-map
"TAB" 'rust-format-buffer))
(use-package flycheck-rust
:pin melpa
:hook (rust-mode . flycheck-rust-setup))
(use-package racer
:hook ((rust-mode . racer-mode)
(rust-mode . eldoc-mode))
:custom
(racer-cmd "~/.cargo/bin/racer")
(racer-rust-src-path "~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src"))
(use-package cargo
:hook (rust-mode . cargo-minor-mode)
:general
(foltz-major-def
:keymaps 'rust-mode-map
"b" 'cargo-process-build
"r" 'cargo-process-run
"t" 'cargo-process-test))
2018-12-01 14:44:54 -05:00
#+END_SRC
2018-10-15 18:28:02 -04:00
*** C/C++
2018-11-05 16:48:52 -05:00
**** Irony
2018-10-15 18:28:02 -04:00
Irony handles enhanced C/C++ operations powered by clang
company-irony for company integration
#+BEGIN_SRC emacs-lisp
(use-package irony
2019-02-01 09:17:35 -05:00
:pin melpa
2018-10-15 18:28:02 -04:00
:after counsel
:hook ((c++-mode . irony-mode)
(c-mode . irony-mode)
(irony-mode . irony-cdb-autosetup-compile-options)))
(use-package company-irony
2019-02-06 18:47:02 -05:00
:company irony-mode)
2018-10-15 18:28:02 -04:00
2019-02-05 23:47:45 -05:00
(use-package company-irony-c-headers
2019-02-06 18:47:02 -05:00
:company irony-mode)
2019-02-05 23:47:45 -05:00
2018-10-15 18:28:02 -04:00
(use-package flycheck-irony
:hook (irony-mode . flycheck-irony-setup))
#+END_SRC
2018-11-05 16:48:52 -05:00
**** Hotkeys
#+BEGIN_SRC emacs-lisp
(foltz-major-def
:keymaps '(c++-mode-map c-mode-map)
"r" 'rmsbolt-mode
"c" 'rmsbolt-compile)
#+END_SRC