Moving to Doom Emacs!

This commit is contained in:
Derek Taylor
2019-12-16 20:21:19 -06:00
parent d9f2f456f1
commit d4b4c33550
683 changed files with 51877 additions and 100 deletions

View File

@@ -0,0 +1,412 @@
;;; config/default/+emacs-bindings.el -*- lexical-binding: t; -*-
;; Sensible deafult key bindings for non-evil users
(setq doom-leader-alt-key "C-c"
doom-localleader-alt-key "C-c l")
;; persp-mode and projectile in different prefixes
(setq persp-keymap-prefix (kbd "C-c w"))
(after! projectile
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
;;
;;; Autoloads
(autoload 'org-capture-goto-target "org-capture" nil t)
;;
;;; Leader keys
(map! :leader
:desc "Evaluate line/region" "e" #'+eval/line-or-region
(:prefix ("l" . "<localleader>")) ; bound locally
(:prefix ("!" . "checkers")) ; bound by flycheck
;;; <leader> f --- file
(:prefix-map ("f" . "file")
:desc "Open project editorconfig" "." #'editorconfig-find-current-editorconfig
:desc "Find other file" "a" #'projectile-find-other-file
:desc "Browse private config" "c" #'doom/open-private-config
:desc "Find file in private config" "C" #'doom/find-file-in-private-config
:desc "Find directory" "d" #'dired
:desc "Find file in emacs.d" "e" #'+default/find-in-emacsd
:desc "Browse emacs.d" "E" #'+default/browse-emacsd
:desc "Find file from here" "f" (if (fboundp 'counsel-file-jump) #'counsel-file-jump #'find-file)
:desc "Find file in other project" "F" #'doom/browse-in-other-project
:desc "Delete this file" "K" #'doom/delete-this-file
:desc "Move this file" "m" #'doom/move-this-file
:desc "Find file in project" "p" #'projectile-find-file
:desc "Find file in other project" "P" #'doom/find-file-in-other-project
:desc "Recent files" "r" #'recentf-open-files
:desc "Recent project files" "R" #'projectile-recentf
:desc "Sudo this file" "s" #'doom/sudo-this-file
:desc "Sudo find file" "S" #'doom/sudo-find-file
:desc "Yank filename" "y" #'+default/yank-buffer-filename
:desc "Open scratch buffer" "x" #'doom/open-scratch-buffer
:desc "Open project scratch buffer" "X" #'doom/switch-to-scratch-buffer)
;;; <leader> g --- lookup
(:when (featurep! :tools lookup)
(:prefix-map ("g" . "lookup")
"k" #'+lookup/documentation
"d" #'+lookup/definition
"D" #'+lookup/references
"f" #'+lookup/file
"o" #'+lookup/online-select
"i" #'+lookup/in-docsets
"I" #'+lookup/in-all-docsets))
;;; <leader> o --- org
"o" nil ; we need to unbind it first as Org claims this
(:prefix-map ("o". "org")
:desc "Do what I mean" "o" #'+org/dwim-at-point
:desc "Display inline images" "i" #'org-display-inline-images
:desc "Search notes for symbol" "." #'+default/search-notes-for-symbol-at-point
(:prefix ("a" . "org agenda")
:desc "Agenda" "a" #'org-agenda
:desc "Todo list" "t" #'org-todo-list
:desc "Tags view" "m" #'org-tags-view
:desc "View search" "v" #'org-search-view)
:desc "Browse notes" "f" #'+default/browse-notes
:desc "Search org-directory" "s" #'+default/org-notes-search
:desc "Switch org buffers" "b" #'org-switchb
:desc "Capture" "c" #'org-capture
:desc "Goto capture" "C" #'org-capture-goto-target
:desc "Link store" "l" #'org-store-link
:desc "Sync org caldav" "S" #'org-caldav-sync)
;;; <leader> p --- project
(:prefix ("p" . "project")
:desc "Find file in other project" "F" #'doom/find-file-in-other-project
:desc "Search project" "s" #'+default/search-project
:desc "List project tasks" "t" #'magit-todos-list
:desc "Open project scratch buffer" "x" #'doom/open-project-scratch-buffer
:desc "Switch to project scratch buffer" "X" #'doom/switch-to-project-scratch-buffer
;; later expanded by projectile
(:prefix ("4" . "in other window"))
(:prefix ("5" . "in other frame")))
;;; <leader> q --- quit/restart
(:prefix-map ("q" . "quit/restart")
:desc "Quit Emacs" "q" #'kill-emacs
:desc "Save and quit Emacs" "Q" #'save-buffers-kill-terminal
(:when (featurep! :ui workspaces)
:desc "Quit Emacs & forget session" "X" #'+workspace/kill-session-and-quit)
:desc "Restart & restore Emacs" "r" #'doom/restart-and-restore
:desc "Restart Emacs" "R" #'doom/restart)
;;; <leader> & --- snippets
(:prefix-map ("&" . "snippets")
:desc "New snippet" "n" #'yas-new-snippet
:desc "Insert snippet" "i" #'yas-insert-snippet
:desc "Find global snippet" "/" #'yas-visit-snippet-file
:desc "Reload snippets" "r" #'yas-reload-all
:desc "Create Temp Template" "c" #'aya-create
:desc "Use Temp Template" "e" #'aya-expand)
(:prefix-map ("t" . "terminal")
(:when (featurep! :term term)
:desc "Toggle term popup" "t" #'+term/toggle
:desc "Open term here" "T" #'+term/here)
(:when (featurep! :term vterm)
:desc "Toggle vterm popup" "t" #'+vterm/toggle
:desc "Open vterm here" "T" #'+vterm/here)
(:when (featurep! :term eshell)
:desc "Toggle eshell popup" "t" #'+eshell/toggle
:desc "Open eshell here" "T" #'+eshell/here))
;;; <leader> v --- versioning
(:prefix-map ("v" . "versioning")
:desc "Git revert file" "R" #'vc-revert
:desc "Kill link to remote" "y" #'+vc/browse-at-remote-kill-file-or-region
:desc "Kill link to homepage" "Y" #'+vc/browse-at-remote-kill-homepage
(:when (featurep! :ui vc-gutter)
:desc "Git revert hunk" "r" #'git-gutter:revert-hunk
:desc "Git stage hunk" "s" #'git-gutter:stage-hunk
:desc "Git time machine" "t" #'git-timemachine-toggle
:desc "Jump to next hunk" "n" #'git-gutter:next-hunk
:desc "Jump to previous hunk" "p" #'git-gutter:previous-hunk)
(:when (featurep! :tools magit)
:desc "Magit dispatch" "/" #'magit-dispatch
:desc "Forge dispatch" "'" #'forge-dispatch
:desc "Magit status" "g" #'magit-status
:desc "Magit file delete" "x" #'magit-file-delete
:desc "Magit blame" "B" #'magit-blame-addition
:desc "Magit clone" "C" #'magit-clone
:desc "Magit fetch" "F" #'magit-fetch
:desc "Magit buffer log" "L" #'magit-log
:desc "Git stage file" "S" #'magit-stage-file
:desc "Git unstage file" "U" #'magit-unstage-file
(:prefix ("f" . "find")
:desc "Find file" "f" #'magit-find-file
:desc "Find gitconfig file" "g" #'magit-find-git-config-file
:desc "Find commit" "c" #'magit-show-commit
:desc "Find issue" "i" #'forge-visit-issue
:desc "Find pull request" "p" #'forge-visit-pullreq)
(:prefix ("o" . "open in browser")
:desc "Browse file or region" "." #'+vc/browse-at-remote-file-or-region
:desc "Browse homepage" "h" #'+vc/browse-at-remote-homepage
:desc "Browse remote" "r" #'forge-browse-remote
:desc "Browse commit" "c" #'forge-browse-commit
:desc "Browse an issue" "i" #'forge-browse-issue
:desc "Browse a pull request" "p" #'forge-browse-pullreq
:desc "Browse issues" "I" #'forge-browse-issues
:desc "Browse pull requests" "P" #'forge-browse-pullreqs)
(:prefix ("l" . "list")
(:when (featurep! :tools gist)
:desc "List gists" "g" #'+gist:list)
:desc "List repositories" "r" #'magit-list-repositories
:desc "List submodules" "s" #'magit-list-submodules
:desc "List issues" "i" #'forge-list-issues
:desc "List pull requests" "p" #'forge-list-pullreqs
:desc "List notifications" "n" #'forge-list-notifications)
(:prefix ("c" . "create")
:desc "Initialize repo" "r" #'magit-init
:desc "Clone repo" "R" #'magit-clone
:desc "Commit" "c" #'magit-commit-create
:desc "Fixup" "f" #'magit-commit-fixup
:desc "Issue" "i" #'forge-create-issue
:desc "Pull request" "p" #'forge-create-pullreq)))
;;; <leader> w --- workspaces/windows
(:prefix-map ("w" . "workspaces/windows")
:desc "Autosave session" "a" #'doom/quicksave-session
:desc "Display workspaces" "d" #'+workspace/display
:desc "Rename workspace" "r" #'+workspace/rename
:desc "Create workspace" "c" #'+workspace/new
:desc "Delete workspace" "k" #'+workspace/delete
:desc "Save session" "s" #'doom/save-session
:desc "Save workspace" "S" #'+workspace/save
:desc "Load session" "l" #'doom/load-session
:desc "Load last autosaved session" "L" #'doom/quickload-session
:desc "Switch to other workspace" "o" #'+workspace/other
:desc "Undo window config" "u" #'winner-undo
:desc "Redo window config" "U" #'winner-redo
:desc "Switch to left workspace" "p" #'+workspace/switch-left
:desc "Switch to right workspace" "n" #'+workspace/switch-right
:desc "Switch to" "w" #'+workspace/switch-to
:desc "Switch to workspace 1" "1" #'+workspace/switch-to-0
:desc "Switch to workspace 2" "2" #'+workspace/switch-to-1
:desc "Switch to workspace 3" "3" #'+workspace/switch-to-2
:desc "Switch to workspace 4" "4" #'+workspace/switch-to-3
:desc "Switch to workspace 5" "5" #'+workspace/switch-to-4
:desc "Switch to workspace 6" "6" #'+workspace/switch-to-5
:desc "Switch to workspace 7" "7" #'+workspace/switch-to-6
:desc "Switch to workspace 8" "8" #'+workspace/switch-to-7
:desc "Switch to workspace 9" "9" #'+workspace/switch-to-8
:desc "Switch to last workspace" "0" #'+workspace/switch-to-final)
;;; <leader> m --- multiple cursors
(:when (featurep! :editor multiple-cursors)
(:prefix-map ("m" . "multiple cursors")
:desc "Edit lines" "l" #'mc/edit-lines
:desc "Mark next" "n" #'mc/mark-next-like-this
:desc "Unmark next" "N" #'mc/unmark-next-like-this
:desc "Mark previous" "p" #'mc/mark-previous-like-this
:desc "Unmark previous" "P" #'mc/unmark-previous-like-this
:desc "Mark all" "t" #'mc/mark-all-like-this
:desc "Mark all DWIM" "m" #'mc/mark-all-like-this-dwim
:desc "Edit line endings" "e" #'mc/edit-ends-of-lines
:desc "Edit line starts" "a" #'mc/edit-beginnings-of-lines
:desc "Mark tag" "s" #'mc/mark-sgml-tag-pair
:desc "Mark in defun" "d" #'mc/mark-all-like-this-in-defun
:desc "Add cursor w/mouse" "<mouse-1>" #'mc/add-cursor-on-click))
;; APPs
;;; <leader> M --- mu4e
(:when (featurep! :email mu4e)
(:prefix-map ("M" . "mu4e")
:desc "Open email app" "M" #'=mu4e
:desc "Compose email" "c" #'+mu4e/compose))
;;; <leader> I --- IRC
(:when (featurep! :app irc)
(:prefix-map ("I" . "irc")
:desc "Open irc app" "I" #'=irc
:desc "Next unread buffer" "a" #'tracking-next-buffer
:desc "Quit irc" "q" #'+irc/quit
:desc "Reconnect all" "r" #'circe-reconnect-all
:desc "Send message" "s" #'+irc/send-message
(:when (featurep! :completion ivy)
:desc "Jump to channel" "j" #'irc/ivy-jump-to-channel)))
;;; <leader> T --- twitter
(:when (featurep! :app twitter)
(:prefix-map ("T" . "twitter")
:desc "Open twitter app" "T" #'=twitter
:desc "Quit twitter" "q" #'+twitter/quit
:desc "Rerender twits" "r" #'+twitter/rerender-all
:desc "Ace link" "l" #'+twitter/ace-link)))
;;
;;; Global & plugin keybinds
(map! "C-'" #'imenu
;;; Text scaling
[C-mouse-4] #'text-scale-increase
[C-mouse-5] #'text-scale-decrease
[C-down-mouse-2] (λ! (text-scale-set 0))
"M-+" #'doom/reset-font-size
"M-=" #'doom/increase-font-size
"M--" #'doom/decrease-font-size
;;; newlines
[remap newline] #'newline-and-indent
"C-j" #'+default/newline
;;; search
(:when (featurep! :completion ivy)
"C-S-s" #'swiper
"C-S-r" #'ivy-resume)
(:when (featurep! :completion helm)
"C-S-s" #'swiper-helm
"C-S-r" #'helm-resume)
;;; objed
(:when (featurep! :editor objed +manual)
"M-SPC" #'objed-activate)
;;; buffer management
"C-x b" #'persp-switch-to-buffer
(:when (featurep! :completion ivy)
"C-x 4 b" #'+ivy/switch-workspace-buffer-other-window)
"C-x C-b" #'ibuffer-list-buffers
"C-x B" #'switch-to-buffer
"C-x 4 B" #'switch-to-buffer-other-window
"C-x K" #'doom/kill-this-buffer-in-all-windows
;;; company-mode
"C-;" #'+company/complete
(:after company
:map company-active-map
"C-o" #'company-search-kill-others
"C-n" #'company-select-next
"C-p" #'company-select-previous
"C-h" #'company-quickhelp-manual-begin
"C-S-h" #'company-show-doc-buffer
"C-s" #'company-search-candidates
"M-s" #'company-filter-candidates
"<C-tab>" #'company-complete-common-or-cycle
[tab] #'company-complete-common-or-cycle
[backtab] #'company-select-previous
"C-RET" #'counsel-company
:map company-search-map
"C-n" #'company-search-repeat-forward
"C-p" #'company-search-repeat-backward
"C-s" (λ! (company-search-abort) (company-filter-candidates)))
;;; ein notebooks
(:after ein:notebook-multilang
:map ein:notebook-multilang-mode-map
"C-c h" #'+ein/hydra/body)
;;; expand-region
"C-=" #'er/expand-region
"C--" #'er/contract-region
;;; flycheck
(:after flycheck
:map flycheck-error-list-mode-map
"C-n" #'flycheck-error-list-next-error
"C-p" #'flycheck-error-list-previous-error
"RET" #'flycheck-error-list-goto-error)
;;; help and info
(:after help-mode
:map help-mode-map
"o" #'ace-link-help
">" #'help-go-forward
"<" #'help-go-back
"n" #'forward-button
"p" #'backward-button)
(:after helpful
:map helpful-mode-map
"o" #'ace-link-help)
(:after apropos
:map apropos-mode-map
"o" #'ace-link-help
"n" #'forward-button
"p" #'backward-button)
(:after info
:map Info-mode-map
"o" #'ace-link-info)
;;; ivy & counsel
(:when (featurep! :completion ivy)
(:after ivy
:map ivy-minibuffer-map
"TAB" #'ivy-alt-done
"C-g" #'keyboard-escape-quit)
(:after counsel
:map counsel-ag-map
"C-SPC" #'ivy-call-and-recenter ; preview
"M-RET" #'+ivy/git-grep-other-window-action)
"C-M-y" #'counsel-yank-pop)
;;; neotree
(:when (featurep! :ui neotree)
"<f9>" #'+neotree/open
"<C-f9>" #'+neotree/find-this-file
(:after neotree
:map neotree-mode-map
"q" #'neotree-hide
"RET" #'neotree-enter
"SPC" #'neotree-quick-look
"v" #'neotree-enter-vertical-split
"s" #'neotree-enter-horizontal-split
"c" #'neotree-create-node
"D" #'neotree-delete-node
"g" #'neotree-refresh
"r" #'neotree-rename-node
"R" #'neotree-refresh
"h" #'+neotree/collapse-or-up
"l" #'+neotree/expand-or-open
"n" #'neotree-next-line
"p" #'neotree-previous-line
"N" #'neotree-select-next-sibling-node
"P" #'neotree-select-previous-sibling-node))
;;; popups
(:when (featurep! :ui popup)
"C-x p" #'+popup/other
"C-`" #'+popup/toggle
"C-~" #'+popup/raise)
;;; repl
"C-c C-z" #'+eval/open-repl-other-window
"C-c C-S-z" #'+eval/open-repl-same-window
;;; smartparens
(:after smartparens
:map smartparens-mode-map
"C-M-a" #'sp-beginning-of-sexp
"C-M-e" #'sp-end-of-sexp
"C-M-f" #'sp-forward-sexp
"C-M-b" #'sp-backward-sexp
"C-M-d" #'sp-splice-sexp
"C-M-k" #'sp-kill-sexp
"C-M-t" #'sp-transpose-sexp
"C-<right>" #'sp-forward-slurp-sexp
"M-<right>" #'sp-forward-barf-sexp
"C-<left>" #'sp-backward-slurp-sexp
"M-<left>" #'sp-backward-barf-sexp)
;;; treemacs
(:when (featurep! :ui treemacs)
"<f9>" #'+treemacs/toggle
"<C-f9>" #'+treemacs/find-file)
;;; yasnippet
(:after yasnippet
:map yas-keymap ; keymap while editing an inserted snippet
"C-e" #'+snippets/goto-end-of-field
"C-a" #'+snippets/goto-start-of-field
"<S-tab>" #'yas-prev-field
"<M-backspace>" #'+snippets/delete-to-start-of-field
[backspace] #'+snippets/delete-backward-char
[delete] #'+snippets/delete-forward-char-or-field))

View File

@@ -0,0 +1,26 @@
;;; config/default/+emacs.el -*- lexical-binding: t; -*-
(require 'projectile) ; we need its keybinds immediately
;;
;;; Reasonable defaults
(setq shift-select-mode t)
(delete-selection-mode +1)
(use-package! expand-region
:commands (er/contract-region er/mark-symbol er/mark-word)
:config
(defadvice! doom--quit-expand-region-a ()
"Properly abort an expand-region region."
:before '(evil-escape doom/escape)
(when (memq last-command '(er/expand-region er/contract-region))
(er/contract-region 0))))
;;
;;; Keybinds
(when (featurep! +bindings)
(load! "+emacs-bindings"))

View File

@@ -0,0 +1,624 @@
;;; config/default/+bindings.el -*- lexical-binding: t; -*-
(when (featurep! :editor evil +everywhere)
;; Have C-u behave similarly to `doom/backward-to-bol-or-indent'.
;; NOTE SPC u replaces C-u as the universal argument.
(map! :i "C-u" #'doom/backward-kill-to-bol-and-indent
:i "C-w" #'backward-kill-word
;; Vimmish ex motion keys
:i "C-b" #'backward-word
:i "C-f" #'forward-word)
;; Minibuffer
(define-key! evil-ex-completion-map
"C-a" #'move-beginning-of-line
"C-b" #'backward-word
"C-s" (if (featurep! :completion ivy)
#'counsel-minibuffer-history
#'helm-minibuffer-history))
(define-key! :keymaps +default-minibuffer-maps
[escape] #'abort-recursive-edit
"C-a" #'move-beginning-of-line
"C-b" #'backward-word
"C-f" #'forward-word
"C-r" #'evil-paste-from-register
"C-u" #'doom/backward-kill-to-bol-and-indent
"C-v" #'yank
"C-w" #'backward-kill-word
"C-z" (λ! (ignore-errors (call-interactively #'undo)))
;; Scrolling lines
"C-j" #'next-line
"C-k" #'previous-line
"C-S-j" #'scroll-up-command
"C-S-k" #'scroll-down-command)
(define-key! read-expression-map
"C-j" #'next-line-or-history-element
"C-k" #'previous-line-or-history-element))
;;
;;; Global keybindings
;; Smart tab, these will only work in GUI Emacs
(map! :i [tab] (general-predicate-dispatch nil ; fall back to nearest keymap
(and (featurep! :editor snippets)
(bound-and-true-p yas-minor-mode)
(yas-maybe-expand-abbrev-key-filter 'yas-expand))
#'yas-expand
(and (featurep! :completion company +tng)
(+company-has-completion-p))
#'+company/complete)
:n [tab] (general-predicate-dispatch nil
(and (featurep! :editor fold)
(save-excursion (end-of-line) (invisible-p (point))))
#'+fold/toggle
(fboundp 'evil-jump-item)
#'evil-jump-item)
:v [tab] (general-predicate-dispatch nil
(and (bound-and-true-p yas-minor-mode)
(or (eq evil-visual-selection 'line)
(not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\))))))
#'yas-insert-snippet
(fboundp 'evil-jump-item)
#'evil-jump-item)
;; Smarter newlines
:i [remap newline] #'newline-and-indent ; auto-indent on newline
:i "C-j" #'+default/newline ; default behavior
(:after help :map help-mode-map
:n "o" #'ace-link-help)
(:after helpful :map helpful-mode-map
:n "o" #'ace-link-help)
(:after info :map Info-mode-map
:n "o" #'ace-link-info)
(:after apropos :map apropos-mode-map
:n "o" #'ace-link-help
:n "TAB" #'forward-button
:n [tab] #'forward-button
:n [backtab] #'backward-button)
(:after view :map view-mode-map
[escape] #'View-quit-all)
(:after man :map Man-mode-map
:n "q" #'kill-current-buffer)
:m "gs" #'+evil/easymotion ; lazy-load `evil-easymotion'
(:after org
:map org-mode-map
:m "gsh" #'+org/goto-visible)
(:when (featurep! :editor multiple-cursors)
:prefix "gz"
:nv "d" #'evil-mc-make-and-goto-next-match
:nv "D" #'evil-mc-make-and-goto-prev-match
:nv "j" #'evil-mc-make-cursor-move-next-line
:nv "k" #'evil-mc-make-cursor-move-prev-line
:nv "m" #'evil-mc-make-all-cursors
:nv "n" #'evil-mc-make-and-goto-next-cursor
:nv "N" #'evil-mc-make-and-goto-last-cursor
:nv "p" #'evil-mc-make-and-goto-prev-cursor
:nv "P" #'evil-mc-make-and-goto-first-cursor
:nv "q" #'evil-mc-undo-all-cursors
:nv "t" #'+multiple-cursors/evil-mc-toggle-cursors
:nv "u" #'evil-mc-undo-last-added-cursor
:nv "z" #'+multiple-cursors/evil-mc-make-cursor-here
:v "I" #'evil-mc-make-cursor-in-visual-selection-beg
:v "A" #'evil-mc-make-cursor-in-visual-selection-end)
;; misc
:n "C-S-f" #'toggle-frame-fullscreen
:n "C-+" #'doom/reset-font-size
;; Buffer-local font resizing
:n "C-=" #'text-scale-increase
:n "C--" #'text-scale-decrease
;; Frame-local font resizing
:n "M-C-=" #'doom/increase-font-size
:n "M-C--" #'doom/decrease-font-size)
;;
;;; Module keybinds
;;; :completion
(map! (:when (featurep! :completion company)
:i "C-@" #'+company/complete
:i "C-SPC" #'+company/complete
(:after company
(:map company-active-map
"C-w" nil ; don't interfere with `evil-delete-backward-word'
"C-n" #'company-select-next
"C-p" #'company-select-previous
"C-j" #'company-select-next
"C-k" #'company-select-previous
"C-h" #'company-show-doc-buffer
"C-u" #'company-previous-page
"C-d" #'company-next-page
"C-s" #'company-filter-candidates
"C-S-s" (cond ((featurep! :completion helm) #'helm-company)
((featurep! :completion ivy) #'counsel-company))
"C-SPC" #'company-complete-common
"TAB" #'company-complete-common-or-cycle
[tab] #'company-complete-common-or-cycle
[backtab] #'company-select-previous
[f1] nil)
(:map company-search-map ; applies to `company-filter-map' too
"C-n" #'company-select-next-or-abort
"C-p" #'company-select-previous-or-abort
"C-j" #'company-select-next-or-abort
"C-k" #'company-select-previous-or-abort
"C-s" (λ! (company-search-abort) (company-filter-candidates))
"ESC" #'company-search-abort))
;; TAB auto-completion in term buffers
(:after comint :map comint-mode-map
"TAB" #'company-complete
[tab] #'company-complete))
(:when (featurep! :completion ivy)
(:after ivy
:map ivy-minibuffer-map
"C-SPC" #'ivy-call-and-recenter ; preview file
"C-l" #'ivy-alt-done
"C-v" #'yank)
(:after counsel
:map counsel-ag-map
"C-SPC" #'ivy-call-and-recenter ; preview
"C-l" #'ivy-done
[C-return] #'+ivy/git-grep-other-window-action))
(:when (featurep! :completion helm)
(:after helm :map helm-map
[left] #'left-char
[right] #'right-char
"C-S-f" #'helm-previous-page
"C-S-n" #'helm-next-source
"C-S-p" #'helm-previous-source
"C-S-j" #'helm-next-source
"C-S-k" #'helm-previous-source
"C-j" #'helm-next-line
"C-k" #'helm-previous-line
"C-u" #'helm-delete-minibuffer-contents
"C-s" #'helm-minibuffer-history
;; Swap TAB and C-z
"TAB" #'helm-execute-persistent-action
[tab] #'helm-execute-persistent-action
"C-z" #'helm-select-action)
(:after helm-ag :map helm-ag-map
"C--" #'+helm-do-ag-decrease-context
"C-=" #'+helm-do-ag-increase-context
[left] nil
[right] nil)
(:after helm-files :map (helm-find-files-map helm-read-file-map)
[C-return] #'helm-ff-run-switch-other-window
"C-w" #'helm-find-files-up-one-level)
(:after helm-locate :map helm-generic-files-map
[C-return] #'helm-ff-run-switch-other-window)
(:after helm-buffers :map helm-buffer-map
[C-return] #'helm-buffer-switch-other-window)
(:after helm-occur :map helm-occur-map
[C-return] #'helm-occur-run-goto-line-ow)
(:after helm-grep :map helm-grep-map
[C-return] #'helm-grep-run-other-window-action)))
;;; :ui
(map! (:when (featurep! :ui popup)
:n "C-`" #'+popup/toggle
:n "C-~" #'+popup/raise
:g "C-x p" #'+popup/other)
(:when (featurep! :ui workspaces)
:n "C-t" #'+workspace/new
:n "C-S-t" #'+workspace/display
:g "M-1" #'+workspace/switch-to-0
:g "M-2" #'+workspace/switch-to-1
:g "M-3" #'+workspace/switch-to-2
:g "M-4" #'+workspace/switch-to-3
:g "M-5" #'+workspace/switch-to-4
:g "M-6" #'+workspace/switch-to-5
:g "M-7" #'+workspace/switch-to-6
:g "M-8" #'+workspace/switch-to-7
:g "M-9" #'+workspace/switch-to-8
:g "M-0" #'+workspace/switch-to-final
(:when IS-MAC
:g "s-t" #'+workspace/new
:g "s-T" #'+workspace/display
:n "s-1" #'+workspace/switch-to-0
:n "s-2" #'+workspace/switch-to-1
:n "s-3" #'+workspace/switch-to-2
:n "s-4" #'+workspace/switch-to-3
:n "s-5" #'+workspace/switch-to-4
:n "s-6" #'+workspace/switch-to-5
:n "s-7" #'+workspace/switch-to-6
:n "s-8" #'+workspace/switch-to-7
:n "s-9" #'+workspace/switch-to-8
:n "s-0" #'+workspace/switch-to-final)))
;;; :editor
(map! (:when (featurep! :editor format)
:n "gQ" #'+format:region)
(:when (featurep! :editor rotate-text)
:n "!" #'rotate-text)
(:when (featurep! :editor multiple-cursors)
;; evil-multiedit
:v "R" #'evil-multiedit-match-all
:n "M-d" #'evil-multiedit-match-symbol-and-next
:n "M-D" #'evil-multiedit-match-symbol-and-prev
:v "M-d" #'evil-multiedit-match-and-next
:v "M-D" #'evil-multiedit-match-and-prev
:nv "C-M-d" #'evil-multiedit-restore
(:after evil-multiedit
(:map evil-multiedit-state-map
"M-d" #'evil-multiedit-match-and-next
"M-D" #'evil-multiedit-match-and-prev
"RET" #'evil-multiedit-toggle-or-restrict-region
[return] #'evil-multiedit-toggle-or-restrict-region)))
(:when (featurep! :editor snippets)
;; auto-yasnippet
:i [C-tab] #'aya-expand
:nv [C-tab] #'aya-create))
;;; :tools
(when (featurep! :tools eval)
(map! "M-r" #'+eval/buffer))
;;
;;; <leader>
(map! :leader
:desc "Eval expression" ";" #'pp-eval-expression
:desc "M-x" ":" #'execute-extended-command
:desc "Pop up scratch buffer" "x" #'doom/open-scratch-buffer
:desc "Org Capture" "X" #'org-capture
;; C-u is used by evil
:desc "Universal argument" "u" #'universal-argument
:desc "window" "w" evil-window-map
:desc "help" "h" help-map
(:when (featurep! :ui popup)
:desc "Toggle last popup" "~" #'+popup/toggle)
:desc "Find file" "." #'find-file
:desc "Switch buffer" "," #'switch-to-buffer
(:when (featurep! :ui workspaces)
:desc "Switch workspace buffer" "," #'persp-switch-to-buffer
:desc "Switch buffer" "<" #'switch-to-buffer)
:desc "Switch to last buffer" "`" #'evil-switch-to-windows-last-buffer
:desc "Resume last search" "'"
(cond ((featurep! :completion ivy) #'ivy-resume)
((featurep! :completion helm) #'helm-resume))
:desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point
:desc "Find file in project" "SPC" #'projectile-find-file
:desc "Jump to bookmark" "RET" #'bookmark-jump
;;; <leader> TAB --- workspace
(:when (featurep! :ui workspaces)
(:prefix-map ("TAB" . "workspace")
:desc "Display tab bar" "TAB" #'+workspace/display
:desc "Switch workspace" "." #'+workspace/switch-to
:desc "Switch to last workspace" "`" #'+workspace/other
:desc "New workspace" "n" #'+workspace/new
:desc "Load workspace from file" "l" #'+workspace/load
:desc "Save workspace to file" "s" #'+workspace/save
:desc "Delete session" "x" #'+workspace/kill-session
:desc "Delete this workspace" "d" #'+workspace/delete
:desc "Rename workspace" "r" #'+workspace/rename
:desc "Restore last session" "R" #'+workspace/restore-last-session
:desc "Next workspace" "]" #'+workspace/switch-right
:desc "Previous workspace" "[" #'+workspace/switch-left
:desc "Switch to 1st workspace" "1" #'+workspace/switch-to-0
:desc "Switch to 2nd workspace" "2" #'+workspace/switch-to-1
:desc "Switch to 3rd workspace" "3" #'+workspace/switch-to-2
:desc "Switch to 4th workspace" "4" #'+workspace/switch-to-3
:desc "Switch to 5th workspace" "5" #'+workspace/switch-to-4
:desc "Switch to 6th workspace" "6" #'+workspace/switch-to-5
:desc "Switch to 7th workspace" "7" #'+workspace/switch-to-6
:desc "Switch to 8th workspace" "8" #'+workspace/switch-to-7
:desc "Switch to 9th workspace" "9" #'+workspace/switch-to-8
:desc "Switch to final workspace" "0" #'+workspace/switch-to-final))
;;; <leader> b --- buffer
(:prefix-map ("b" . "buffer")
:desc "Toggle narrowing" "-" #'doom/toggle-narrow-buffer
:desc "Previous buffer" "[" #'previous-buffer
:desc "Next buffer" "]" #'next-buffer
(:when (featurep! :ui workspaces)
:desc "Switch workspace buffer" "b" #'persp-switch-to-buffer
:desc "Switch buffer" "B" #'switch-to-buffer)
(:unless (featurep! :ui workspaces)
:desc "Switch buffer" "b" #'switch-to-buffer)
:desc "Kill buffer" "d" #'kill-current-buffer
:desc "ibuffer" "i" #'ibuffer
:desc "Kill buffer" "k" #'kill-current-buffer
:desc "Kill all buffers" "K" #'doom/kill-all-buffers
:desc "Switch to last buffer" "l" #'evil-switch-to-windows-last-buffer
:desc "Next buffer" "n" #'next-buffer
:desc "New empty buffer" "N" #'evil-buffer-new
:desc "Kill other buffers" "O" #'doom/kill-other-buffers
:desc "Previous buffer" "p" #'previous-buffer
:desc "Revert buffer" "r" #'revert-buffer
:desc "Save buffer" "s" #'basic-save-buffer
:desc "Save all buffers" "S" #'evil-write-all
:desc "Pop up scratch buffer" "x" #'doom/open-scratch-buffer
:desc "Switch to scratch buffer" "X" #'doom/switch-to-scratch-buffer
:desc "Bury buffer" "z" #'bury-buffer
:desc "Kill buried buffers" "Z" #'doom/kill-buried-buffers)
;;; <leader> c --- code
(:prefix-map ("c" . "code")
:desc "Compile" "c" #'compile
:desc "Recompile" "C" #'recompile
:desc "Jump to definition" "d" #'+lookup/definition
:desc "Jump to references" "D" #'+lookup/references
:desc "Evaluate buffer/region" "e" #'+eval/buffer-or-region
:desc "Evaluate & replace region" "E" #'+eval:replace-region
:desc "Format buffer/region" "f" #'+format/region-or-buffer
:desc "LSP Format buffer/region" "F" #'+default/lsp-format-region-or-buffer
:desc "LSP Organize imports" "i" #'lsp-organize-imports
:desc "Jump to documentation" "k" #'+lookup/documentation
:desc "LSP Rename" "r" #'lsp-rename
:desc "Send to repl" "s" #'+eval/send-region-to-repl
:desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace
:desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines
:desc "List errors" "x" #'flymake-show-diagnostics-buffer
(:when (featurep! :tools flycheck)
:desc "List errors" "x" #'flycheck-list-errors))
;;; <leader> f --- file
(:prefix-map ("f" . "file")
:desc "Open project editorconfig" "c" #'editorconfig-find-current-editorconfig
:desc "Copy this file" "C" #'doom/copy-this-file
:desc "Find directory" "d" #'dired
:desc "Delete this file" "D" #'doom/delete-this-file
:desc "Find file in emacs.d" "e" #'+default/find-in-emacsd
:desc "Browse emacs.d" "E" #'+default/browse-emacsd
:desc "Find file" "f" #'find-file
:desc "Find file from here" "F" #'+default/find-file-under-here
:desc "Locate file" "l" #'locate
:desc "Find file in private config" "p" #'doom/find-file-in-private-config
:desc "Browse private config" "P" #'doom/open-private-config
:desc "Recent files" "r" #'recentf-open-files
:desc "Rename/move file" "R" #'doom/move-this-file
:desc "Save file" "s" #'save-buffer
:desc "Save file as..." "S" #'write-file
:desc "Sudo find file" "u" #'doom/sudo-find-file
:desc "Sudo this file" "U" #'doom/sudo-this-file
:desc "Yank filename" "y" #'+default/yank-buffer-filename)
;;; <leader> g --- git
(:prefix-map ("g" . "git")
:desc "Git revert file" "R" #'vc-revert
:desc "Copy link to remote" "y" #'+vc/browse-at-remote-kill-file-or-region
:desc "Copy link to homepage" "Y" #'+vc/browse-at-remote-kill-homepage
(:when (featurep! :ui vc-gutter)
:desc "Git revert hunk" "r" #'git-gutter:revert-hunk
:desc "Git stage hunk" "s" #'git-gutter:stage-hunk
:desc "Git time machine" "t" #'git-timemachine-toggle
:desc "Jump to next hunk" "]" #'git-gutter:next-hunk
:desc "Jump to previous hunk" "[" #'git-gutter:previous-hunk)
(:when (featurep! :tools magit)
:desc "Magit dispatch" "/" #'magit-dispatch
:desc "Forge dispatch" "'" #'forge-dispatch
:desc "Magit switch branch" "b" #'magit-branch-checkout
:desc "Magit status" "g" #'magit-status
:desc "Magit file delete" "D" #'magit-file-delete
:desc "Magit blame" "B" #'magit-blame-addition
:desc "Magit clone" "C" #'magit-clone
:desc "Magit fetch" "F" #'magit-fetch
:desc "Magit buffer log" "L" #'magit-log
:desc "Git stage file" "S" #'magit-stage-file
:desc "Git unstage file" "U" #'magit-unstage-file
(:prefix ("f" . "find")
:desc "Find file" "f" #'magit-find-file
:desc "Find gitconfig file" "g" #'magit-find-git-config-file
:desc "Find commit" "c" #'magit-show-commit
:desc "Find issue" "i" #'forge-visit-issue
:desc "Find pull request" "p" #'forge-visit-pullreq)
(:prefix ("o" . "open in browser")
:desc "Browse file or region" "o" #'+vc/browse-at-remote-file-or-region
:desc "Browse homepage" "h" #'+vc/browse-at-remote-homepage
:desc "Browse remote" "r" #'forge-browse-remote
:desc "Browse commit" "c" #'forge-browse-commit
:desc "Browse an issue" "i" #'forge-browse-issue
:desc "Browse a pull request" "p" #'forge-browse-pullreq
:desc "Browse issues" "I" #'forge-browse-issues
:desc "Browse pull requests" "P" #'forge-browse-pullreqs)
(:prefix ("l" . "list")
(:when (featurep! :tools gist)
:desc "List gists" "g" #'+gist:list)
:desc "List repositories" "r" #'magit-list-repositories
:desc "List submodules" "s" #'magit-list-submodules
:desc "List issues" "i" #'forge-list-issues
:desc "List pull requests" "p" #'forge-list-pullreqs
:desc "List notifications" "n" #'forge-list-notifications)
(:prefix ("c" . "create")
:desc "Initialize repo" "r" #'magit-init
:desc "Clone repo" "R" #'magit-clone
:desc "Commit" "c" #'magit-commit-create
:desc "Fixup" "f" #'magit-commit-fixup
:desc "Branch" "b" #'magit-branch-and-checkout
:desc "Issue" "i" #'forge-create-issue
:desc "Pull request" "p" #'forge-create-pullreq)))
;;; <leader> i --- insert
(:prefix-map ("i" . "insert")
:desc "Current file name" "f" #'+default/insert-file-path
:desc "Current file path" "F" (λ!! #'+default/insert-file-path t)
:desc "Evil ex path" "p" (λ! (evil-ex "R!echo "))
:desc "From evil register" "r" #'evil-ex-registers
:desc "Snippet" "s" #'yas-insert-snippet
:desc "Unicode" "u" #'unicode-chars-list-chars
:desc "From clipboard" "y" #'+default/yank-pop)
;;; <leader> n --- notes
(:prefix-map ("n" . "notes")
:desc "Search notes for symbol" "*" #'+default/search-notes-for-symbol-at-point
:desc "Org agenda" "a" #'org-agenda
:desc "Toggle org-clock" "c" #'+org/toggle-clock
:desc "Cancel org-clock" "C" #'org-clock-cancel
:desc "Open deft" "d" #'deft
:desc "Find file in notes" "f" #'+default/find-in-notes
:desc "Browse notes" "F" #'+default/browse-notes
:desc "Org store link" "l" #'org-store-link
:desc "Tags search" "m" #'org-tags-view
:desc "Org capture" "n" #'org-capture
:desc "Active org-clock" "o" #'org-clock-goto
:desc "Todo list" "t" #'org-todo-list
:desc "Search notes" "s" #'+default/org-notes-search
:desc "Search org agenda headlines" "S" #'+default/org-notes-headlines
:desc "View search" "v" #'org-search-view
:desc "Org export to clipboard" "y" #'+org/export-to-clipboard
:desc "Org export to clipboard as RTF" "Y" #'+org/export-to-clipboard-as-rich-text
(:when (featurep! :lang org +journal)
(:prefix ("j" . "journal")
:desc "New Entry" "j" #'org-journal-new-entry
:desc "Search Forever" "s" #'org-journal-search-forever)))
;;; <leader> o --- open
(:prefix-map ("o" . "open")
:desc "Org agenda" "A" #'org-agenda
(:prefix ("a" . "org agenda")
:desc "Agenda" "a" #'org-agenda
:desc "Todo list" "t" #'org-todo-list
:desc "Tags search" "m" #'org-tags-view
:desc "View search" "v" #'org-search-view)
:desc "Default browser" "b" #'browse-url-of-file
:desc "Start debugger" "d" #'+debugger/start
:desc "New frame" "f" #'make-frame
:desc "REPL" "r" #'+eval/open-repl-other-window
:desc "REPL (same window)" "R" #'+eval/open-repl-same-window
:desc "Dired" "-" #'dired-jump
(:when (featurep! :ui neotree)
:desc "Project sidebar" "p" #'+neotree/open
:desc "Find file in project sidebar" "P" #'+neotree/find-this-file)
(:when (featurep! :ui treemacs)
:desc "Project sidebar" "p" #'+treemacs/toggle
:desc "Find file in project sidebar" "P" #'+treemacs/find-file)
(:when (featurep! :term shell)
:desc "Toggle shell popup" "t" #'+shell/toggle
:desc "Open shell here" "T" #'+shell/here)
(:when (featurep! :term term)
:desc "Toggle terminal popup" "t" #'+term/toggle
:desc "Open terminal here" "T" #'+term/here)
(:when (featurep! :term vterm)
:desc "Toggle vterm popup" "t" #'+vterm/toggle
:desc "Open vterm here" "T" #'+vterm/here)
(:when (featurep! :term eshell)
:desc "Toggle eshell popup" "e" #'+eshell/toggle
:desc "Open eshell here" "E" #'+eshell/here)
(:when (featurep! :tools macos)
:desc "Reveal in Finder" "o" #'+macos/reveal-in-finder
:desc "Reveal project in Finder" "O" #'+macos/reveal-project-in-finder
:desc "Send to Transmit" "u" #'+macos/send-to-transmit
:desc "Send project to Transmit" "U" #'+macos/send-project-to-transmit
:desc "Send to Launchbar" "l" #'+macos/send-to-launchbar
:desc "Send project to Launchbar" "L" #'+macos/send-project-to-launchbar)
(:when (featurep! :tools docker)
:desc "Docker" "D" #'docker))
;;; <leader> p --- project
(:prefix-map ("p" . "project")
:desc "Browse project" "." #'+default/browse-project
:desc "Browse other project" ">" #'doom/browse-in-other-project
:desc "Run cmd in project root" "!" #'projectile-run-shell-command-in-root
:desc "Add new project" "a" #'projectile-add-known-project
:desc "Switch to project buffer" "b" #'projectile-switch-to-buffer
:desc "Compile in project" "c" #'projectile-compile-project
:desc "Repeat last command" "C" #'projectile-repeat-last-command
:desc "Remove known project" "d" #'projectile-remove-known-project
:desc "Edit project .dir-locals" "e" #'projectile-edit-dir-locals
:desc "Find file in project" "f" #'projectile-find-file
:desc "Find file in other project" "F" #'doom/find-file-in-other-project
:desc "Configure project" "g" #'projectile-configure-project
:desc "Invalidate project cache" "i" #'projectile-invalidate-cache
:desc "Kill project buffers" "k" #'projectile-kill-buffers
:desc "Find other file" "o" #'projectile-find-other-file
:desc "Switch project" "p" #'projectile-switch-project
:desc "Find recent project files" "r" #'projectile-recentf
:desc "Run project" "R" #'projectile-run-project
:desc "Save project files" "s" #'projectile-save-project-buffers
:desc "Pop up scratch buffer" "x" #'doom/open-project-scratch-buffer
:desc "Switch to scratch buffer" "X" #'doom/switch-to-project-scratch-buffer
:desc "List project tasks" "t" #'magit-todos-list
:desc "Test project" "T" #'projectile-test-project)
;;; <leader> q --- quit/session
(:prefix-map ("q" . "quit/session")
:desc "Restart emacs server" "d" #'+default/restart-server
:desc "Delete frame" "f" #'delete-frame
:desc "Clear current frame" "F" #'doom/kill-all-buffers
:desc "Kill Emacs (and daemon)" "K" #'save-buffers-kill-emacs
:desc "Quit Emacs" "q" #'save-buffers-kill-terminal
:desc "Quit Emacs without saving" "Q" #'evil-quit-all-with-error-code
:desc "Quick save current session" "s" #'doom/quicksave-session
:desc "Restore last session" "l" #'doom/quickload-session
:desc "Save session to file" "S" #'doom/save-session
:desc "Restore session from file" "L" #'doom/load-session
:desc "Restart & restore Emacs" "r" #'doom/restart-and-restore
:desc "Restart Emacs" "R" #'doom/restart)
;;; <leader> r --- remote
(:when (featurep! :tools upload)
(:prefix-map ("r" . "remote")
:desc "Upload local" "u" #'ssh-deploy-upload-handler
:desc "Upload local (force)" "U" #'ssh-deploy-upload-handler-forced
:desc "Download remote" "d" #'ssh-deploy-download-handler
:desc "Diff local & remote" "D" #'ssh-deploy-diff-handler
:desc "Browse remote files" "." #'ssh-deploy-browse-remote-handler
:desc "Detect remote changes" ">" #'ssh-deploy-remote-changes-handler))
;;; <leader> s --- search
(:prefix-map ("s" . "search")
:desc "Search buffer" "b" #'swiper
:desc "Search current directory" "d" #'+default/search-cwd
:desc "Search other directory" "D" #'+default/search-other-cwd
:desc "Locate file" "f" #'locate
:desc "Jump to symbol" "i" #'imenu
:desc "Jump to visible link" "l" #'ace-link
:desc "Jump to link" "L" #'ffap-menu
:desc "Jump list" "j" #'evil-show-jumps
:desc "Jump to mark" "m" #'evil-show-marks
:desc "Look up online" "o" #'+lookup/online
:desc "Look up online (w/ prompt)" "O" #'+lookup/online-select
:desc "Look up in local docsets" "k" #'+lookup/in-docsets
:desc "Look up in all docsets" "K" #'+lookup/in-all-docsets
:desc "Search project" "p" #'+default/search-project
:desc "Search other project" "P" #'+default/search-other-project
:desc "Search buffer" "s" #'swiper-isearch
:desc "Search buffer for thing at point" "S" #'swiper-isearch-thing-at-point)
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")
:desc "Big mode" "b" #'doom-big-font-mode
:desc "Flymake" "f" #'flymake-mode
(:when (featurep! :tools flycheck)
:desc "Flycheck" "f" #'flycheck-mode)
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
:desc "Evil goggles" "g" #'evil-goggles-mode
(:when (featurep! :ui indent-guides)
:desc "Indent guides" "i" #'highlight-indent-guides-mode)
:desc "Indent style" "I" #'doom/toggle-indent-style
:desc "Line numbers" "l" #'doom/toggle-line-numbers
(:when (featurep! :lang org +present)
:desc "org-tree-slide mode" "p" #'+org-present/start)
:desc "Read-only mode" "r" #'read-only-mode
(:when (featurep! :tools flyspell)
:desc "Flyspell" "s" #'flyspell-mode)
(:when (featurep! :lang org +pomodoro)
:desc "Pomodoro timer" "t" #'org-pomodoro)
:desc "Word-wrap mode" "w" #'+word-wrap-mode))
(after! which-key
(let ((prefix-re (regexp-opt (list doom-leader-key doom-leader-alt-key))))
(cl-pushnew `((,(format "\\`\\(?:C-w\\|%s w\\) m\\'" prefix-re))
nil . "maximize")
which-key-replacement-alist)))

View File

@@ -0,0 +1,21 @@
;;; config/default/+evil.el -*- lexical-binding: t; -*-
(defun +default-disable-delete-selection-mode-h ()
(delete-selection-mode -1))
(add-hook 'evil-insert-state-entry-hook #'delete-selection-mode)
(add-hook 'evil-insert-state-exit-hook #'+default-disable-delete-selection-mode-h)
;;
;;; Keybindings
;; This section is dedicated to "fixing" certain keys so that they behave
;; sensibly (and consistently with similar contexts).
;; Make SPC u SPC u [...] possible (#747)
(map! :map universal-argument-map
:prefix doom-leader-key "u" #'universal-argument-more
:prefix doom-leader-alt-key "u" #'universal-argument-more)
(when (featurep! +bindings)
(load! "+evil-bindings"))

View File

@@ -0,0 +1,46 @@
#+TITLE: :config default
This module provides a set of reasonable defaults, including:
+ A Spacemacs-esque keybinding scheme
+ Extra Ex commands for evil-mode users
+ A yasnippet snippets library tailored to Doom emacs
+ A configuration for (almost) universally repeating searches with =;= and =,=
#+begin_quote
The defaults module is intended as a "reasonable-defaults" module, but also as a
reference for your own private modules. You'll find [[https://github.com/hlissner/doom-emacs-private][my private module in a
separate repo]].
Refer to the [[https://github.com/hlissner/doom-emacs/wiki/Customization][Customization page]] on the wiki for details on starting your own
private module.
#+end_quote
* Table of Contents :TOC:
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#im-not-an-evil-user][I'm not an evil user...]]
- [[#appendix][Appendix]]
- [[#commands][Commands]]
- [[#hacks][Hacks]]
* Install
This module has no external dependencies.
* Configuration
** I'm not an evil user...
That's fine. All evil configuration is ignored if =:editor evil= is disabled.
* Appendix
** Commands
+ ~+default/browse-project~
+ ~+default/browse-templates~
+ ~+default/find-in-templates~
+ ~+default/browse-emacsd~
+ ~+default/find-in-emacsd~
+ ~+default/browse-notes~
+ ~+default/find-in-notes~
+ ~+default/find-in-snippets~
** Hacks
+ ~epa-pinentry-mode~ is set to ~'loopback~, forcing gpg-agent to use the Emacs
minibuffer when prompting for your passphrase. *Only works with GPG 2.1+!*

View File

@@ -0,0 +1,347 @@
;; config/default/autoload/default.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +default/yank-buffer-filename ()
"Copy the current buffer's path to the kill ring."
(interactive)
(if-let* ((filename (or buffer-file-name (bound-and-true-p list-buffers-directory))))
(message (kill-new (abbreviate-file-name filename)))
(error "Couldn't find filename in current buffer")))
;;;###autoload
(defun +default/browse-project ()
(interactive) (doom-project-browse (doom-project-root)))
;; NOTE No need for find-in-project, use `projectile-find-file'
;;;###autoload
(defun +default/browse-templates ()
(interactive) (doom-project-browse +file-templates-dir))
;;;###autoload
(defun +default/find-in-templates ()
(interactive) (doom-project-find-file +file-templates-dir))
;;;###autoload
(defun +default/browse-emacsd ()
(interactive) (doom-project-browse doom-emacs-dir))
;;;###autoload
(defun +default/find-in-emacsd ()
(interactive) (doom-project-find-file doom-emacs-dir))
;;;###autoload
(defun +default/browse-notes ()
(interactive) (doom-project-browse org-directory))
;;;###autoload
(defun +default/find-in-notes ()
(interactive) (doom-project-find-file org-directory))
;;;###autoload
(defun +default/compile (arg)
"Runs `compile' from the root of the current project.
If a compilation window is already open, recompile that instead.
If ARG (universal argument), runs `compile' from the current directory."
(interactive "P")
(if (and (bound-and-true-p compilation-in-progress)
(buffer-live-p compilation-last-buffer))
(recompile)
(call-interactively
(if arg
#'projectile-compile-project
#'compile))))
;;;###autoload
(defun +default/man-or-woman ()
"Invoke `man' if man is installed, otherwise use `woman'."
(interactive)
(call-interactively
(if (executable-find "man")
#'man
#'woman)))
;;;###autoload
(defalias '+default/newline #'newline)
;;;###autoload
(defun +default/new-buffer ()
"TODO"
(interactive)
(if (featurep! 'evil)
(call-interactively #'evil-buffer-new)
(let ((buffer (generate-new-buffer "*new*")))
(set-window-buffer nil buffer)
(with-current-buffer buffer
(funcall (default-value 'major-mode))))))
;;;###autoload
(defun +default/newline-above ()
"Insert an indented new line before the current one."
(interactive)
(if (featurep 'evil)
(call-interactively 'evil-open-above)
(beginning-of-line)
(save-excursion (newline))
(indent-according-to-mode)))
;;;###autoload
(defun +default/newline-below ()
"Insert an indented new line after the current one."
(interactive)
(if (featurep 'evil)
(call-interactively 'evil-open-below)
(end-of-line)
(newline-and-indent)))
;;;###autoload
(defun +default/yank-pop ()
"Interactively select what text to insert from the kill ring."
(interactive)
(call-interactively
(cond ((fboundp 'counsel-yank-pop) #'counsel-yank-pop)
((fboundp 'helm-show-kill-ring) #'helm-show-kill-ring)
((error "No kill-ring search backend available. Enable ivy or helm!")))))
;;;###autoload
(defun +default--newline-indent-and-continue-comments-a ()
"A replacement for `newline-and-indent'.
Continues comments if executed from a commented line, with special support for
languages with weak native comment continuation support (like C-family
languages)."
(interactive)
(if (and (sp-point-in-comment)
comment-line-break-function)
(funcall comment-line-break-function nil)
(delete-horizontal-space t)
(newline nil t)
(indent-according-to-mode)))
(defun doom--backward-delete-whitespace-to-column ()
"Delete back to the previous column of whitespace, or as much whitespace as
possible, or just one char if that's not possible."
(interactive)
(let* ((context (ignore-errors (sp-get-thing)))
(op (plist-get context :op))
(cl (plist-get context :cl))
open-len close-len)
(cond ;; When in strings (sp acts weird with quotes; this is the fix)
;; Also, skip closing delimiters
((and op cl
(string= op cl)
(and (string= (char-to-string (or (char-before) 0)) op)
(setq open-len (length op)))
(and (string= (char-to-string (or (char-after) 0)) cl)
(setq close-len (length cl))))
(delete-char (- open-len))
(delete-char close-len))
;; Delete up to the nearest tab column IF only whitespace between
;; point and bol.
((and (not indent-tabs-mode)
(not (bolp))
(not (sp-point-in-string))
(save-excursion (>= (- (skip-chars-backward " \t")) tab-width)))
(let ((movement (% (current-column) tab-width)))
(when (= movement 0)
(setq movement tab-width))
(delete-char (- movement)))
(unless (memq (char-before) (list ?\n ?\ ))
(insert " ")))
;; Otherwise do a regular delete
((delete-char -1)))))
;;;###autoload
(defun +default--delete-backward-char-a (n &optional killflag)
"Same as `delete-backward-char', but preforms these additional checks:
+ If point is surrounded by (balanced) whitespace and a brace delimiter ({} []
()), delete a space on either side of the cursor.
+ If point is at BOL and surrounded by braces on adjacent lines, collapse
newlines:
{
|
} => {|}
+ Otherwise, resort to `doom--backward-delete-whitespace-to-column'.
+ Resorts to `delete-char' if n > 1"
(interactive "p\nP")
(or (integerp n)
(signal 'wrong-type-argument (list 'integerp n)))
(cond ((and (use-region-p)
delete-active-region
(= n 1))
;; If a region is active, kill or delete it.
(if (eq delete-active-region 'kill)
(kill-region (region-beginning) (region-end) 'region)
(funcall region-extract-function 'delete-only)))
;; In Overwrite mode, maybe untabify while deleting
((null (or (null overwrite-mode)
(<= n 0)
(memq (char-before) '(?\t ?\n))
(eobp)
(eq (char-after) ?\n)))
(let ((ocol (current-column)))
(delete-char (- n) killflag)
(save-excursion
(insert-char ?\s (- ocol (current-column)) nil))))
;;
((and (= n 1) (bound-and-true-p smartparens-mode))
(cond ((and (memq (char-before) (list ?\ ?\t))
(save-excursion
(and (/= (skip-chars-backward " \t" (line-beginning-position)) 0)
(bolp))))
(doom--backward-delete-whitespace-to-column))
((let* ((pair (ignore-errors (sp-get-thing)))
(op (plist-get pair :op))
(cl (plist-get pair :cl))
(beg (plist-get pair :beg))
(end (plist-get pair :end)))
(cond ((and end beg (= end (+ beg (length op) (length cl))))
(sp-backward-delete-char 1))
((doom-surrounded-p pair 'inline 'balanced)
(delete-char -1 killflag)
(delete-char 1)
(when (= (point) (+ (length cl) beg))
(sp-backward-delete-char 1)
(sp-insert-pair op)))
((and (bolp) (doom-surrounded-p pair nil 'balanced))
(delete-region beg end)
(sp-insert-pair op)
t)
((run-hook-with-args-until-success 'doom-delete-backward-functions))
((doom--backward-delete-whitespace-to-column)))))))
;; Otherwise, do simple deletion.
((delete-char (- n) killflag))))
;;;###autoload
(defun +default/search-cwd (&optional arg)
"Conduct a text search in files under the current folder.
If prefix ARG is set, prompt for a directory to search from."
(interactive "P")
(let ((default-directory
(if arg
(read-directory-name "Search directory: ")
default-directory)))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search-from-cwd)
((featurep! :completion helm) #'+helm/project-search-from-cwd)
(#'rgrep)))))
;;;###autoload
(defun +default/search-other-cwd ()
"Conduct a text search in another directory."
(interactive)
(+default/search-cwd 'other))
;;;###autoload
(defun +default/search-project (&optional arg)
"Conduct a text search in the current project root.
If prefix ARG is set, prompt for a known project to search from."
(interactive "P")
(let ((default-directory
(if arg
(if-let (projects (projectile-relevant-known-projects))
(completing-read "Search project: " projects
nil t nil nil (doom-project-root))
(user-error "There are no known projects"))
default-directory)))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search)
((featurep! :completion helm) #'+helm/project-search)
(#'projectile-grep)))))
;;;###autoload
(defun +default/search-other-project ()
"Conduct a text search in a known project."
(interactive)
(+default/search-project 'other))
;;;###autoload
(defun +default/search-project-for-symbol-at-point (&optional arg symbol)
"Conduct a text search in the current project for symbol at point.
If prefix ARG is set, prompt for a known project to search from."
(interactive
(list current-prefix-arg
(or (and (use-region-p)
(rxt-quote-pcre
(buffer-substring-no-properties (region-beginning)
(region-end))))
(rxt-quote-pcre (thing-at-point 'symbol t))
"")))
(let ((default-directory
(if arg
(if-let (projects (projectile-relevant-known-projects))
(completing-read "Switch to project: " projects
nil t nil nil (doom-project-root))
(user-error "There are no known projects"))
default-directory)))
(cond ((featurep! :completion ivy)
(+ivy/project-search nil symbol))
((featurep! :completion helm)
(+helm/project-search nil symbol))
((rgrep (regexp-quote symbol))))))
;;;###autoload
(defun +default/search-notes-for-symbol-at-point (&optional symbol)
"Conduct a text search in the current project for symbol at point. If prefix
ARG is set, prompt for a known project to search from."
(interactive
(list (rxt-quote-pcre (or (thing-at-point 'symbol t) ""))))
(require 'org)
(let ((default-directory org-directory))
(+default/search-project-for-symbol-at-point
nil symbol)))
;;;###autoload
(defun +default/org-notes-search ()
"Perform a text search on `org-directory'."
(interactive)
(require 'org)
(let ((default-directory org-directory))
(+default/search-project-for-symbol-at-point nil "")))
;;;###autoload
(defun +default/org-notes-headlines ()
"Jump to an Org headline in `org-agenda-files'."
(interactive)
(doom-completing-read-org-headings
"Jump to org headline: " org-agenda-files 3 t))
;;;###autoload
(defun +default/lsp-format-region-or-buffer ()
"Format the buffer (or selection) with LSP."
(interactive)
(unless (bound-and-true-p lsp-mode)
(user-error "Not in an LSP buffer"))
(call-interactively
(if (use-region-p)
#'lsp-format-region
#'lsp-format-buffer)))
;;;###autoload
(defun +default/restart-server ()
"Restart the Emacs server."
(interactive)
(server-force-delete)
(while (server-running-p)
(sit-for 1))
(server-start))
;;;###autoload
(defun +default/find-file-under-here ()
"Perform a recursive file search from the current directory."
(interactive)
(if (featurep! :completion ivy)
(call-interactively #'counsel-file-jump)
(λ! (doom-project-find-file default-directory))))
;;;###autoload
(defun +default/insert-file-path (arg)
"Insert the file name (absolute path if prefix ARG).
If `buffer-file-name' isn't set, uses `default-directory'."
(interactive "P")
(let ((path (or buffer-file-name default-directory)))
(insert
(if arg
(abbreviate-file-name path)
(file-name-nondirectory path)))))

View File

@@ -0,0 +1,405 @@
;;; config/default/config.el -*- lexical-binding: t; -*-
(defvar +default-minibuffer-maps
`(minibuffer-local-map
minibuffer-local-ns-map
minibuffer-local-completion-map
minibuffer-local-must-match-map
minibuffer-local-isearch-map
read-expression-map
,@(cond ((featurep! :completion ivy)
'(ivy-minibuffer-map
ivy-switch-buffer-map))
((featurep! :completion helm)
'(helm-map
helm-ag-map
helm-read-file-map))))
"A list of all the keymaps used for the minibuffer.")
;;
;;; Reasonable defaults
;;;###package avy
(setq avy-all-windows nil
avy-all-windows-alt t
avy-background t)
(after! epa
(setq epa-file-encrypt-to
(or epa-file-encrypt-to
;; Collect all public key IDs with your username
(unless (string-empty-p user-full-name)
(cl-loop for key in (ignore-errors (epg-list-keys (epg-make-context) user-full-name))
collect (epg-sub-key-id (car (epg-key-sub-key-list key)))))
user-mail-address)
;; With GPG 2.1, this forces gpg-agent to use the Emacs minibuffer to
;; prompt for the key passphrase.
epa-pinentry-mode 'loopback))
(use-package! drag-stuff
:defer t
:init
(map! "<M-up>" #'drag-stuff-up
"<M-down>" #'drag-stuff-down
"<M-left>" #'drag-stuff-left
"<M-right>" #'drag-stuff-right))
;;;###package tramp
(unless IS-WINDOWS
(setq tramp-default-method "ssh")) ; faster than the default scp
;;
;;; Smartparens config
(when (featurep! +smartparens)
;; You can disable :unless predicates with (sp-pair "'" nil :unless nil)
;; And disable :post-handlers with (sp-pair "{" nil :post-handlers nil)
;; or specific :post-handlers with:
;; (sp-pair "{" nil :post-handlers '(:rem ("| " "SPC")))
(after! smartparens
;; Smartparens is broken in `cc-mode' as of Emacs 27. See
;; <https://github.com/Fuco1/smartparens/issues/963>.
(unless EMACS27+
(pushnew! sp--special-self-insert-commands 'c-electric-paren 'c-electric-brace))
;; Smartparens' navigation feature is neat, but does not justify how
;; expensive it is. It's also less useful for evil users. This may need to
;; be reactivated for non-evil users though. Needs more testing!
(add-hook! 'after-change-major-mode-hook
(defun doom-disable-smartparens-navigate-skip-match-h ()
(setq sp-navigate-skip-match nil
sp-navigate-consider-sgml-tags nil)))
;; Autopair quotes more conservatively; if I'm next to a word/before another
;; quote, I likely don't want to open a new pair.
(let ((unless-list '(sp-point-before-word-p
sp-point-after-word-p
sp-point-before-same-p)))
(sp-pair "'" nil :unless unless-list)
(sp-pair "\"" nil :unless unless-list))
;; Expand {|} => { | }
;; Expand {|} => {
;; |
;; }
(dolist (brace '("(" "{" "["))
(sp-pair brace nil
:post-handlers '(("||\n[i]" "RET") ("| " "SPC"))
;; I likely don't want a new pair if adjacent to a word or opening brace
:unless '(sp-point-before-word-p sp-point-before-same-p)))
;; In lisps ( should open a new form if before another parenthesis
(sp-local-pair sp-lisp-modes "(" ")" :unless '(:rem sp-point-before-same-p))
;; Major-mode specific fixes
(sp-local-pair '(ruby-mode enh-ruby-mode) "{" "}"
:pre-handlers '(:rem sp-ruby-pre-handler)
:post-handlers '(:rem sp-ruby-post-handler))
;; Don't do square-bracket space-expansion where it doesn't make sense to
(sp-local-pair '(emacs-lisp-mode org-mode markdown-mode gfm-mode)
"[" nil :post-handlers '(:rem ("| " "SPC")))
;; Reasonable default pairs for HTML-style comments
(sp-local-pair (append sp--html-modes '(markdown-mode gfm-mode))
"<!--" "-->"
:unless '(sp-point-before-word-p sp-point-before-same-p)
:actions '(insert) :post-handlers '(("| " "SPC")))
;; Disable electric keys in C modes because it interferes with smartparens
;; and custom bindings. We'll do it ourselves (mostly).
(after! cc-mode
(c-toggle-electric-state -1)
(c-toggle-auto-newline -1)
(setq c-electric-flag nil)
(dolist (key '("#" "{" "}" "/" "*" ";" "," ":" "(" ")" "\177"))
(define-key c-mode-base-map key nil))
;; Smartparens and cc-mode both try to autoclose angle-brackets
;; intelligently. The result isn't very intelligent (causes redundant
;; characters), so just do it ourselves.
(define-key! c++-mode-map "<" nil ">" nil)
(defun +default-cc-sp-point-is-template-p (id action context)
"Return t if point is in the right place for C++ angle-brackets."
(and (sp-in-code-p id action context)
(cond ((eq action 'insert)
(sp-point-after-word-p id action context))
((eq action 'autoskip)
(/= (char-before) 32)))))
(defun +default-cc-sp-point-after-include-p (id action context)
"Return t if point is in an #include."
(and (sp-in-code-p id action context)
(save-excursion
(goto-char (line-beginning-position))
(looking-at-p "[ ]*#include[^<]+"))))
;; ...and leave it to smartparens
(sp-local-pair '(c++-mode objc-mode)
"<" ">"
:when '(+default-cc-sp-point-is-template-p
+default-cc-sp-point-after-include-p)
:post-handlers '(("| " "SPC")))
(sp-local-pair '(c-mode c++-mode objc-mode java-mode)
"/*!" "*/"
:post-handlers '(("||\n[i]" "RET") ("[d-1]< | " "SPC"))))
;; Expand C-style doc comment blocks. Must be done manually because some of
;; these languages use specialized (and deferred) parsers, whose state we
;; can't access while smartparens is doing its thing.
(defun +default-expand-asterix-doc-comment-block (&rest _ignored)
(let ((indent (current-indentation)))
(newline-and-indent)
(save-excursion
(newline)
(insert (make-string indent 32) " */")
(delete-char 2))))
(sp-local-pair
'(js2-mode typescript-mode rjsx-mode rust-mode c-mode c++-mode objc-mode
csharp-mode java-mode php-mode css-mode scss-mode less-css-mode
stylus-mode scala-mode)
"/*" "*/"
:actions '(insert)
:post-handlers '(("| " "SPC")
("|\n[i]*/[d-2]" "RET")
(+default-expand-asterix-doc-comment-block "*")))
(after! smartparens-ml
(sp-with-modes '(tuareg-mode fsharp-mode)
(sp-local-pair "(*" "*)" :actions nil)
(sp-local-pair "(*" "*"
:actions '(insert)
:post-handlers '(("| " "SPC") ("|\n[i]*)[d-2]" "RET")))))
(after! smartparens-markdown
(sp-with-modes '(markdown-mode gfm-mode)
(sp-local-pair "```" "```" :post-handlers '(:add ("||\n[i]" "RET")))
;; The original rules for smartparens had an odd quirk: inserting two
;; asterixex would replace nearby quotes with asterixes. These two rules
;; set out to fix this.
(sp-local-pair "**" nil :actions :rem)
(sp-local-pair "*" "*"
:actions '(insert skip)
:unless '(:rem sp-point-at-bol-p)
;; * then SPC will delete the second asterix and assume
;; you wanted a bullet point. * followed by another *
;; will produce an extra, assuming you wanted **|**.
:post-handlers '(("[d1]" "SPC") ("|*" "*"))))
;; This keybind allows * to skip over **.
(map! :map markdown-mode-map
:ig "*" (λ! (if (looking-at-p "\\*\\* *$")
(forward-char 2)
(call-interactively 'self-insert-command)))))
;; Highjacks backspace to:
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
;; b) delete up to nearest column multiple of `tab-width' at a time
;; c) close empty multiline brace blocks in one step:
;; {
;; |
;; }
;; becomes {|}
;; d) refresh smartparens' :post-handlers, so SPC and RET expansions work
;; even after a backspace.
;; e) properly delete smartparen pairs when they are encountered, without
;; the need for strict mode.
;; f) do none of this when inside a string
(advice-add #'delete-backward-char :override #'+default--delete-backward-char-a))
;; Makes `newline-and-indent' continue comments (and more reliably)
(advice-add #'newline-and-indent :override #'+default--newline-indent-and-continue-comments-a))
;;
;;; Keybinding fixes
;; This section is dedicated to "fixing" certain keys so that they behave
;; sensibly (and consistently with similar contexts).
;; Consistently use q to quit windows
(after! tabulated-list
(define-key tabulated-list-mode-map "q" #'quit-window))
;; OS specific fixes
(when IS-MAC
;; Fix MacOS shift+tab
(define-key key-translation-map [S-iso-lefttab] [backtab])
;; Fix conventional OS keys in Emacs
(map! "s-`" #'other-frame ; fix frame-switching
;; fix OS window/frame navigation/manipulation keys
"s-w" #'delete-window
"s-W" #'delete-frame
"s-n" #'+default/new-buffer
"s-N" #'make-frame
"s-q" (if (daemonp) #'delete-frame #'save-buffers-kill-terminal)
"C-s-f" #'toggle-frame-fullscreen
;; Restore somewhat common navigation
"s-l" #'goto-line
;; Restore OS undo, save, copy, & paste keys (without cua-mode, because
;; it imposes some other functionality and overhead we don't need)
"s-f" #'swiper
"s-z" #'undo
"s-Z" #'redo
"s-c" (if (featurep 'evil) #'evil-yank #'copy-region-as-kill)
"s-v" #'yank
"s-s" #'save-buffer
:v "s-x" #'kill-region
;; Buffer-local font scaling
"s-+" #'doom/reset-font-size
"s-=" #'doom/increase-font-size
"s--" #'doom/decrease-font-size
;; Conventional text-editing keys & motions
"s-a" #'mark-whole-buffer
"s-/" (λ! (save-excursion (comment-line 1)))
:n "s-/" #'evilnc-comment-or-uncomment-lines
:v "s-/" #'evilnc-comment-operator
:gi [s-backspace] #'doom/backward-kill-to-bol-and-indent
:gi [s-left] #'doom/backward-to-bol-or-indent
:gi [s-right] #'doom/forward-to-last-non-comment-or-eol
:gi [M-backspace] #'backward-kill-word
:gi [M-left] #'backward-word
:gi [M-right] #'forward-word))
;;
;;; Keybind schemes
;; Custom help keys -- these aren't under `+bindings' because they ought to be
;; universal.
(define-key! help-map
;; new keybinds
"'" #'describe-char
"E" #'doom/sandbox
"M" #'doom/describe-active-minor-mode
"O" #'+lookup/online
"T" #'doom/toggle-profiler
"V" #'set-variable
"W" #'+default/man-or-woman
"C-k" #'describe-key-briefly
"C-l" #'describe-language-environment
"C-m" #'info-emacs-manual
;; Unbind `help-for-help'. Conflicts with which-key's help command for the
;; <leader> h prefix. It's already on ? and F1 anyway.
"C-h" nil
;; replacement keybinds
;; replaces `info-emacs-manual' b/c it's on C-m now
"r" nil
"rr" #'doom/reload
"rt" #'doom/reload-theme
"rp" #'doom/reload-packages
"rf" #'doom/reload-font
"re" #'doom/reload-env
;; make `describe-bindings' available under the b prefix which it previously
;; occupied. Add more binding related commands under that prefix as well
"b" nil
"bb" #'describe-bindings
"bi" #'which-key-show-minor-mode-keymap
"bm" #'which-key-show-major-mode
"bt" #'which-key-show-top-level
"bf" #'which-key-show-full-keymap
"bk" #'which-key-show-keymap
;; replaces `apropos-documentation' b/c `apropos' covers this
"d" nil
"da" #'doom/help-autodefs
"db" #'doom/report-bug
"dd" #'doom/toggle-debug-mode
"df" #'doom/help-faq
"dh" #'doom/help
"dk" #'doom/goto-packages-file
"dl" #'doom/help-search-load-path
"dm" #'doom/help-modules
"dn" #'doom/help-news
"dN" #'doom/help-news-search
"di" #'doom/goto-doomblock
"dp" #'doom/help-packages
"dP" #'doom/help-package-homepage
"dc" #'doom/goto-config-file
"dC" #'doom/help-package-config
"ds" #'doom/help-search
"dx" #'doom/sandbox
"dt" #'doom/toggle-profiler
"dv" #'doom/version
;; replaces `apropos-command'
"a" #'apropos
"A" #'apropos-documentation
;; replaces `describe-copying' b/c not useful
"C-c" #'describe-coding-system
;; replaces `Info-got-emacs-command-node' b/c redundant w/ `Info-goto-node'
"F" #'describe-face
;; replaces `view-hello-file' b/c annoying
"h" nil
;; replaces `view-emacs-news' b/c it's on C-n too
"n" #'doom/help-news
;; replaces `help-with-tutorial', b/c it's less useful than `load-theme'
"t" #'load-theme
;; replaces `finder-by-keyword' b/c not useful
"p" #'doom/help-packages
;; replaces `describe-package' b/c redundant w/ `doom/describe-package'
"P" #'find-library)
(after! which-key
(let ((prefix-re (regexp-opt (list doom-leader-key doom-leader-alt-key))))
(cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) d\\'" prefix-re))
nil . "doom")
which-key-replacement-alist)
(cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) r\\'" prefix-re))
nil . "reload")
which-key-replacement-alist)
(cl-pushnew `((,(format "\\`\\(?:<\\(?:\\(?:f1\\|help\\)>\\)\\|C-h\\|%s h\\) b\\'" prefix-re))
nil . "bindings")
which-key-replacement-alist)))
(when (featurep! +bindings)
;; Make M-x harder to miss
(define-key! 'override
"M-x" #'execute-extended-command
"A-x" #'execute-extended-command)
;; A Doom convention where C-s on popups and interactive searches will invoke
;; ivy/helm for their superior filtering.
(define-key! :keymaps +default-minibuffer-maps
"C-s" (if (featurep! :completion ivy)
#'counsel-minibuffer-history
#'helm-minibuffer-history))
;; Smarter C-a/C-e for both Emacs and Evil. C-a will jump to indentation.
;; Pressing it again will send you to the true bol. Same goes for C-e, except
;; it will ignore comments+trailing whitespace before jumping to eol.
(map! :gi "C-a" #'doom/backward-to-bol-or-indent
:gi "C-e" #'doom/forward-to-last-non-comment-or-eol
;; Standardizes the behavior of modified RET to match the behavior of
;; other editors, particularly Atom, textedit, textmate, and vscode, in
;; which ctrl+RET will add a new "item" below the current one and
;; cmd+RET (Mac) / meta+RET (elsewhere) will add a new, blank line below
;; the current one.
:gni [C-return] #'+default/newline-below
:gni [C-S-return] #'+default/newline-above
(:when IS-MAC
:gni [s-return] #'+default/newline-below
:gni [S-s-return] #'+default/newline-above)
(:unless IS-MAC
:gni [M-return] #'+default/newline-below
:gni [M-S-return] #'+default/newline-above)))
;;
;;; Bootstrap configs
(if (featurep 'evil)
(load! "+evil")
(load! "+emacs"))

View File

@@ -0,0 +1,9 @@
;; -*- no-byte-compile: t; -*-
;;; config/default/packages.el
(package! avy)
(package! ace-link)
(package! drag-stuff)
(unless (featurep! :editor evil)
(package! expand-region))

View File

@@ -0,0 +1,14 @@
;;; config/literate/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defalias '+literate/reload #'doom/reload)
;;;###autoload
(defun +literate-recompile-maybe-h ()
"Recompile config.org if we're editing an org file in our DOOMDIR.
We assume any org file in `doom-private-dir' is connected to your literate
config, and should trigger a recompile if changed."
(when (and (eq major-mode 'org-mode)
(file-in-directory-p buffer-file-name doom-private-dir))
(+literate-tangle 'force)))

View File

@@ -0,0 +1,51 @@
;;; config/literate/init.el -*- lexical-binding: t; -*-
(defvar +literate-config-file
(concat doom-private-dir "config.org")
"The file path of your literate config file.")
(defvar +literate-config-cache-file
(concat doom-cache-dir "literate-last-compile")
"The file path that `+literate-config-file' will be tangled to, then
byte-compiled from.")
;;
(defun +literate-tangle (&optional force-p)
"Tangles `+literate-config-file' if it has changed."
(let ((default-directory doom-private-dir))
(when (or (file-newer-than-file-p +literate-config-file
+literate-config-cache-file)
force-p)
(message "Compiling your literate config...")
(let* ((org (expand-file-name +literate-config-file))
(dest (concat (file-name-sans-extension +literate-config-file) ".el"))
(output (get-buffer-create "*org-tangle*")))
(unwind-protect
;; We tangle in a separate, blank process because loading it here
;; would load all of :lang org (very expensive!).
(or (and (zerop (call-process
"emacs" nil output nil
"-q" "--batch"
"-l" "ob-tangle"
"--eval" (format "(org-babel-tangle-file %S %S)"
org dest)))
(with-current-buffer output
(message "%s" (buffer-string))
t)
;; Write the cache file to serve as our mtime cache
(with-temp-file +literate-config-cache-file
(message "Done!")))
(warn "There was a problem tangling your literate config!"))
(kill-buffer output))))))
;; Let 'er rip!
(+literate-tangle (or doom-reloading-p noninteractive))
;; No need to load the resulting file. Doom will do this for us after all
;; modules have finished loading.
;; Recompile our literate config if we modify it
(after! org
(add-hook 'after-save-hook #'+literate-recompile-maybe-h))