Embark, ace-window, smooth scroll, global magit keybindings
This commit is contained in:
parent
770eb65611
commit
bcd3b394a2
@ -87,7 +87,6 @@ Prioritize old byte-compiled source files over newer sources. It saves us a litt
|
||||
(prefer-coding-system 'utf-8)
|
||||
;;; early-init.el ends here
|
||||
#+end_src
|
||||
|
||||
** Straight.el
|
||||
|
||||
For now, use [[https://github.com/radian-software/straight.el][straight.el]] until [[https://github.com/progfolio/elpaca
|
||||
@ -109,7 +108,6 @@ Then bootstrap
|
||||
(eval-print-last-sexp)))
|
||||
(load bootstrap-file nil 'nomessage))
|
||||
#+END_SRC
|
||||
|
||||
** Benchmarking
|
||||
|
||||
This is commented out since it adds ever so slightly to init time, but keep it around in case we
|
||||
@ -120,7 +118,6 @@ need to benchmark slow init times later.
|
||||
(require 'benchmark-init)
|
||||
(add-hook 'after-init-hook 'benchmark-init/deactivate)
|
||||
#+end_src
|
||||
|
||||
** Misc Stuff
|
||||
|
||||
#+begin_SRC emacs-lisp
|
||||
@ -168,7 +165,6 @@ I don't even know how you resume from GUI mode, we'll find a use for this keybin
|
||||
(when (display-graphic-p)
|
||||
(global-unset-key (kbd "C-z")))
|
||||
#+end_src
|
||||
|
||||
** Visuals
|
||||
*** Dashboard
|
||||
|
||||
@ -189,7 +185,6 @@ Use Dashboard.el. First load `all-the-icons` for nicer rendering
|
||||
(setq dashboard-set-heading-icons t)
|
||||
(add-hook 'dashboard-mode-hook (lambda () (setq-local line-spacing 12)))
|
||||
#+end_src
|
||||
|
||||
*** Olivetti
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@ -198,7 +193,6 @@ Use Dashboard.el. First load `all-the-icons` for nicer rendering
|
||||
(setq olivetti-minimum-body-width 100)
|
||||
(global-set-key (kbd "C-x x o") 'olivetti-mode)
|
||||
#+end_src
|
||||
|
||||
*** Themes
|
||||
|
||||
sanityinc-tomorrow-light is really good
|
||||
@ -219,8 +213,6 @@ Save the last used theme when exiting emacs and then reload it.
|
||||
(customize-save-variable 'custom-enabled-themes custom-enabled-themes))
|
||||
(add-hook 'kill-emacs-hook #'joe/save-current-theme)
|
||||
#+end_src
|
||||
|
||||
|
||||
*** Other
|
||||
|
||||
Setup other stuff
|
||||
@ -262,10 +254,11 @@ Setup other stuff
|
||||
(straight-use-package 'nano-modeline)
|
||||
(nano-modeline-mode)
|
||||
#+end_src
|
||||
|
||||
** Text
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(set-face-attribute 'default nil :font "Fira Code Nerd Font" :height 105)
|
||||
(set-face-attribute 'default nil :family "Fira Code Nerd Font Mono" :height 120)
|
||||
;; (set-face-attribute 'variable-pitch nil :family "Source Code Pro" :height 120)
|
||||
|
||||
(setq-default c-basic-offset 4) ;; This is annoying
|
||||
(setq-default indent-tabs-mode nil)
|
||||
@ -277,7 +270,6 @@ Setup other stuff
|
||||
|
||||
(add-hook 'before-save-hook 'whitespace-cleanup)
|
||||
#+end_src
|
||||
|
||||
** Buffers
|
||||
#+begin_src emacs-lisp
|
||||
(defun joe/kill-this-buffer-or-popup ()
|
||||
@ -321,10 +313,8 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
|
||||
(global-set-key (kbd "C-x C-0") 'kill-buffer-and-window)
|
||||
|
||||
#+end_src
|
||||
|
||||
** Windows
|
||||
|
||||
*** Popper
|
||||
*** Window Management
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'after-init-hook (lambda () (winner-mode t)))
|
||||
@ -338,6 +328,14 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
|
||||
|
||||
(define-key ctl-x-4-map (kbd "|") #'joe/window-split-vertical)
|
||||
(define-key ctl-x-4-map (kbd "-") #'joe/window-split-horizontal)
|
||||
(define-key ctl-x-4-map (kbd "t") #'rotate-window)
|
||||
|
||||
(global-set-key (kbd "C-x o") #'ace-window)
|
||||
(global-set-key (kbd "C-x C-o") #'ace-swap-window)
|
||||
#+end_src>
|
||||
*** Popper
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'popper)
|
||||
(require 'popper)
|
||||
(setq popper-reference-buffers
|
||||
@ -374,45 +372,54 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
|
||||
|
||||
(popper-mode t)
|
||||
#+end_src
|
||||
|
||||
*** Scrolling
|
||||
#+begin_src emacs-lisp
|
||||
(require 'pixel-scroll)
|
||||
(setq pixel-scroll-precision-large-scroll-height 10.0)
|
||||
(setq pixel-scroll-precision-interpolation-factor 30)
|
||||
|
||||
|
||||
(defun joe/pixel-scroll-lerp (amount direction)
|
||||
(let ((half-height (* direction (/ (window-height) amount)))
|
||||
(point-min-or-max (if (> direction 0) (point-min) (point-max))))
|
||||
(when (or (and (pos-visible-in-window-p (point-min))
|
||||
(< direction 0)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height))))
|
||||
|
||||
(defun joe/smooth-scroll-half-page-down ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(let ((half-height (/ (window-height) 2)))
|
||||
(pixel-scroll-precision-interpolate (* 5 (- half-height)))))
|
||||
(joe/pixel-scroll-lerp 2 -1))
|
||||
;; (pixel-scroll-kbd-up))
|
||||
|
||||
(defun joe/smooth-scroll-half-page-up ()
|
||||
"Smooth scroll down"
|
||||
"Smooth scroll up"
|
||||
(interactive)
|
||||
(let ((half-height (/ (window-height) 2)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height))))
|
||||
(joe/pixel-scroll-lerp 2 1))
|
||||
|
||||
(defun joe/smooth-scroll-short-down ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(let ((half-height (/ (window-height) 6)))
|
||||
(pixel-scroll-precision-interpolate (* 5 (- half-height)))))
|
||||
(joe/pixel-scroll-lerp 6 -1))
|
||||
|
||||
(defun joe/smooth-scroll-short-up ()
|
||||
"Smooth scroll down"
|
||||
(interactive)
|
||||
(let ((half-height (/ (window-height) 6)))
|
||||
(pixel-scroll-precision-interpolate (* 5 half-height))))
|
||||
(joe/pixel-scroll-lerp 6 1))
|
||||
|
||||
;; scroll-up-command
|
||||
(global-set-key (kbd "C-v") #'joe/smooth-scroll-half-page-down)
|
||||
(global-set-key (kbd "M-v") #'joe/smooth-scroll-half-page-up)
|
||||
#+end_src
|
||||
(global-set-key (kbd "C-S-v") #'joe/smooth-scroll-short-down)
|
||||
(global-set-key (kbd "M-S-v") #'joe/smooth-scroll-short-up)
|
||||
|
||||
#+end_src
|
||||
** Org Mode
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'org-bullets)
|
||||
|
||||
(defun joe/org-init ()
|
||||
(setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG")))
|
||||
(setq org-agenda-files '("~/todo.org"))
|
||||
@ -422,28 +429,38 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun
|
||||
(setq org-edit-src-content-indentation 0))
|
||||
(with-eval-after-load 'org (joe/org-init))
|
||||
|
||||
(setq org-blank-before-new-entry
|
||||
'((heading . nil)
|
||||
(plain-list-item . nil)))
|
||||
(setq org-cycle-separator-lines 1)
|
||||
(setq org-hide-emphasis-markers t)
|
||||
(setq org-src-window-setup 'current-window)
|
||||
|
||||
(defun joe/org-hook ()
|
||||
(local-set-key (kbd "C-. C-i") 'consult-org-heading)
|
||||
(org-bullets-mode)
|
||||
(org-indent-mode))
|
||||
(add-hook 'org-mode-hook 'joe/org-hook)
|
||||
#+end_src
|
||||
|
||||
** VEMCO
|
||||
|
||||
Vertico Embark Marginalia Consult Orderless
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'all-the-icons-completion)
|
||||
(straight-use-package '(vertico :files (:defaults "extensions/*") :includes (vertico-directory vertico-reverse)))
|
||||
;; :bind (:map vertico-map
|
||||
;; ("\M-G" . vertico-multiform-mode)
|
||||
;; ("\M-e" . embark-act)))
|
||||
|
||||
(straight-use-package '(vertico :files (:defaults "extensions/*")
|
||||
:includes (vertico-indexed
|
||||
vertico-repeat
|
||||
vertico-directory)))
|
||||
|
||||
(vertico-mode)
|
||||
(straight-use-package 'vertico-posframe)
|
||||
|
||||
(define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word)
|
||||
(define-key vertico-map (kbd "C-r") #'vertico-repeat-)
|
||||
|
||||
(vertico-posframe-mode t)
|
||||
(vertico-indexed-mode)
|
||||
(setq vertico-posframe-parameters
|
||||
'((left-fringe . 100)
|
||||
(right-fringe . 100)))
|
||||
@ -461,8 +478,14 @@ Vertico Embark Marginalia Consult Orderless
|
||||
vertico-resize nil
|
||||
vertico-cycle t)
|
||||
|
||||
(define-key vertico-map (kbd "C-M-n") #'vertico-next-group)
|
||||
;; #' "C-M-p" #'vertico-previous-group)
|
||||
|
||||
(require 'savehist)
|
||||
(savehist-mode)
|
||||
(add-hook 'minibuffer-setup-hook #'vertico-repeat-save)
|
||||
(add-to-list 'savehist-additional-variables 'vertico-repeat-history)
|
||||
|
||||
(straight-use-package 'vertico-directory)
|
||||
;; :bind (:map vertico-map
|
||||
;; ("RET" . vertico-directory-enter)
|
||||
@ -471,11 +494,69 @@ Vertico Embark Marginalia Consult Orderless
|
||||
;; :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
|
||||
|
||||
(straight-use-package 'embark)
|
||||
|
||||
(defvar joe-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-'") #'embark-act)
|
||||
(define-key map (kbd "M-'") #'embark-dwim)
|
||||
map)
|
||||
"my-keys-minor-mode keymap.")
|
||||
|
||||
(define-minor-mode joe-mode
|
||||
"A minor mode so that my key settings override annoying major modes."
|
||||
:init-value t
|
||||
:lighter " joe-keys")
|
||||
|
||||
(joe-mode t)
|
||||
|
||||
(defun embark-which-key-indicator ()
|
||||
"An embark indicator that displays keymaps using which-key.
|
||||
The which-key help message will show the type and value of the
|
||||
current target followed by an ellipsis if there are further
|
||||
targets."
|
||||
(lambda (&optional keymap targets prefix)
|
||||
(if (null keymap)
|
||||
(which-key--hide-popup-ignore-command)
|
||||
(which-key--show-keymap
|
||||
(if (eq (plist-get (car targets) :type) 'embark-become)
|
||||
"Become"
|
||||
(format "Act on %s '%s'%s"
|
||||
(plist-get (car targets) :type)
|
||||
(embark--truncate-target (plist-get (car targets) :target))
|
||||
(if (cdr targets) "…" "")))
|
||||
(if prefix
|
||||
(pcase (lookup-key keymap prefix 'accept-default)
|
||||
((and (pred keymapp) km) km)
|
||||
(_ (key-binding prefix 'accept-default)))
|
||||
keymap)
|
||||
nil nil t (lambda (binding)
|
||||
(not (string-suffix-p "-argument" (cdr binding))))))))
|
||||
|
||||
(setq embark-indicators
|
||||
'(embark-which-key-indicator
|
||||
embark-highlight-indicator
|
||||
embark-isearch-highlight-indicator))
|
||||
|
||||
(defun embark-hide-which-key-indicator (fn &rest args)
|
||||
"Hide the which-key indicator immediately when using the completing-read prompter."
|
||||
(which-key--hide-popup-ignore-command)
|
||||
(let ((embark-indicators
|
||||
(remq #'embark-which-key-indicator embark-indicators)))
|
||||
(apply fn args)))
|
||||
|
||||
(advice-add #'embark-completing-read-prompter
|
||||
:around #'embark-hide-which-key-indicator)
|
||||
|
||||
(global-set-key (kbd "C-'") #'embark-act)
|
||||
|
||||
(straight-use-package 'embark-consult)
|
||||
|
||||
(straight-use-package 'marginalia)
|
||||
(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
|
||||
(setq marginalia-align 'right)
|
||||
(setq marginalia-max-relative-age most-positive-fixnum)
|
||||
(marginalia-mode)
|
||||
(define-key minibuffer-local-map (kbd "M-A") #'marginalia-cycle)
|
||||
(require 'all-the-icons-completion)
|
||||
(all-the-icons-completion-mode)
|
||||
(all-the-icons-completion-marginalia-setup)
|
||||
@ -496,7 +577,6 @@ Vertico Embark Marginalia Consult Orderless
|
||||
(global-set-key (kbd "C-. C-r") 'consult-recent-file)
|
||||
(global-set-key (kbd "C-. C-y") 'consult-yank-from-kill-ring)
|
||||
#+end_src
|
||||
|
||||
** Avy
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@ -510,7 +590,6 @@ Vertico Embark Marginalia Consult Orderless
|
||||
(define-key global-map (kbd "M-g w") 'avy-goto-word-1) ;; first character of the word
|
||||
(define-key global-map (kbd "M-g P") 'avy-pop-mark)
|
||||
#+end_src
|
||||
|
||||
** Helpful
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'helpful)
|
||||
@ -521,7 +600,6 @@ Vertico Embark Marginalia Consult Orderless
|
||||
(global-set-key (kbd "C-h F") #'helpful-function)
|
||||
(global-set-key (kbd "C-h C") #'helpful-command)
|
||||
#+end_src
|
||||
|
||||
** Dirvish/Dired
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'dirvish)
|
||||
@ -556,6 +634,7 @@ Vertico Embark Marginalia Consult Orderless
|
||||
|
||||
(define-key dirvish-mode-map (kbd "C-c f") #'dirvish-fd)
|
||||
(define-key dirvish-mode-map (kbd "a" ) #'dirvish-quick-access)
|
||||
(define-key dirvish-mode-map (kbd "." ) #'dired-create-empty-file)
|
||||
(define-key dirvish-mode-map (kbd "f" ) #'dirvish-file-info-menu)
|
||||
(define-key dirvish-mode-map (kbd "y" ) #'dirvish-yank-menu)
|
||||
(define-key dirvish-mode-map (kbd "N" ) #'dirvish-narrow)
|
||||
@ -577,7 +656,6 @@ Vertico Embark Marginalia Consult Orderless
|
||||
(global-set-key (kbd "C-x C-d") #'joe/dirvish-find-directory)
|
||||
|
||||
#+end_src
|
||||
|
||||
** Terminals/Shells
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'vterm)
|
||||
@ -603,6 +681,9 @@ Vertico Embark Marginalia Consult Orderless
|
||||
|
||||
(global-set-key (kbd "C-c t") #'vterm)
|
||||
(global-set-key (kbd "C-c T") #'joe/vterm-here)
|
||||
;; (setq explicit-shell-file-name "~/Development/fell/fell")
|
||||
(add-hook 'shell-mode (lambda () (setq-local global-hl-line-mode nil)))
|
||||
(setq shell-kill-buffer-on-exit t)
|
||||
|
||||
(add-hook 'vterm-mode-hook (lambda () (setq-local global-hl-line-mode nil)))
|
||||
#+end_src
|
||||
@ -613,7 +694,6 @@ down init time because vterm is loading TRAMP which is slow.
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'emacs-startup-hook (lambda () (require 'vterm)))
|
||||
#+end_src
|
||||
|
||||
** Undo Tree
|
||||
#+begin_src emacs-lisp
|
||||
(straight-use-package 'undo-tree)
|
||||
@ -623,7 +703,6 @@ down init time because vterm is loading TRAMP which is slow.
|
||||
(setq undo-tree-visualizer-diff t)
|
||||
(setq undo-tree-history-directory-alist `(("." . ,(expand-file-name "undo" user-emacs-directory))))))
|
||||
#+end_src
|
||||
|
||||
** Which Key
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@ -631,7 +710,6 @@ down init time because vterm is loading TRAMP which is slow.
|
||||
(setq which-key-idle-delay 0.3)
|
||||
(add-hook 'after-init-hook (lambda () (which-key-mode)))
|
||||
#+end_src
|
||||
|
||||
** Text Editor
|
||||
|
||||
Emacs is an great operating system, if only it had a good text editor...
|
||||
@ -640,7 +718,6 @@ Emacs is an great operating system, if only it had a good text editor...
|
||||
#+begin_src emacs-lisp
|
||||
(global-set-key (kbd "M-z") #'zap-up-to-char)
|
||||
(global-set-key (kbd "M-Z") #'zap-to-char)
|
||||
;; (setq explicit-shell-file-name "~/Development/fell/fell")
|
||||
|
||||
(defun joe/duplicate-line-comment ()
|
||||
(interactive)
|
||||
@ -660,6 +737,7 @@ Emacs is an great operating system, if only it had a good text editor...
|
||||
|
||||
(defhydra hydra-navigate (global-map "<f2>")
|
||||
"Window Navigation"
|
||||
("q" nil "quit")
|
||||
("d" joe/smooth-scroll-half-page-down "half page down")
|
||||
("u" joe/smooth-scroll-half-page-up "half page up")
|
||||
("e" joe/smooth-scroll-short-down "line down")
|
||||
@ -812,7 +890,6 @@ Emacs is an great operating system, if only it had a good text editor...
|
||||
(add-hook 'after-init-hook 'my/kakoune-setup)
|
||||
|
||||
#+end_src
|
||||
|
||||
** IDE Features
|
||||
*** LSP/Company
|
||||
|
||||
@ -845,6 +922,7 @@ Emacs is an great operating system, if only it had a good text editor...
|
||||
(define-key company-active-map (kbd "C-n") nil)
|
||||
(define-key company-active-map (kbd "C-p") nil)
|
||||
(define-key company-active-map (kbd "<return>") nil)
|
||||
(define-key company-active-map (kbd "RET") nil)
|
||||
(define-key company-active-map (kbd "C-f") #'company-complete-selection)
|
||||
(define-key company-active-map [tab] #'company-complete-common-or-cycle)
|
||||
(define-key company-active-map (kbd "<backtab>") (lambda () (interactive) (company-complete-common-or-cycle -1)))
|
||||
@ -895,7 +973,6 @@ Emacs is an great operating system, if only it had a good text editor...
|
||||
;; (require 'yasnippet)
|
||||
;; (yas-global-mode 1)
|
||||
#+end_src
|
||||
|
||||
*** C
|
||||
|
||||
Design some basic functions for compiling. There's also a hook to close the popper window if there
|
||||
@ -924,7 +1001,6 @@ it doesn't close it.
|
||||
(popper-close-latest))))))
|
||||
(add-hook 'compilation-finish-functions 'joe/close-compilation-if-no-warn-err)
|
||||
#+end_src
|
||||
|
||||
** Magit
|
||||
|
||||
The best git porcelain/client I've ever used. Also kill stray magit buffers left over as explained [[https://manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/][here]]
|
||||
@ -939,9 +1015,23 @@ The best git porcelain/client I've ever used. Also kill stray magit buffers left
|
||||
(mapc #'kill-buffer buffers)))
|
||||
|
||||
(setq magit-bury-buffer-function #'joe/magit-kill-buffers)
|
||||
(setq magit-clone-set-remote.pushDefault t)
|
||||
(setq magit-clone-default-directory "~/Development/")
|
||||
|
||||
(defvar joe/magit-keys-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "C-x g g") #'magit-status)
|
||||
(define-key map (kbd "C-x g c") #'magit-clone)
|
||||
(define-key map (kbd "C-x g i") #'magit-init)
|
||||
map)
|
||||
"Personal magit map")
|
||||
|
||||
(define-minor-mode joe/magit-keys-mode
|
||||
"A minor mode to enable some magit keys"
|
||||
:init-value t)
|
||||
|
||||
(joe/magit-keys t)
|
||||
#+end_src
|
||||
|
||||
** Restclient
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
Loading…
x
Reference in New Issue
Block a user