This commit is contained in:
ry
2022-01-11 18:05:13 -08:00
parent 2046befee2
commit 8e7b654716
846 changed files with 71287 additions and 4 deletions

View File

@@ -0,0 +1,641 @@
;;; config/default/+emacs-bindings.el -*- lexical-binding: t; -*-
;; Sensible default 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> 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/region-and-replace
:desc "Format buffer/region" "f" #'+format/region-or-buffer
:desc "Find implementations" "i" #'+lookup/implementations
:desc "Jump to documentation" "k" #'+lookup/documentation
:desc "Send to repl" "s" #'+eval/send-region-to-repl
:desc "Find type definition" "t" #'+lookup/type-definition
:desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace
:desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines
:desc "List errors" "x" #'+default/diagnostics
(:when (and (featurep! :tools lsp) (not (featurep! :tools lsp +eglot)))
:desc "LSP Code actions" "a" #'lsp-execute-code-action
:desc "LSP Organize imports" "o" #'lsp-organize-imports
:desc "LSP Rename" "r" #'lsp-rename
:desc "LSP" "l" #'+default/lsp-command-map
(:when (featurep! :completion ivy)
:desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol
:desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol)
(:when (featurep! :completion helm)
:desc "Jump to symbol in current workspace" "j" #'helm-lsp-workspace-symbol
:desc "Jump to symbol in any workspace" "J" #'helm-lsp-global-workspace-symbol)
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-lsp-symbols
:desc "Jump to symbol in any workspace" "J" (cmd!! #'consult-lsp-symbols 'all-workspaces))
(:when (featurep! :ui treemacs +lsp)
:desc "Errors list" "X" #'lsp-treemacs-errors-list
:desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy
:desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t)
:desc "References tree" "R" (cmd!! #'lsp-treemacs-references t)
:desc "Symbols" "S" #'lsp-treemacs-symbols))
(:when (featurep! :tools lsp +eglot)
:desc "LSP Execute code action" "a" #'eglot-code-actions
:desc "LSP Rename" "r" #'eglot-rename
:desc "LSP Find declaration" "j" #'eglot-find-declaration
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols)))
;;; <leader> f --- file
(:prefix-map ("f" . "file")
(:when (featurep! :tools editorconfig)
: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" #'doom/find-file-in-emacsd
:desc "Browse emacs.d" "E" #'doom/browse-in-emacsd
:desc "Find file" "f" #'find-file
:desc "Find file from here" "F" #'+default/find-file-under-here
:desc "Locate file" "l" #'locate
:desc "Rename/move this file" "m" #'doom/move-this-file
: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 "Recent project files" "R" #'projectile-recentf
:desc "Sudo this file" "u" #'doom/sudo-this-file
:desc "Sudo find file" "U" #'doom/sudo-find-file
:desc "Yank file path" "y" #'+default/yank-buffer-path
:desc "Yank file path from project" "Y" #'+default/yank-buffer-path-relative-to-project
:desc "Open scratch buffer" "x" #'doom/open-scratch-buffer
:desc "Switch to scratch buffer" "X" #'doom/switch-to-scratch-buffer)
;;; <leader> r --- remote
(:when (featurep! :tools upload)
(:prefix-map ("r" . "remote")
:desc "Browse remote" "b" #'ssh-deploy-browse-remote-base-handler
:desc "Browse relative" "B" #'ssh-deploy-browse-remote-handler
:desc "Download remote" "d" #'ssh-deploy-download-handler
:desc "Delete local & remote" "D" #'ssh-deploy-delete-handler
:desc "Eshell base terminal" "e" #'ssh-deploy-remote-terminal-eshell-base-handler
:desc "Eshell relative terminal" "E" #'ssh-deploy-remote-terminal-eshell-handler
:desc "Move/rename local & remote" "m" #'ssh-deploy-rename-handler
:desc "Open this file on remote" "o" #'ssh-deploy-open-remote-file-handler
:desc "Run deploy script" "s" #'ssh-deploy-run-deploy-script-handler
:desc "Upload local" "u" #'ssh-deploy-upload-handler
:desc "Upload local (force)" "U" #'ssh-deploy-upload-handler-forced
:desc "Diff local & remote" "x" #'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 project for symbol" "." #'+default/search-project-for-symbol-at-point
:desc "Search buffer" "b"
(cond ((featurep! :completion vertico) #'consult-line)
((featurep! :completion ivy) #'swiper)
((featurep! :completion helm) #'swiper))
:desc "Search all open buffers" "B"
(cond ((featurep! :completion vertico) (cmd!! #'consult-line-multi 'all-buffers))
((featurep! :completion ivy) #'swiper-all)
((featurep! :completion helm) #'swiper-all))
:desc "Search current directory" "d" #'+default/search-cwd
:desc "Search other directory" "D" #'+default/search-other-cwd
:desc "Search .emacs.d" "e" #'+default/search-emacsd
:desc "Locate file" "f" #'+lookup/file
:desc "Jump to symbol" "i" #'imenu
:desc "Jump to visible link" "l" #'link-hint-open-link
:desc "Jump to link" "L" #'ffap-menu
:desc "Jump to bookmark" "m" #'bookmark-jump
: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" #'+default/search-buffer
:desc "Search buffer for thing at point" "S"
(cond ((featurep! :completion vertico) #'+vertico/search-symbol-at-point)
((featurep! :completion ivy) #'swiper-isearch-thing-at-point)
((featurep! :completion helm) #'swiper-isearch-thing-at-point))
:desc "Dictionary" "t" #'+lookup/dictionary-definition
:desc "Thesaurus" "T" #'+lookup/synonyms)
;;; <leader> i --- insert
(:prefix-map ("i" . "insert")
:desc "Emoji" "e" #'emojify-insert-emoji
:desc "Current file name" "f" #'+default/insert-file-path
:desc "Current file path" "F" (cmd!! #'+default/insert-file-path t)
:desc "Snippet" "s" #'yas-insert-snippet
:desc "Unicode" "u" #'insert-char
: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
(:when (featurep! :tools biblio)
:desc "Bibliographic entries" "b"
(cond ((featurep! :completion vertico) #'citar-open-entry)
((featurep! :completion ivy) #'ivy-bibtex)
((featurep! :completion helm) #'helm-bibtex)))
:desc "Toggle last org-clock" "c" #'+org/toggle-last-clock
:desc "Cancel current org-clock" "C" #'org-clock-cancel
:desc "Open deft" "d" #'deft
(:when (featurep! :lang org +noter)
:desc "Org noter" "e" #'org-noter)
: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 "Goto capture" "N" #'org-capture-goto-target
: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 "New Scheduled Entry" "J" #'org-journal-new-scheduled-entry
:desc "Search Forever" "s" #'org-journal-search-forever))
(:when (featurep! :lang org +roam)
(:prefix ("r" . "roam")
:desc "Switch to buffer" "b" #'org-roam-switch-to-buffer
:desc "Org Roam Capture" "c" #'org-roam-capture
:desc "Find file" "f" #'org-roam-find-file
:desc "Show graph" "g" #'org-roam-graph
:desc "Insert" "i" #'org-roam-insert
:desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate
:desc "Org Roam" "r" #'org-roam
:desc "Tag" "t" #'org-roam-tag-add
:desc "Un-tag" "T" #'org-roam-tag-delete
(:prefix ("d" . "by date")
:desc "Arbitrary date" "d" #'org-roam-dailies-find-date
:desc "Today" "t" #'org-roam-dailies-find-today
:desc "Tomorrow" "m" #'org-roam-dailies-find-tomorrow
:desc "Yesterday" "y" #'org-roam-dailies-find-yesterday)))
(:when (featurep! :lang org +roam2)
(:prefix ("r" . "roam")
:desc "Open random node" "a" #'org-roam-node-random
:desc "Find node" "f" #'org-roam-node-find
:desc "Find ref" "F" #'org-roam-ref-find
:desc "Show graph" "g" #'org-roam-graph
:desc "Insert node" "i" #'org-roam-node-insert
:desc "Capture to node" "n" #'org-roam-capture
:desc "Toggle roam buffer" "r" #'org-roam-buffer-toggle
:desc "Launch roam buffer" "R" #'org-roam-buffer-display-dedicated
:desc "Sync database" "s" #'org-roam-db-sync
(:prefix ("d" . "by date")
:desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note
:desc "Goto date" "d" #'org-roam-dailies-goto-date
:desc "Capture date" "D" #'org-roam-dailies-capture-date
:desc "Goto next note" "f" #'org-roam-dailies-goto-next-note
:desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow
:desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow
:desc "Capture today" "n" #'org-roam-dailies-capture-today
:desc "Goto today" "t" #'org-roam-dailies-goto-today
:desc "Capture today" "T" #'org-roam-dailies-capture-today
:desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday
:desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday
:desc "Find directory" "-" #'org-roam-dailies-find-directory))))
;;; <leader> o --- open
"o" nil ; we need to unbind it first as Org claims this prefix
(:prefix-map ("o" . "open")
:desc "Browser" "b" #'browse-url-of-file
:desc "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 rsidebar" "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! :os 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
:desc "Open in iTerm" "i" #'+macos/open-in-iterm)
(:when (featurep! :tools docker)
:desc "Docker" "D" #'docker)
(:when (featurep! :email mu4e)
:desc "mu4e" "m" #'=mu4e)
(:when (featurep! :email notmuch)
:desc "notmuch" "m" #'=notmuch)
(:when (featurep! :email wanderlust)
:desc "wanderlust" "m" #'=wanderlust))
;;; <leader> p --- project
(:prefix ("p" . "project")
:desc "Search project for symbol" "." #'+default/search-project-for-symbol-at-point
:desc "Find file in other project" "F" #'doom/find-file-in-other-project
:desc "Search project" "s" #'+default/search-project
:desc "List project todos" "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
(:when (and (featurep! :tools taskrunner)
(or (featurep! :completion ivy)
(featurep! :completion helm)))
:desc "List project tasks" "z" #'+taskrunner/project-tasks)
;; later expanded by projectile
(:prefix ("4" . "in other window"))
(:prefix ("5" . "in other frame")))
;;; <leader> q --- quit/restart
(:prefix-map ("q" . "quit/restart")
: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" #'kill-emacs
:desc "Save and quit Emacs" "Q" #'save-buffers-kill-terminal
: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> & --- 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)
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")
:desc "Big mode" "b" #'doom-big-font-mode
:desc "Fill Column Indicator" "c" #'global-display-fill-column-indicator-mode
:desc "Flymake" "f" #'flymake-mode
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
:desc "Indent style" "I" #'doom/toggle-indent-style
:desc "Line numbers" "l" #'doom/toggle-line-numbers
:desc "Soft line wrapping" "w" #'visual-line-mode
(:when (featurep! :editor word-wrap)
:desc "Soft line wrapping" "w" #'+word-wrap-mode)
(:when (featurep! :checkers syntax)
:desc "Flycheck" "f" #'flycheck-mode)
(:when (featurep! :ui indent-guides)
:desc "Indent guides" "i" #'highlight-indent-guides-mode)
(:when (featurep! :ui minimap)
:desc "Minimap mode" "m" #'minimap-mode)
(:when (featurep! :lang org +present)
:desc "org-tree-slide mode" "p" #'org-tree-slide-mode)
:desc "Read-only mode" "r" #'read-only-mode
(:when (and (featurep! :checkers spell) (not (featurep! :checkers spell +flyspell)))
:desc "Spell checker" "s" #'spell-fu-mode)
(:when (featurep! :checkers spell +flyspell)
:desc "Spell checker" "s" #'flyspell-mode)
(:when (featurep! :lang org +pomodoro)
:desc "Pomodoro timer" "t" #'org-pomodoro)
(:when (featurep! :ui zen)
:desc "Zen mode" "z" #'+zen/toggle
:desc "Zen mode (fullscreen)" "Z" #'+zen/toggle-fullscreen))
;;; <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
: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 "Magit file dispatch" "." #'magit-file-dispatch
:desc "Forge dispatch" "'" #'forge-dispatch
:desc "Magit status" "g" #'magit-status
:desc "Magit status here" "G" #'magit-status-here
: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-buffer-file
: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
: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")
(:when (featurep! :ui workspaces)
:desc "Display workspaces" "d" #'+workspace/display
:desc "Rename workspace" "r" #'+workspace/rename
:desc "Create workspace" "c" #'+workspace/new
:desc "Create named workspace" "C" #'+workspace/new-named
:desc "Delete workspace" "k" #'+workspace/delete
:desc "Save workspace" "S" #'+workspace/save
:desc "Switch to other workspace" "o" #'+workspace/other
: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)
:desc "Autosave session" "a" #'doom/quicksave-session
:desc "Save session" "s" #'doom/save-session
:desc "Load session" "l" #'doom/load-session
:desc "Load last autosaved session" "L" #'doom/quickload-session
:desc "Undo window config" "u" #'winner-undo
:desc "Redo window config" "U" #'winner-redo)
;;; <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)
(:when (featurep! :completion vertico)
:desc "Jump to channel" "j" #'+irc/vertico-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
"M-+" #'doom/reset-font-size
"M-=" #'doom/increase-font-size
"M--" #'doom/decrease-font-size
;;; 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)
(:when (featurep! :completion vertico)
"C-S-r" #'vertico-repeat)
;;; objed
(:when (featurep! :editor objed +manual)
"M-SPC" #'objed-activate)
;;; buffer management
"C-x b" #'switch-to-buffer
"C-x 4 b" #'switch-to-buffer-other-window
(:when (featurep! :ui workspaces)
"C-x b" #'persp-switch-to-buffer
"C-x B" #'switch-to-buffer
"C-x 4 B" #'switch-to-buffer-other-window
(:when (featurep! :completion ivy)
"C-x 4 b" #'+ivy/switch-workspace-buffer-other-window))
"C-x C-b" #'ibuffer
"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" (cond ((featurep! :completion vertico) #'completion-at-point)
((featurep! :completion ivy) #'counsel-company)
((featurep! :completion helm) #'helm-company))
"C-<return>" (cond ((featurep! :completion vertico) #'completion-at-point)
((featurep! :completion ivy) #'counsel-company)
((featurep! :completion helm) #'helm-company))
:map company-search-map
"C-n" #'company-search-repeat-forward
"C-p" #'company-search-repeat-backward
"C-s" (cmd! (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" #'link-hint-open-link
">" #'help-go-forward
"<" #'help-go-back
"n" #'forward-button
"p" #'backward-button)
(:after helpful
:map helpful-mode-map
"o" #'link-hint-open-link)
(:after apropos
:map apropos-mode-map
"o" #'link-hint-open-link
"n" #'forward-button
"p" #'backward-button)
(:after info
:map Info-mode-map
"o" #'link-hint-open-link)
;;; 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)
;;; 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-n" #'sp-next-sexp
"C-M-p" #'sp-previous-sexp
"C-M-u" #'sp-up-sexp
"C-M-d" #'sp-down-sexp
"C-M-k" #'sp-kill-sexp
"C-M-t" #'sp-transpose-sexp
"C-M-<backspace>" #'sp-splice-sexp)
;;; treemacs
(:when (featurep! :ui treemacs)
"<f9>" #'+treemacs/toggle
"<C-f9>" #'treemacs-find-file))
(map! :leader
(:when (featurep! :editor fold)
(:prefix ("C-f" . "fold")
"C-d" #'vimish-fold-delete
"C-a C-d" #'vimish-fold-delete-all
"C-f" #'+fold/toggle
"C-a C-f" #'+fold/close-all
"C-u" #'+fold/open
"C-a C-u" #'+fold/open-all)))

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 (&rest _)
"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,770 @@
;;; config/default/+bindings.el -*- lexical-binding: t; -*-
(when (featurep! :editor evil +everywhere)
;; NOTE SPC u replaces C-u as the universal argument.
;; Minibuffer
(map! :map (evil-ex-completion-map evil-ex-search-keymap)
"C-a" #'evil-beginning-of-line
"C-b" #'evil-backward-char
"C-f" #'evil-forward-char
:gi "C-j" #'next-complete-history-element
:gi "C-k" #'previous-complete-history-element)
(define-key! :keymaps +default-minibuffer-maps
[escape] #'abort-recursive-edit
"C-a" #'move-beginning-of-line
"C-r" #'evil-paste-from-register
"C-u" #'evil-delete-back-to-indentation
"C-v" #'yank
"C-w" #'doom/delete-backward-word
"C-z" (cmd! (ignore-errors (call-interactively #'undo))))
(define-key! :keymaps +default-minibuffer-maps
"C-j" #'next-line
"C-k" #'previous-line
"C-S-j" #'scroll-up-command
"C-S-k" #'scroll-down-command)
;; For folks with `evil-collection-setup-minibuffer' enabled
(define-key! :states 'insert :keymaps +default-minibuffer-maps
"C-j" #'next-line
"C-k" #'previous-line)
(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] (cmds! (and (featurep! :editor snippets)
(yas-maybe-expand-abbrev-key-filter 'yas-expand))
#'yas-expand
(and (bound-and-true-p company-mode)
(featurep! :completion company +tng))
#'company-indent-or-complete-common)
:m [tab] (cmds! (and (featurep! :editor snippets)
(evil-visual-state-p)
(or (eq evil-visual-selection 'line)
(not (memq (char-after) (list ?\( ?\[ ?\{ ?\} ?\] ?\))))))
#'yas-insert-snippet
(and (featurep! :editor fold)
(save-excursion (end-of-line) (invisible-p (point))))
#'+fold/toggle
;; Fixes #4548: without this, this tab keybind overrides
;; mode-local ones for modes that don't have an evil
;; keybinding scheme or users who don't have :editor (evil
;; +everywhere) enabled.
(or (doom-lookup-key
[tab]
(list (evil-get-auxiliary-keymap (current-local-map) evil-state)
(current-local-map)))
(doom-lookup-key
(kbd "TAB")
(list (evil-get-auxiliary-keymap (current-local-map) evil-state)))
(doom-lookup-key (kbd "TAB") (list (current-local-map))))
it
(fboundp 'evil-jump-item)
#'evil-jump-item)
(:after help :map help-mode-map
:n "o" #'link-hint-open-link)
(:after helpful :map helpful-mode-map
:n "o" #'link-hint-open-link)
(:after info :map Info-mode-map
:n "o" #'link-hint-open-link)
(:after apropos :map apropos-mode-map
:n "o" #'link-hint-open-link
: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)
(:after geiser-doc :map geiser-doc-mode-map
:n "o" #'link-hint-open-link)
(:unless (featurep! :input layout +bepo)
(:after (evil-org evil-easymotion)
:map evil-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" #'+multiple-cursors/evil-mc-undo-cursor
:nv "z" #'+multiple-cursors/evil-mc-toggle-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-@" (cmds! (not (minibufferp)) #'company-complete-common)
:i "C-SPC" (cmds! (not (minibufferp)) #'company-complete-common)
(: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 vertico) #'completion-at-point)
((featurep! :completion ivy) #'counsel-company)
((featurep! :completion helm) #'helm-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-filter-candidates
[escape] #'company-search-abort)))
(: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
[remap next-line] #'helm-next-line
[remap previous-line] #'helm-previous-line
[left] #'left-char
[right] #'right-char
"C-S-f" #'helm-previous-page
"C-S-n" #'helm-next-source
"C-S-p" #'helm-previous-source
(:when (featurep! :editor evil +everywhere)
"C-j" #'helm-next-line
"C-k" #'helm-previous-line
"C-S-j" #'helm-next-source
"C-S-k" #'helm-previous-source)
"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))
(:when (featurep! :completion vertico)
(:after vertico
:map vertico-map
"M-RET" #'vertico-exit-input
"C-SPC" #'+vertico/embark-preview
"C-j" #'vertico-next
"C-M-j" #'vertico-next-group
"C-k" #'vertico-previous
"C-M-k" #'vertico-previous-group)))
;;; :ui
(map! (:when (featurep! :ui popup)
"C-`" #'+popup/toggle
"C-~" #'+popup/raise
"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 "]r" #'rotate-text
:n "[r" #'rotate-text-backward)
(: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-mode-map
:nv "M-d" #'evil-multiedit-match-and-next
:nv "M-D" #'evil-multiedit-match-and-prev
[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 vertico) #'vertico-repeat)
((featurep! :completion ivy) #'ivy-resume)
((featurep! :completion helm) #'helm-resume))
:desc "Search for symbol in project" "*" #'+default/search-project-for-symbol-at-point
:desc "Search project" "/" #'+default/search-project
: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 "New named workspace" "N" #'+workspace/new-named
: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 "Clone buffer" "c" #'clone-indirect-buffer
:desc "Clone buffer other window" "C" #'clone-indirect-buffer-other-window
: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 "Set bookmark" "m" #'bookmark-set
:desc "Delete bookmark" "M" #'bookmark-delete
: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 "Save buffer as root" "u" #'doom/sudo-save-buffer
: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")
(:when (and (featurep! :tools lsp) (not (featurep! :tools lsp +eglot)))
:desc "LSP Execute code action" "a" #'lsp-execute-code-action
:desc "LSP Organize imports" "o" #'lsp-organize-imports
(:when (featurep! :completion ivy)
:desc "Jump to symbol in current workspace" "j" #'lsp-ivy-workspace-symbol
:desc "Jump to symbol in any workspace" "J" #'lsp-ivy-global-workspace-symbol)
(:when (featurep! :completion helm)
:desc "Jump to symbol in current workspace" "j" #'helm-lsp-workspace-symbol
:desc "Jump to symbol in any workspace" "J" #'helm-lsp-global-workspace-symbol)
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-lsp-symbols
:desc "Jump to symbol in any workspace" "J" (cmd!! #'consult-lsp-symbols 'all-workspaces))
(:when (featurep! :ui treemacs +lsp)
:desc "Errors list" "X" #'lsp-treemacs-errors-list
:desc "Incoming call hierarchy" "y" #'lsp-treemacs-call-hierarchy
:desc "Outgoing call hierarchy" "Y" (cmd!! #'lsp-treemacs-call-hierarchy t)
:desc "References tree" "R" (cmd!! #'lsp-treemacs-references t)
:desc "Symbols" "S" #'lsp-treemacs-symbols)
:desc "LSP" "l" #'+default/lsp-command-map
:desc "LSP Rename" "r" #'lsp-rename)
(:when (featurep! :tools lsp +eglot)
:desc "LSP Execute code action" "a" #'eglot-code-actions
:desc "LSP Rename" "r" #'eglot-rename
:desc "LSP Find declaration" "j" #'eglot-find-declaration
(:when (featurep! :completion vertico)
:desc "Jump to symbol in current workspace" "j" #'consult-eglot-symbols))
: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 "Find implementations" "i" #'+lookup/implementations
:desc "Jump to documentation" "k" #'+lookup/documentation
:desc "Send to repl" "s" #'+eval/send-region-to-repl
:desc "Find type definition" "t" #'+lookup/type-definition
:desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace
:desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines
:desc "List errors" "x" #'+default/diagnostics)
;;; <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" #'+default/dired
:desc "Delete this file" "D" #'doom/delete-this-file
:desc "Find file in emacs.d" "e" #'doom/find-file-in-emacsd
:desc "Browse emacs.d" "E" #'doom/browse-in-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 file path" "y" #'+default/yank-buffer-path
:desc "Yank file path from project" "Y" #'+default/yank-buffer-path-relative-to-project)
;;; <leader> g --- git/version control
(:prefix-map ("g" . "git")
:desc "Revert file" "R" #'vc-revert
:desc "Copy link to remote" "y" #'+vc/browse-at-remote-kill
:desc "Copy link to homepage" "Y" #'+vc/browse-at-remote-kill-homepage
(:when (featurep! :ui hydra)
:desc "SMerge" "m" #'+vc/smerge-hydra/body)
(:when (featurep! :ui vc-gutter)
(:when (featurep! :ui hydra)
:desc "VCGutter" "." #'+vc/gutter-hydra/body)
:desc "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 "Magit file dispatch" "." #'magit-file-dispatch
:desc "Forge dispatch" "'" #'forge-dispatch
:desc "Magit switch branch" "b" #'magit-branch-checkout
:desc "Magit status" "g" #'magit-status
:desc "Magit status here" "G" #'magit-status-here
: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-buffer-file
: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
: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 "Emoji" "e" #'emojify-insert-emoji
:desc "Current file name" "f" #'+default/insert-file-path
:desc "Current file path" "F" (cmd!! #'+default/insert-file-path t)
:desc "Evil ex path" "p" (cmd! (evil-ex "R!echo "))
:desc "From evil register" "r" #'evil-show-registers
:desc "Snippet" "s" #'yas-insert-snippet
:desc "Unicode" "u" #'insert-char
: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
(:when (featurep! :tools biblio)
:desc "Bibliographic entries" "b"
(cond ((featurep! :completion vertico) #'citar-open-entry)
((featurep! :completion ivy) #'ivy-bibtex)
((featurep! :completion helm) #'helm-bibtex)))
:desc "Toggle last org-clock" "c" #'+org/toggle-last-clock
:desc "Cancel current org-clock" "C" #'org-clock-cancel
:desc "Open deft" "d" #'deft
(:when (featurep! :lang org +noter)
:desc "Org noter" "e" #'org-noter)
: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 "Goto capture" "N" #'org-capture-goto-target
: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 +roam)
(:prefix ("r" . "roam")
:desc "Switch to buffer" "b" #'org-roam-switch-to-buffer
:desc "Org Roam Capture" "c" #'org-roam-capture
:desc "Find file" "f" #'org-roam-find-file
:desc "Show graph" "g" #'org-roam-graph
:desc "Insert" "i" #'org-roam-insert
:desc "Insert (skipping org-capture)" "I" #'org-roam-insert-immediate
:desc "Org Roam" "r" #'org-roam
(:prefix ("d" . "by date")
:desc "Arbitrary date" "d" #'org-roam-dailies-find-date
:desc "Today" "t" #'org-roam-dailies-find-today
:desc "Tomorrow" "m" #'org-roam-dailies-find-tomorrow
:desc "Yesterday" "y" #'org-roam-dailies-find-yesterday)))
(:when (featurep! :lang org +roam2)
(:prefix ("r" . "roam")
:desc "Open random node" "a" #'org-roam-node-random
:desc "Find node" "f" #'org-roam-node-find
:desc "Find ref" "F" #'org-roam-ref-find
:desc "Show graph" "g" #'org-roam-graph
:desc "Insert node" "i" #'org-roam-node-insert
:desc "Capture to node" "n" #'org-roam-capture
:desc "Toggle roam buffer" "r" #'org-roam-buffer-toggle
:desc "Launch roam buffer" "R" #'org-roam-buffer-display-dedicated
:desc "Sync database" "s" #'org-roam-db-sync
(:prefix ("d" . "by date")
:desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note
:desc "Goto date" "d" #'org-roam-dailies-goto-date
:desc "Capture date" "D" #'org-roam-dailies-capture-date
:desc "Goto next note" "f" #'org-roam-dailies-goto-next-note
:desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow
:desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow
:desc "Capture today" "n" #'org-roam-dailies-capture-today
:desc "Goto today" "t" #'org-roam-dailies-goto-today
:desc "Capture today" "T" #'org-roam-dailies-capture-today
:desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday
:desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday
:desc "Find directory" "-" #'org-roam-dailies-find-directory)))
(:when (featurep! :lang org +journal)
(:prefix ("j" . "journal")
:desc "New Entry" "j" #'org-journal-new-entry
:desc "New Scheduled Entry" "J" #'org-journal-new-scheduled-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 "Select frame" "F" #'select-frame-by-name
: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! :os 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
:desc "Open in iTerm" "i" #'+macos/open-in-iterm)
(:when (featurep! :tools docker)
:desc "Docker" "D" #'docker)
(:when (featurep! :email mu4e)
:desc "mu4e" "m" #'=mu4e)
(:when (featurep! :email notmuch)
:desc "notmuch" "m" #'=notmuch)
(:when (featurep! :email wanderlust)
:desc "wanderlust" "m" #'=wanderlust))
;;; <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 "Async cmd in project root" "&" #'projectile-run-async-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 "Discover projects in folder" "D" #'+default/discover-projects
: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 "List project todos" "t" #'magit-todos-list
:desc "Test project" "T" #'projectile-test-project
:desc "Pop up scratch buffer" "x" #'doom/open-project-scratch-buffer
:desc "Switch to scratch buffer" "X" #'doom/switch-to-project-scratch-buffer
(:when (and (featurep! :tools taskrunner)
(or (featurep! :completion ivy)
(featurep! :completion helm)))
:desc "List project tasks" "z" #'+taskrunner/project-tasks))
;;; <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 "Browse remote" "b" #'ssh-deploy-browse-remote-base-handler
:desc "Browse relative" "B" #'ssh-deploy-browse-remote-handler
:desc "Download remote" "d" #'ssh-deploy-download-handler
:desc "Delete local & remote" "D" #'ssh-deploy-delete-handler
:desc "Eshell base terminal" "e" #'ssh-deploy-remote-terminal-eshell-base-handler
:desc "Eshell relative terminal" "E" #'ssh-deploy-remote-terminal-eshell-handler
:desc "Move/rename local & remote" "m" #'ssh-deploy-rename-handler
:desc "Open this file on remote" "o" #'ssh-deploy-open-remote-file-handler
:desc "Run deploy script" "s" #'ssh-deploy-run-deploy-script-handler
:desc "Upload local" "u" #'ssh-deploy-upload-handler
:desc "Upload local (force)" "U" #'ssh-deploy-upload-handler-forced
:desc "Diff local & remote" "x" #'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"
(cond ((featurep! :completion vertico) #'+default/search-buffer)
((featurep! :completion ivy) #'swiper)
((featurep! :completion helm) #'swiper))
:desc "Search all open buffers" "B"
(cond ((featurep! :completion vertico) (cmd!! #'consult-line-multi 'all-buffers))
((featurep! :completion ivy) #'swiper-all)
((featurep! :completion helm) #'swiper-all))
:desc "Search current directory" "d" #'+default/search-cwd
:desc "Search other directory" "D" #'+default/search-other-cwd
:desc "Search .emacs.d" "e" #'+default/search-emacsd
:desc "Locate file" "f" #'locate
:desc "Jump to symbol" "i" #'imenu
:desc "Jump to visible link" "l" #'link-hint-open-link
:desc "Jump to link" "L" #'ffap-menu
:desc "Jump list" "j" #'evil-show-jumps
:desc "Jump to bookmark" "m" #'bookmark-jump
: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 "Jump to mark" "r" #'evil-show-marks
:desc "Search buffer" "s" #'+default/search-buffer
:desc "Search buffer for thing at point" "S"
(cond ((featurep! :completion vertico) #'+vertico/search-symbol-at-point)
((featurep! :completion ivy) #'swiper-isearch-thing-at-point)
((featurep! :completion helm) #'swiper-isearch-thing-at-point))
:desc "Dictionary" "t" #'+lookup/dictionary-definition
:desc "Thesaurus" "T" #'+lookup/synonyms)
;;; <leader> t --- toggle
(:prefix-map ("t" . "toggle")
:desc "Big mode" "b" #'doom-big-font-mode
:desc "Fill Column Indicator" "c" #'global-display-fill-column-indicator-mode
:desc "Flymake" "f" #'flymake-mode
(:when (featurep! :checkers syntax)
: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! :ui minimap)
:desc "Minimap" "m" #'minimap-mode)
(:when (featurep! :lang org +present)
:desc "org-tree-slide mode" "p" #'org-tree-slide-mode)
:desc "Read-only mode" "r" #'read-only-mode
(:when (and (featurep! :checkers spell) (not (featurep! :checkers spell +flyspell)))
:desc "Spell checker" "s" #'spell-fu-mode)
(:when (featurep! :checkers spell +flyspell)
:desc "Spell checker" "s" #'flyspell-mode)
(:when (featurep! :lang org +pomodoro)
:desc "Pomodoro timer" "t" #'org-pomodoro)
:desc "Soft line wrapping" "w" #'visual-line-mode
(:when (featurep! :editor word-wrap)
:desc "Soft line wrapping" "w" #'+word-wrap-mode)
(:when (featurep! :ui zen)
:desc "Zen mode" "z" #'+zen/toggle
:desc "Zen mode (fullscreen)" "Z" #'+zen/toggle-fullscreen)))
(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,44 @@
#+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-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,68 @@
;; config/default/autoload/default.el -*- lexical-binding: t; -*-
;;;###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 and the platform is not MacOS, otherwise use `woman'.
`man -k \"^\"` is very slow on MacOS, which is what `Man-completion-table' uses to
generate `completing-read' candidates."
(interactive)
(call-interactively
(if (and (not IS-MAC) (executable-find "man"))
#'man
#'woman)))
;;;###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/restart-server ()
"Restart the Emacs server."
(interactive)
(server-force-delete)
(while (server-running-p)
(sleep-for 1))
(server-start))
;;;###autoload
(defun +default/diagnostics (&rest arg)
"List diagnostics for the current buffer/project.
If the the vertico and lsp modules are active, list lsp diagnostics for the
current project. Otherwise list them for the current buffer"
(interactive)
(cond ((and (featurep! :completion vertico)
(featurep! :tools lsp)
(bound-and-true-p lsp-mode))
(consult-lsp-diagnostics arg))
((and (featurep! :checkers syntax)
(bound-and-true-p flycheck-mode))
(flycheck-list-errors))
((bound-and-true-p flymake-mode)
(flymake-show-diagnostics-buffer))
(t
(user-error "No diagnostics backend detected. Enable flycheck or \
flymake, or set up lsp-mode if applicable (see :lang lsp)"))))

View File

@@ -0,0 +1,20 @@
;;; config/default/autoload/deferred.el -*- lexical-binding: t; -*-
;; TODO generalize this
;;;###autoload
(defun +default/lsp-command-map ()
"Lazily invoke `lsp-command-map'."
(interactive)
(require 'lsp-mode)
(map! :leader "c l" lsp-command-map)
(dolist (leader-key (list doom-leader-key doom-leader-alt-key))
(let ((lsp-keymap-prefix (concat leader-key " c l")))
(lsp-enable-which-key-integration)))
(setq prefix-arg current-prefix-arg
unread-command-events
(mapcar (lambda (e) (cons t e))
(vconcat (when (bound-and-true-p evil-this-operator)
(where-is-internal evil-this-operator
evil-normal-state-map
t))
(this-command-keys)))))

View File

@@ -0,0 +1,66 @@
;;; config/default/autoload/files.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +default/browse-project ()
"Browse files from the current project's root."
(interactive) (doom-project-browse (doom-project-root)))
;; NOTE No need for find-in-project, use `projectile-find-file'
;;;###autoload
(defun +default/browse-templates ()
"Browse files from `+file-templates-dir'."
(interactive) (doom-project-browse +file-templates-dir))
;;;###autoload
(defun +default/find-in-templates ()
"Find a file under `+file-templates-dir', recursively."
(interactive) (doom-project-find-file +file-templates-dir))
;;;###autoload
(defun +default/browse-notes ()
"Browse files from `org-directory'."
(interactive)
(unless (bound-and-true-p org-directory)
(require 'org))
(doom-project-browse org-directory))
;;;###autoload
(defun +default/find-in-notes ()
"Find a file under `org-directory', recursively."
(interactive)
(unless (bound-and-true-p org-directory)
(require 'org))
(doom-project-find-file org-directory))
;;;###autoload
(defun +default/find-file-under-here ()
"Perform a recursive file search from the current directory."
(interactive)
(doom-project-find-file default-directory))
;;;###autoload
(defun +default/discover-projects (arg)
"Discover projects in `projectile-project-search-path'.
If prefix ARG is non-nil, prompt for the search path."
(interactive "P")
(if arg
(call-interactively #'projectile-discover-projects-in-directory)
(if (not projectile-project-search-path)
(user-error "`projectile-project-search-path' is empty; don't know where to search")
(letf! (defun projectile-add-known-project (project-root)
(unless (projectile-ignored-project-p project-root)
(funcall projectile-add-known-project project-root)
(message "Added %S to known project roots" project-root)))
(dolist (dir projectile-project-search-path)
(cl-destructuring-bind (dir . depth) (if (consp dir) dir (cons dir nil))
(if (not (file-accessible-directory-p dir))
(message "%S was inaccessible and couldn't be searched" dir)
(projectile-discover-projects-in-directory dir depth))))))))
;;;###autoload
(defun +default/dired (arg)
"Open a directory in dired.
If prefix ARG is non-nil, prompt for a known project to open in dired."
(interactive "P")
(apply #'dired
(if arg
(list (completing-read "Open dired in project: " projectile-known-projects))
(dired-read-dir-and-switches ""))))

View File

@@ -0,0 +1,144 @@
;;; config/default/autoload/search.el -*- lexical-binding: t; -*-
;;;###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)
((featurep! :completion vertico) #'+vertico/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-emacsd ()
"Conduct a text search in files under `user-emacs-directory'."
(interactive)
(let ((default-directory user-emacs-directory))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search-from-cwd)
((featurep! :completion helm) #'+helm/project-search-from-cwd)
((featurep! :completion vertico) #'+vertico/project-search-from-cwd)
(#'rgrep)))))
;;;###autoload
(defun +default/search-buffer ()
"Conduct a text search on the current buffer.
If a selection is active and multi-line, perform a search restricted to that
region.
If a selection is active and not multi-line, use the selection as the initial
input and search the whole buffer for it."
(interactive)
(let (start end multiline-p)
(save-restriction
(when (region-active-p)
(setq start (region-beginning)
end (region-end)
multiline-p (/= (line-number-at-pos start)
(line-number-at-pos end)))
(deactivate-mark)
(when multiline-p
(narrow-to-region start end)))
(cond ((or (featurep! :completion helm)
(featurep! :completion ivy))
(call-interactively
(if (and start end (not multiline-p))
#'swiper-isearch-thing-at-point
#'swiper-isearch)))
((featurep! :completion vertico)
(if (and start end (not multiline-p))
(consult-line
(replace-regexp-in-string
" " "\\\\ "
(rxt-quote-pcre
(buffer-substring-no-properties start end))))
(call-interactively #'consult-line)))))))
;;;###autoload
(defun +default/search-project (&optional arg)
"Conduct a text search in the current project root.
If prefix ARG is set, include ignored/hidden files."
(interactive "P")
(let* ((projectile-project-root nil)
(disabled-command-function nil)
(current-prefix-arg (unless (eq arg 'other) arg))
(default-directory
(if (eq arg 'other)
(if-let (projects (projectile-relevant-known-projects))
(completing-read "Search project: " projects nil t)
(user-error "There are no known projects"))
default-directory)))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search)
((featurep! :completion helm) #'+helm/project-search)
((featurep! :completion vertico) #'+vertico/project-search)
(#'projectile-ripgrep)))))
;;;###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 (symbol dir)
"Search 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 (doom-thing-at-point-or-region) ""))
(let ((projectile-project-root nil))
(if current-prefix-arg
(if-let (projects (projectile-relevant-known-projects))
(completing-read "Search project: " projects nil t)
(user-error "There are no known projects"))
(doom-project-root default-directory)))))
(cond ((featurep! :completion ivy)
(+ivy/project-search nil symbol dir))
((featurep! :completion helm)
(+helm/project-search nil symbol dir))
((featurep! :completion vertico)
(+vertico/project-search nil symbol dir))
((rgrep (regexp-quote symbol)))))
;;;###autoload
(defun +default/search-notes-for-symbol-at-point (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 (doom-thing-at-point-or-region) ""))))
(require 'org)
(+default/search-project-for-symbol-at-point
symbol org-directory))
;;;###autoload
(defun +default/org-notes-search (query)
"Perform a text search on `org-directory'."
(interactive
(list (if (doom-region-active-p)
(buffer-substring-no-properties
(doom-region-beginning)
(doom-region-end))
"")))
(require 'org)
(+default/search-project-for-symbol-at-point
query org-directory))
;;;###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))

View File

@@ -0,0 +1,166 @@
;;; config/default/autoload/text.el -*- lexical-binding: t; -*-
;;;###autoload
(defalias '+default/newline #'electric-indent-just-newline)
;;;###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 'consult-yank-pop) #'consult-yank-pop) ;HACK see @ymarco's comment on #5013 and TODO.org in the selecturm module.
((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, helm or vertico!")))))
;;;###autoload
(defun +default/yank-buffer-path (&optional root)
"Copy the current buffer's path to the kill ring."
(interactive)
(if-let (filename (or (buffer-file-name (buffer-base-buffer))
(bound-and-true-p list-buffers-directory)))
(message "Copied path to clipboard: %s"
(kill-new (abbreviate-file-name
(if root
(file-relative-name filename root)
filename))))
(error "Couldn't find filename in current buffer")))
;;;###autoload
(defun +default/yank-buffer-path-relative-to-project (&optional include-root)
"Copy the current buffer's path to the kill ring.
With non-nil prefix INCLUDE-ROOT, also include the project's root."
(interactive "P")
(+default/yank-buffer-path
(if include-root
(file-name-directory (directory-file-name (doom-project-root)))
(doom-project-root))))
;;;###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)))))
;;;###autoload
(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
(if (bound-and-true-p smartparens-mode)
(ignore-errors (sp-get-thing))))
(op (plist-get context :op))
(cl (plist-get context :cl))
open-len close-len current-column)
(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)
(> tab-width 1)
(not (bolp))
(not (doom-point-in-string-p))
(>= (abs (save-excursion (skip-chars-backward " \t")))
(setq current-column (current-column))))
(delete-char (- (1+ (% (1- current-column) tab-width)))))
;; 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))))
;;
((= n 1)
(cond ((or (not (featurep! +smartparens))
(not (bound-and-true-p smartparens-mode))
(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))))
(delete-char (- (length op))))
((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))))

View File

@@ -0,0 +1,479 @@
;;; config/default/config.el -*- lexical-binding: t; -*-
(defvar +default-want-RET-continue-comments t
"If non-nil, RET will continue commented lines.")
(defvar +default-minibuffer-maps
(append '(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-rg-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
;; the unpredictability of this (when enabled) makes it a poor default
avy-single-candidate-jump nil)
(after! epa
;; With GPG 2.1+, this forces gpg-agent to use the Emacs minibuffer to prompt
;; for the key passphrase.
(set 'epg-pinentry-mode 'loopback)
;; Default to the first secret key available in your keyring.
(setq-default
epa-file-encrypt-to
(or (default-value 'epa-file-encrypt-to)
(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))
;; And suppress prompts if epa-file-encrypt-to has a default value (without
;; overwriting file-local values).
(defadvice! +default--dont-prompt-for-keys-a (&rest _)
:before #'epa-file-write-region
(unless (local-variable-p 'epa-file-encrypt-to)
(setq-local epa-file-encrypt-to (default-value 'epa-file-encrypt-to)))))
(after! woman
;; The woman-manpath default value does not necessarily match man. If we have
;; man available but aren't using it for performance reasons, we can extract
;; it's manpath.
(when (executable-find "man")
(setq woman-manpath
(split-string (cdr (doom-call-process "man" "--path"))
path-separator t))))
(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' 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 don't want to open a new pair or it would unbalance them.
(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"))
;; Don't autopair opening braces if before a word character or
;; other opening brace. The rationale: it interferes with manual
;; balancing of braces, and is odd form to have s-exps with no
;; whitespace in between, e.g. ()()(). Insert whitespace if
;; genuinely want to start a new form in the middle of a word.
: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 "{" "}"
:pre-handlers '(:rem sp-ruby-pre-handler)
:post-handlers '(:rem sp-ruby-post-handler))
;; Don't eagerly escape Swift style string interpolation
(sp-local-pair 'swift-mode "\\(" ")" :when '(sp-in-string-p))
;; 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
(setq-default 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 comment blocks.
(defun +default-open-doc-comments-block (&rest _ignored)
(save-excursion
(newline)
(indent-according-to-mode)))
(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")
(" | " "*")
("|[i]\n[i]" "RET")))
(after! smartparens-ml
(sp-with-modes '(tuareg-mode fsharp-mode)
(sp-local-pair "(*" "*)" :actions nil)
(sp-local-pair "(*" "*"
:actions '(insert)
:post-handlers '(("| " "SPC") ("|[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 "*" (general-predicate-dispatch nil
(looking-at-p "\\*\\* *")
(cmd! (forward-char 2)))))
;; Removes haskell-mode trailing braces
(after! smartparens-haskell
(sp-with-modes '(haskell-mode haskell-interactive-mode)
(sp-local-pair "{-" "-}" :actions :rem)
(sp-local-pair "{-#" "#-}" :actions :rem)
(sp-local-pair "{-@" "@-}" :actions :rem)
(sp-local-pair "{-" "-")
(sp-local-pair "{-#" "#-")
(sp-local-pair "{-@" "@-")))))
;;
;;; Keybinding fixes
;; Highjacks backspace to delete up to nearest column multiple of `tab-width' at
;; a time. If you have smartparens enabled, it will also:
;; a) balance spaces inside brackets/parentheses ( | ) -> (|)
;; b) close empty multiline brace blocks in one step:
;; {
;; |
;; }
;; becomes {|}
;; c) refresh smartparens' :post-handlers, so SPC and RET expansions work even
;; after a backspace.
;; d) properly delete smartparen pairs when they are encountered, without the
;; need for strict mode.
;; e) do none of this when inside a string
(advice-add #'delete-backward-char :override #'+default--delete-backward-char-a)
;; HACK Makes `newline-and-indent' continue comments (and more reliably).
;; Consults `doom-point-in-comment-functions' to detect a commented region
;; and uses that mode's `comment-line-break-function' to continue comments.
;; If neither exists, it will fall back to the normal behavior of
;; `newline-and-indent'.
;;
;; We use an advice here instead of a remapping because many modes define
;; and remap to their own newline-and-indent commands, and tackling all
;; those cases was judged to be more work than dealing with the edge cases
;; on a case by case basis.
(defadvice! +default--newline-indent-and-continue-comments-a (&rest _)
"A replacement for `newline-and-indent'.
Continues comments if executed from a commented line. Consults
`doom-point-in-comment-functions' to determine if in a comment."
:before-until #'newline-and-indent
(interactive "*")
(when (and +default-want-RET-continue-comments
(doom-point-in-comment-p)
(functionp comment-line-break-function))
(funcall comment-line-break-function nil)
t))
;; 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" (if (featurep! :completion vertico) #'consult-line #'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
"s-x" #'execute-extended-command
: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-/" (cmd! (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
"u" #'doom/help-autodefs
"E" #'doom/sandbox
"M" #'doom/describe-active-minor-mode
"O" #'+lookup/online
"T" #'doom/toggle-profiler
"V" #'doom/help-custom-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
"db" #'doom/report-bug
"dc" #'doom/goto-private-config-file
"dC" #'doom/goto-private-init-file
"dd" #'doom-debug-mode
"df" #'doom/help-faq
"dh" #'doom/help
"dl" #'doom/help-search-load-path
"dL" #'doom/help-search-loaded-files
"dm" #'doom/help-modules
"dn" #'doom/help-news
"dN" #'doom/help-search-news
"dpc" #'doom/help-package-config
"dpd" #'doom/goto-private-packages-file
"dph" #'doom/help-package-homepage
"dpp" #'doom/help-packages
"ds" #'doom/help-search-headings
"dS" #'doom/help-search
"dt" #'doom/toggle-profiler
"du" #'doom/help-autodefs
"dv" #'doom/version
"dx" #'doom/sandbox
;; 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/help-packages'
"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/vertico for their superior filtering.
(when-let (command (cond ((featurep! :completion ivy)
#'counsel-minibuffer-history)
((featurep! :completion helm)
#'helm-minibuffer-history)
((featurep! :completion vertico)
#'consult-history)))
(define-key!
:keymaps (append +default-minibuffer-maps
(when (featurep! :editor evil +everywhere)
'(evil-ex-completion-map)))
"C-s" command))
;; 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.
;; C-<mouse-scroll-up> = text scale increase
;; C-<mouse-scroll-down> = text scale decrease
[C-down-mouse-2] (cmd! (text-scale-set 0))
;; auto-indent on newline by default
:gi [remap newline] #'newline-and-indent
;; insert literal newline
:i "S-RET" #'+default/newline
:i [S-return] #'+default/newline
:i "C-j" #'+default/newline
;; Add new item below current (without splitting current line).
:gi "C-RET" #'+default/newline-below
:gn [C-return] #'+default/newline-below
;; Add new item above current (without splitting current line)
:gi "C-S-RET" #'+default/newline-above
:gn [C-S-return] #'+default/newline-above
(:when IS-MAC
:gn "s-RET" #'+default/newline-below
:gn [s-return] #'+default/newline-below
:gn "S-s-RET" #'+default/newline-above
:gn [S-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 :pin "e92cb37457b43336b765630dbfbea8ba4be601fa")
(package! drag-stuff :pin "6d06d846cd37c052d79acd0f372c13006aa7e7c8")
(package! link-hint :pin "3be270f3a732dc4acae6a20ff449eef0c4f9a966")
(unless (featurep! :editor evil)
(package! expand-region :pin "95a773bd8f557cbd43d3b2dab2fa4417ec5927ab"))