Updates to thoom-emacs

This commit is contained in:
2022-10-04 22:44:24 -07:00
parent c53cc43c23
commit 0c45659f22

View File

@@ -1,3 +1,9 @@
;;; init.el --- Support for the Foo programming language -*- lexical-binding: t; -*-
;;; Commentary:
;;; This is here to shut up the elisp linter.
;;; Code:
;; Install straight.el ;; Install straight.el
(defvar bootstrap-version) (defvar bootstrap-version)
(let ((bootstrap-file (let ((bootstrap-file
@@ -12,53 +18,256 @@
(eval-print-last-sexp))) (eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)) (load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq inhibit-startup-message t (setq inhibit-startup-message t
use-dialog-box nil) use-dialog-box nil)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;; TODO - only on non-Darwin
(menu-bar-mode -1)
(setq custom-file (locate-user-emacs-file "custom-vars.el")) (setq custom-file (locate-user-emacs-file "custom-vars.el"))
(load custom-file 'noerror 'nomessage)
;; Revert buffers when the underlying file has changed ;; Revert buffers when the underlying file has changed
(global-auto-revert-mode 1) (global-auto-revert-mode 1)
(setq global-auto-revert-non-file-buffers t)
;; Remember recent files ;; Remember recent files
(recentf-mode 1) (recentf-mode 1)
;; TODO - bind recentf-open-files
;; Save what you enter into minibuffer prompts ;; Save what you enter into minibuffer prompts
(setq history-length 25) (setq history-length 25)
(savehist-mode 1) (savehist-mode 1)
(straight-use-package
'(nano-emacs :type git :host github :repo "rougier/nano-emacs"))
(require 'nano-layout)
(require 'nano-theme-dark)
(require 'nano-faces)
(require 'nano-theme)
(require 'nano-modeline)
(require 'nano-defaults)
(nano-faces)
(nano-theme)
(hl-line-mode 1) (hl-line-mode 1)
(use-package doom-themes
:straight t
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config))
(use-package vertico
:straight t
:init
(vertico-mode))
(use-package marginalia
:straight t
;; Either bind `marginalia-cycle' globally or only in the minibuffer
:bind (:map minibuffer-local-map
("M-A" . marginalia-cycle))
:init
(marginalia-mode))
(use-package orderless
:straight t
:init
;; Configure a custom style dispatcher (see the Consult wiki)
;; (setq orderless-style-dispatchers '(+orderless-dispatch)
;; orderless-component-separator #'orderless-escapable-split-on-space)
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(use-package consult
:straight t
;; Replace bindings. Lazily loaded due by `use-package'.
:bind (;; C-c bindings (mode-specific-map)
("C-c h" . consult-history)
("C-c m" . consult-mode-command)
("C-c k" . consult-kmacro)
;; C-x bindings (ctl-x-map)
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
("<help> a" . consult-apropos) ;; orig. apropos-command
;; M-g bindings (goto-map)
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings (search-map)
("M-s d" . consult-find)
("M-s D" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s m" . consult-multi-occur)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Configure other variables and modes in the :config section,
;; after lazily loading the package.
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key (kbd "M-."))
;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-theme
:preview-key '(:debounce 0.2 any)
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file consult-xref
consult--source-bookmark consult--source-recent-file
consult--source-project-recent-file
:preview-key (kbd "M-."))
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; (kbd "C-+")
;; Optionally make narrowing help available in the minibuffer.
;; You may want to use `embark-prefix-help-command' or which-key instead.
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
;; By default `consult-project-function' uses `project-root' from project.el.
;; Optionally configure a different project root function.
;; There are multiple reasonable alternatives to chose from.
;;;; 1. project.el (the default)
;; (setq consult-project-function #'consult--default-project--function)
;;;; 2. projectile.el (projectile-project-root)
;; (autoload 'projectile-project-root "projectile")
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
;;;; 3. vc.el (vc-root-dir)
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
;;;; 4. locate-dominating-file
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
)
(use-package embark
:straight t
:bind
(("C-." . embark-act) ;; pick some comfortable binding
("C-;" . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:straight t
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package which-key
:straight t
:init
(which-key-mode)
(which-key-setup-side-window-bottom))
(use-package meow
:straight t
:init
(defun meow-setup ()
"Wow, the elisp linter is pedantic."
(setq meow-use-clipboard t
meow-char-thing-table '((?\( . round)
(?\) . round)
(?\[ . square)
(?\] . square)
(?\{ . curly)
(?\} . curly)
(?\" . string)
(?\' . string)
(?e . symbol)
(?w . window)
(?b . buffer)
(?p . paragraph)
(?l . line)
(?d . defun)
(?. . sentence))
meow-cheatsheet-layout meow-cheatsheet-layout-qwerty
meow-keypad-self-insert-undefined nil)
(add-to-list 'meow-mode-state-list
'(eshell-mode . insert) t)
(straight-use-package 'meow)
(defun meow-setup ()
(setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty)
(meow-motion-overwrite-define-key (meow-motion-overwrite-define-key
'("j" . meow-next) '("j" . meow-next)
'("k" . meow-prev) '("k" . meow-prev)
'("<escape>" . ignore)) '("<escape>" . ignore))
(meow-leader-define-key (meow-leader-define-key
;; SPC j/k will run the original command in MOTION state. ;; SPC j/k will run the original command in MOTION state.
'("j" . "H-j") '("j" . "H-j")
'("k" . "H-k") '("k" . "H-k")
;; Use SPC (0-9) for digit arguments. ;; Use SPC (0-9) for digit arguments.
'("1" . meow-digit-argument) '("1" . meow-digit-argument)
'("2" . meow-digit-argument) '("2" . meow-digit-argument)
@@ -72,8 +281,10 @@
'("0" . meow-digit-argument) '("0" . meow-digit-argument)
'("/" . meow-keypad-describe-key) '("/" . meow-keypad-describe-key)
'("?" . meow-cheatsheet)) '("?" . meow-cheatsheet))
(meow-define-keys 'insert (meow-define-keys 'insert
'("ESC" . meow-insert-exit)) '("ESC" . meow-insert-exit))
(meow-normal-define-key (meow-normal-define-key
'("0" . meow-expand-0) '("0" . meow-expand-0)
'("9" . meow-expand-9) '("9" . meow-expand-9)
@@ -135,10 +346,11 @@
'("z" . meow-pop-selection) '("z" . meow-pop-selection)
'("'" . repeat) '("'" . repeat)
'("/" . meow-comment) '("/" . meow-comment)
'("ESC" . ignore))) '("=" . indent-region)))
(require 'meow)
(meow-setup) (require 'meow)
(meow-global-mode 1) (meow-setup)
(meow-global-mode 1))
;; Meow-tutor notes: ;; Meow-tutor notes:
;; r replaces selection with yank buffer ;; r replaces selection with yank buffer
@@ -154,17 +366,28 @@
;; Why doesn't visit work consistently in beacon mode? ;; Why doesn't visit work consistently in beacon mode?
;; TODO ;; TODO
;; make C-[ work as ESC for exiting insert mode ;; equivalents of evil <, > for indentation
;; use ([{ instead of rsc for brackets and " instead of g for string?
;; equivalents of evil <, >, = for indentation
;; interactive/case insensitive visit? ;; interactive/case insensitive visit?
;; equivalents of evil C-o, C-i ;; equivalents of evil C-o, C-i
;; equivalent of gd/gu ;; equivalent of gd/gu (use embark?)
;; gd = (+lookup/definition)
;; gu = (+lookup/references)
;;
;; equivalent of r ;; equivalent of r
;; equivalent of . for repeating edits
;;
;; learn kmacros ;; learn kmacros
;; learn emacs undo / undo tree
;; bind page up/down, make them act more like vim: center new cursor position, go all the way to the end of file if possible ;; bind page up/down, make them act more like vim: center new cursor position, go all the way to the end of file if possible
;; vim surround ;; vim surround
;; system clipboard integration ;; system clipboard integration
;; cmd-z undo on mac ;; cmd-z undo on mac
;; How the fuck does Emacs' default undo/redo work?
(use-package hl-todo
:straight t
:init
(global-hl-todo-mode))
(provide 'init)
;;; init.el ends here