dotfiles/emacs/.emacs.d/config/init-windows.el

78 lines
3.0 KiB
EmacsLisp

;; -*- lexical-binding: t; -*-
;; Window-related configuration
;; winum-mode allows selecting windows by number
(use-package winum
:config
(winum-mode)
:custom
(winum-scope 'frame-local))
;; winner-mode lets you undo and redo changes to the window layout
(winner-mode 1)
;; Keybindings
(leader-def-key
"0" #'winum-select-window-0-or-10
"1" #'winum-select-window-1
"2" #'winum-select-window-2
"3" #'winum-select-window-3
"4" #'winum-select-window-4
"5" #'winum-select-window-5
"6" #'winum-select-window-6
"7" #'winum-select-window-7
"8" #'winum-select-window-8
"9" #'winum-select-window-9
"w" '(evil-window-map :which-key "window"))
(general-def evil-window-map
"m" #'delete-other-windows
"S" #'split-root-window-below
"V" #'split-root-window-right
"u" #'winner-undo
"C-r" #'winner-redo)
;; Condense the which-key display for window selection bindings
(with-eval-after-load 'which-key
(push '(("\\(.*\\) 0" . "select-window-0") . ("\\1 0..9" . "window 0..9"))
which-key-replacement-alist)
(push '((nil . "select-window-[1-9]") . t) which-key-replacement-alist))
;; Buffer and window layout management
(setopt switch-to-buffer-in-dedicated-window 'pop
split-height-threshold 116
window-sides-slots '(1 0 0 1)
display-buffer-alist '(("\\*Help\\*"
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 85))
("\\*helpful .*\\*"
(display-buffer-reuse-mode-window
display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 85))
("\\*eldoc\\*"
(display-buffer-reuse-window
display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 85))
("\\*vterm.*\\*"
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(mode vterm-mode vterm-copy-mode))
("\\*ielm\\*"
(display-buffer-reuse-mode-window
display-buffer-pop-up-window)
(mode vterm-mode vterm-copy-mode))
("\\*Messages\\*" display-buffer-no-window (allow-no-window . t))
("\\*Warnings\\*" display-buffer-no-window (allow-no-window . t))
("\\*info\\*" (display-buffer-reuse-window
display-buffer-pop-up-window))))
(provide 'init-windows)