core-packages.el (9095B)
1 ;;; core-packages.el --- Core packages for my Emacs config 2 3 ;; Author: Mark Feller <mark.feller@member.fsf.org> 4 5 ;; This file is not part of GNU Emacs. 6 7 ;; This file is free software; you can redistribute it and/or modify 8 ;; it under the terms of the GNU General Public License as published by 9 ;; the Free Software Foundation; either version 3, or (at your option) 10 ;; any later version. 11 12 ;; This file is distributed in the hope that it will be useful, 13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 ;; GNU General Public License for more details. 16 17 ;; You should have received a copy of the GNU General Public License 18 ;; along with this file. If not, see <http://www.gnu.org/licenses/>. 19 20 ;;; Commentary: 21 22 ;;; Code: 23 24 (use-package swiper 25 :demand 26 :delight (ivy-mode) 27 :bind (("C-s" . swiper) 28 ("C-r" . swiper) 29 ("C-c u" . swiper-all) 30 ("C-c C-r" . ivy-resume) 31 ("C-c C-o" . ivy-occur) 32 ("C-c C-b" . ivy-switch-buffer) 33 ("C-c C-k" . kill-buffer)) 34 (:map ivy-minibuffer-map 35 ("TAB" . ivy-partial-or-done)) 36 :config 37 (setq ivy-height 6) 38 (setq enable-recursive-minibuffers t) 39 (setq swiper-include-line-number-in-search t) 40 41 (ivy-mode 1)) 42 43 (use-package smex 44 :demand 45 :config (setq smex-save-file "~/.cache/smex-items")) 46 47 (use-package counsel 48 :after (ivy) 49 :demand 50 :bind (("M-x" . counsel-M-x) 51 ("C-x C-f" . counsel-find-file) 52 ("C-h f" . counsel-describe-function) 53 ("C-h v" . counsel-describe-variable) 54 ("C-c f r" . counsel-recentf) 55 ("C-c g" . counsel-git) 56 ("C-c /" . counsel-git-grep) 57 ("M-y" . counsel-yank-pop))) 58 59 (use-package saveplace 60 :config 61 (setq save-place-file "~/.cache/places" 62 backup-by-copying t 63 delete-old-versions t 64 kept-new-versions 6 65 kept-old-versions 2 66 version-control t)) 67 68 (use-package bufler 69 :bind (("C-x C-b" . bufler)) 70 71 :config 72 (add-to-list 'evil-emacs-state-modes 'bufler-list-mode)) 73 74 75 ;; (use-package ibuffer 76 ;; :bind (("C-x C-b" . ibuffer) 77 ;; :map ibuffer-mode-map 78 ;; ("/ p" . ibuffer-projectile-set-filter-groups)) 79 ;; :config 80 ;; (setq ibuffer-default-sorting-mode 'major-mode) 81 ;; (setq ibuffer-display-summary nil) 82 ;; (setq ibuffer-expert t) 83 ;; (setq ibuffer-show-empty-filter-groups nil) 84 ;; (setq ibuffer-marked-char ?-) 85 86 ;; (add-hook 'ibuffer-mode-hook 'disable-line-numbers) 87 ;; (add-hook 'ibuffer-mode-hook (lambda () (ibuffer-auto-mode 1))) 88 89 ;; (defun ibuffer-get-major-modes-ibuff-rules-list (mm-list result-list) 90 ;; (if mm-list 91 ;; (let* ((cur-mm (car mm-list)) 92 ;; (next-res-list-el `(,(symbol-name cur-mm) (mode . ,cur-mm)))) 93 ;; (ibuffer-get-major-modes-ibuff-rules-list 94 ;; (cdr mm-list) (cons next-res-list-el result-list))) 95 ;; result-list)) 96 97 ;; (defun ibuffer-get-major-modes-list () 98 ;; (mapcar 99 ;; (function (lambda (buffer) 100 ;; (buffer-local-value 'major-mode (get-buffer buffer)))) 101 ;; (buffer-list (selected-frame)))) 102 103 ;; (defun ibuffer-create-buffs-group () 104 ;; (interactive) 105 ;; (let* ((ignore-modes '(Buffer-menu-mode 106 ;; compilation-mode 107 ;; minibuffer-inactive-mode 108 ;; ibuffer-mode 109 ;; magit-process-mode 110 ;; messages-buffer-mode 111 ;; fundamental-mode 112 ;; completion-list-mode 113 ;; help-mode 114 ;; Info-mode)) 115 ;; (cur-bufs 116 ;; (list (cons "Home" 117 ;; (ibuffer-get-major-modes-ibuff-rules-list 118 ;; (cl-set-difference 119 ;; (remove-duplicates 120 ;; (ibuffer-get-major-modes-list)) 121 ;; ignore-modes) '()))))) 122 ;; (setq ibuffer-saved-filter-groups cur-bufs) 123 ;; (ibuffer-switch-to-saved-filter-groups "Home"))) 124 125 ;; (autoload 'ibuffer "ibuffer" "List buffers." t) 126 127 ;; (defun ibuffer-group-by-modes () 128 ;; "Group buffers by modes." 129 ;; (ibuffer-create-buffs-group)) 130 131 132 ;; (defadvice ibuffer-update-title-and-summary (after remove-column-titles) 133 ;; (with-no-warnings 134 ;; (save-excursion 135 ;; (set-buffer "*Ibuffer*") 136 ;; (toggle-read-only 0) 137 ;; (goto-char 1) 138 ;; (search-forward "-\n" nil t) 139 ;; (delete-region 1 (point)) 140 ;; ;; (let ((window-min-height 1)) 141 ;; ;; ;; save a little screen estate 142 ;; ;; (shrink-window-if-larger-than-buffer)) 143 ;; (toggle-read-only)))) 144 145 ;; (ad-activate 'ibuffer-update-title-and-summary) 146 147 ;; ;; Use human readable Size column instead of original one 148 ;; (define-ibuffer-column size-h 149 ;; (:name "Size" :inline t) 150 ;; (cond 151 ;; ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0))) 152 ;; ((> (buffer-size) 100000) (format "%7.0fk" (/ (buffer-size) 1000.0))) 153 ;; ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0))) 154 ;; (t (format "%8d" (buffer-size))))) 155 156 ;; ;; Modify the default ibuffer-formats 157 ;; (setq ibuffer-formats 158 ;; '((mark modified read-only " " 159 ;; (name 18 18 :left :elide) 160 ;; " " 161 ;; (size-h 9 -1 :right) 162 ;; " " 163 ;; (mode 16 16 :left :elide) 164 ;; " " 165 ;; filename-and-process)))) 166 167 (electric-pair-mode t) 168 (global-auto-revert-mode t) 169 170 (use-package comment-dwim-2 171 :bind (("M-;" . comment-dwim-2))) 172 173 (use-package dired 174 :ensure nil 175 :bind (("C-x C-j" . dired-jump)) 176 177 :config 178 (setq wdired-use-dired-vertical-movement 'sometimes) 179 (setq dired-listing-switches "-la") 180 181 (set-face-attribute 'dired-directory nil 182 :inherit 'default 183 :foreground "#839496" 184 :weight 'bold) 185 186 (add-hook 'dired-mode-hook 'disable-line-numbers) 187 188 (defun dired-sort-dir-first () 189 "Sort dired listings with directories first." 190 (save-excursion 191 (let (buffer-read-only) 192 (forward-line 2) ;; beyond dir. header 193 (sort-regexp-fields t "^.*$" "[ ]*." (point) (point-max))) 194 (set-buffer-modified-p nil))) 195 196 (defadvice dired-readin 197 (after dired-after-updating-hook first () activate) 198 "Sort dired listings with directories first before adding marks." 199 (dired-sort-dir-first))) 200 201 (use-package dired-subtree 202 :after dired 203 :bind (:map dired-mode-map 204 ("<tab>" . dired-subtree-toggle) 205 ("C-<tab>" . dired-subtree-cycle) 206 ("<backtab>" . dired-subtree-remove))) 207 208 ;; better describe 209 (use-package helpful 210 :bind (("C-h f" . helpful-function) 211 ("C-h o" . helpful-symbol) 212 ("C-h k" . helpful-key) 213 ("C-h v" . helpful-variable)) 214 :config 215 (add-hook 'helpful-mode-hook 'disable-line-numbers)) 216 217 (use-package rg 218 :config 219 (rg-enable-default-bindings (kbd "M-s")) 220 (setq rg-executable "/usr/local/bin/rg")) 221 222 ;; window management 223 (if (eq system-type 'darwin) 224 (setq window-management-prefix "H") 225 (setq window-management-prefix "s")) 226 227 (bind-keys 228 ((concat window-management-prefix "-e") . windmove-up) 229 ((concat window-management-prefix "-d") . windmove-down) 230 ((concat window-management-prefix "-f") . windmove-right) 231 ((concat window-management-prefix "-s") . windmove-left) 232 233 ;; Window Resizing 234 ((concat window-management-prefix "-E") . enlarge-window) 235 ((concat window-management-prefix "-D") . shrink-window) 236 ((concat window-management-prefix "-F") . enlarge-window-horizontally) 237 ((concat window-management-prefix "-S") . shrink-window-horizontally) 238 239 ;; Window Splitting 240 ((concat window-management-prefix "-v") . split-window-vertically) 241 ((concat window-management-prefix "-r") . split-window-horizontally) 242 ((concat window-management-prefix "-w") . delete-window) 243 ((concat window-management-prefix "-q") . delete-other-windows) 244 245 ;; Misc Window Commands 246 ((concat window-management-prefix "-a") . balance-windows) 247 ((concat window-management-prefix "-t") . toggle-window-split) 248 ((concat window-management-prefix "-<return>") . toggle-fullscreen) 249 250 ((concat window-management-prefix "-c") . mjf/center-window) 251 ((concat window-management-prefix "-W") . mjf/focused) 252 ((concat window-management-prefix "-n") . narrow-or-widen-dwim)) 253 254 (delight 'subword-mode "" "subword") 255 (delight 'undo-tree-mode "" "undo-tree") 256 257 (add-hook 'woman-mode-hook 'disable-line-numbers) 258 (add-hook 'Man-mode-hook 'disable-line-numbers) 259 (add-hook 'compilation-mode-hook 'disable-line-numbers) 260 261 (bind-keys 262 ("C-c C-j" . xref-show-definitions-function) 263 ("M-," . xref-go-back)) 264 265 (require 'ansi-color) 266 (defun colorize-compilation-buffer () 267 (ansi-color-apply-on-region compilation-filter-start (point))) 268 (add-hook 'compilation-filter-hook 'colorize-compilation-buffer) 269 270 (provide 'core-packages) 271 272 ;;; core-packages.el ends here