diff options
author | jdlugosz963 <jdlugosz963@gmail.com> | 2022-08-21 03:26:51 +0200 |
---|---|---|
committer | jdlugosz963 <jdlugosz963@gmail.com> | 2022-08-21 03:26:51 +0200 |
commit | 5241b7e2cbee2c47749dee06248255416c65db7e (patch) | |
tree | 7508116b6b0ccd421977c54144708a75c82d910e | |
parent | 166fef2538fcde8c7ef7caa786e7941d3a7d043f (diff) | |
download | dotfiles-5241b7e2cbee2c47749dee06248255416c65db7e.tar.gz dotfiles-5241b7e2cbee2c47749dee06248255416c65db7e.zip |
Emacs: Update init.el file
-rw-r--r-- | .config/emacs/init.el | 218 |
1 files changed, 184 insertions, 34 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el index ffcd1bb..b9a465c 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el | |||
@@ -1,6 +1,3 @@ | |||
1 | (setq user-full-name "Jakub Dlugosz" | ||
2 | user-mail-address "jdlugosz963@gmail.com") | ||
3 | |||
4 | (setq gc-cons-threshold (* 50 1000 1000)) | 1 | (setq gc-cons-threshold (* 50 1000 1000)) |
5 | 2 | ||
6 | (defun jd/display-startup-time () | 3 | (defun jd/display-startup-time () |
@@ -12,6 +9,18 @@ | |||
12 | 9 | ||
13 | (add-hook 'emacs-startup-hook #'jd/display-startup-time) | 10 | (add-hook 'emacs-startup-hook #'jd/display-startup-time) |
14 | 11 | ||
12 | (setq user-full-name "Jakub Dlugosz" | ||
13 | user-mail-address "jdlugosz963@gmail.com") | ||
14 | |||
15 | (setq backup-directory-alist '(("." . "~/.cache/emacs/backup")) | ||
16 | backup-by-copying t | ||
17 | version-control t | ||
18 | delete-old-versions t | ||
19 | kept-new-versions 20 | ||
20 | kept-old-versions 5) | ||
21 | |||
22 | (setq user-emacs-directory "~/.cache/emacs") | ||
23 | |||
15 | (require 'package) | 24 | (require 'package) |
16 | (setq package-archives '(("melpa" . "https://melpa.org/packages/") | 25 | (setq package-archives '(("melpa" . "https://melpa.org/packages/") |
17 | ("org" . "https://orgmode.org/elpa/") | 26 | ("org" . "https://orgmode.org/elpa/") |
@@ -40,6 +49,7 @@ | |||
40 | :prefix "C-c")) | 49 | :prefix "C-c")) |
41 | 50 | ||
42 | (use-package undo-tree | 51 | (use-package undo-tree |
52 | :diminish | ||
43 | :config | 53 | :config |
44 | (setq undo-tree-auto-save-history nil) | 54 | (setq undo-tree-auto-save-history nil) |
45 | (global-undo-tree-mode 1)) | 55 | (global-undo-tree-mode 1)) |
@@ -78,16 +88,33 @@ | |||
78 | 88 | ||
79 | (set-face-attribute 'default nil :font "Hack" :height 100) | 89 | (set-face-attribute 'default nil :font "Hack" :height 100) |
80 | 90 | ||
81 | ; (load-theme 'wombat) | 91 | (add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative) |
82 | 92 | ||
83 | (global-set-key (kbd "<escape>") 'keyboard-escape-quit) | 93 | (global-set-key (kbd "<escape>") 'keyboard-escape-quit) |
84 | 94 | ||
85 | (use-package monokai-theme | 95 | (defalias 'yes-or-no-p 'y-or-n-p) |
96 | |||
97 | (use-package doom-themes | ||
86 | :config | 98 | :config |
87 | (load-theme 'monokai t)) | 99 | (load-theme 'doom-molokai t)) |
88 | 100 | ||
89 | (use-package diminish) | 101 | (use-package diminish) |
90 | 102 | ||
103 | (use-package hl-todo | ||
104 | :init | ||
105 | (setq hl-todo-keyword-faces | ||
106 | '(("TODO" . "#FF0000") | ||
107 | ("FIXME" . "#FF0000") | ||
108 | ("DEBUG" . "#A020F0"))) | ||
109 | :config | ||
110 | (global-hl-todo-mode 1)) | ||
111 | |||
112 | (defun jd/switch-buffer () | ||
113 | (interactive) | ||
114 | (let ((completion-regexp-list '("\\`[^*]" | ||
115 | "\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*"))) | ||
116 | (call-interactively 'counsel-switch-buffer))) | ||
117 | |||
91 | (use-package counsel) | 118 | (use-package counsel) |
92 | (use-package ivy | 119 | (use-package ivy |
93 | :diminish | 120 | :diminish |
@@ -106,7 +133,8 @@ | |||
106 | "tt" '(counsel-load-theme :which-key "Choose theme")) | 133 | "tt" '(counsel-load-theme :which-key "Choose theme")) |
107 | 134 | ||
108 | (jd/leader-key-def | 135 | (jd/leader-key-def |
109 | "bb" '(counsel-switch-buffer :which-key "Buffer switch") | 136 | "bb" '(jd/switch-buffer :which-key "Buffer switch") |
137 | "ba" '(counsel-switch-buffer :which-key "Buffer switch") | ||
110 | "b" '(:ignore t :which-key "Buffer") | 138 | "b" '(:ignore t :which-key "Buffer") |
111 | "," '(counsel-switch-buffer :which-key "Buffer switch")) | 139 | "," '(counsel-switch-buffer :which-key "Buffer switch")) |
112 | 140 | ||
@@ -122,6 +150,10 @@ | |||
122 | :init (doom-modeline-mode 1) | 150 | :init (doom-modeline-mode 1) |
123 | :custom ((doom-modeline-height 15))) | 151 | :custom ((doom-modeline-height 15))) |
124 | 152 | ||
153 | (use-package beacon | ||
154 | :config | ||
155 | (beacon-mode 1)) | ||
156 | |||
125 | (jd/leader-key-def | 157 | (jd/leader-key-def |
126 | "f" '(:ignore t :which-key "Files") | 158 | "f" '(:ignore t :which-key "Files") |
127 | "fs" '(save-buffer :which-key "File save") | 159 | "fs" '(save-buffer :which-key "File save") |
@@ -136,8 +168,14 @@ | |||
136 | :keymaps '(visual) | 168 | :keymaps '(visual) |
137 | "er" '(eval-region :which-key "Eval region")) | 169 | "er" '(eval-region :which-key "Eval region")) |
138 | 170 | ||
171 | (defun jd/kill-other-buffers () | ||
172 | (interactive) | ||
173 | (mapc 'kill-buffer (cdr (buffer-list (current-buffer))))) | ||
174 | |||
139 | (jd/leader-key-def | 175 | (jd/leader-key-def |
140 | "bk" '(kill-this-buffer :which-key "Buffer kill")) | 176 | "bK" '(jd/kill-other-buffers :which-key "Kill other buffers")) |
177 | "bk" '(kill-current-buffer :which-key "Kill buffer") | ||
178 | "bB" '(ibuffer :which-key "Open ibuffer")) | ||
141 | 179 | ||
142 | (defun jd/org-mode-setup () | 180 | (defun jd/org-mode-setup () |
143 | (org-indent-mode) | 181 | (org-indent-mode) |
@@ -148,22 +186,23 @@ | |||
148 | :pin org | 186 | :pin org |
149 | :commands (org-capture org-agenda) | 187 | :commands (org-capture org-agenda) |
150 | :hook (org-mode . jd/org-mode-setup) | 188 | :hook (org-mode . jd/org-mode-setup) |
151 | :config | 189 | :init |
152 | (setq org-ellipsis " ▾") | 190 | (setq org-ellipsis " ▾") |
153 | |||
154 | (setq org-agenda-start-with-log-mode t) | 191 | (setq org-agenda-start-with-log-mode t) |
155 | (setq org-log-done 'time) | 192 | (setq org-log-done 'time) |
156 | (setq org-log-into-drawer t) | 193 | (setq org-log-into-drawer t) |
194 | (setq org-return-follows-link t) | ||
195 | :config | ||
196 | (menu-bar--display-line-numbers-mode-none) | ||
157 | (require 'org-tempo)) | 197 | (require 'org-tempo)) |
158 | 198 | ||
159 | (jd/leader-key-def | 199 | (jd/leader-key-def |
160 | "o" '(:ignore t :which-key "Open") | 200 | "o" '(:ignore t :which-key "Open") |
161 | "oa" '(org-agenda :which-key "Open org-agenda")) | 201 | "oa" '(org-agenda :which-key "Open org-agenda")) |
162 | 202 | ||
163 | (use-package org-make-toc) | 203 | (use-package toc-org |
164 | 204 | :config | |
165 | (add-hook 'org-mode-hook #'org-make-toc-mode) | 205 | (add-hook 'org-mode-hook 'toc-org-mode)) |
166 | ; (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'org-make-toc))) | ||
167 | 206 | ||
168 | (defun jd/org-font-setup () | 207 | (defun jd/org-font-setup () |
169 | ;; Replace list hyphen with dot | 208 | ;; Replace list hyphen with dot |
@@ -211,7 +250,7 @@ | |||
211 | 250 | ||
212 | (defun jd/org-babel-tangle-config () | 251 | (defun jd/org-babel-tangle-config () |
213 | (when (string-equal (file-name-directory (buffer-file-name)) | 252 | (when (string-equal (file-name-directory (buffer-file-name)) |
214 | (expand-file-name user-emacs-directory)) | 253 | (expand-file-name "~/dotfiles/")) |
215 | ;; Dynamic scoping to the rescue | 254 | ;; Dynamic scoping to the rescue |
216 | (let ((org-confirm-babel-evaluate nil)) | 255 | (let ((org-confirm-babel-evaluate nil)) |
217 | (org-babel-tangle)))) | 256 | (org-babel-tangle)))) |
@@ -228,24 +267,128 @@ | |||
228 | 267 | ||
229 | (use-package org-superstar | 268 | (use-package org-superstar |
230 | :hook (org-mode . org-superstar-mode) | 269 | :hook (org-mode . org-superstar-mode) |
231 | :config | 270 | :init |
232 | (setq org-superstar-special-todo-items t) | 271 | (setq org-superstar-special-todo-items t) |
233 | (setq org-superstar-remove-leading-stars t) | 272 | (setq org-superstar-remove-leading-stars t) |
234 | (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) | 273 | (setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●"))) |
235 | 274 | ||
275 | (use-package org-roam | ||
276 | :custom | ||
277 | (org-roam-directory (file-truename "~/Documents/org/roam/")) | ||
278 | :bind (("C-c n l" . org-roam-buffer-toggle) | ||
279 | ("C-c n f" . org-roam-node-find) | ||
280 | ("C-c n g" . org-roam-graph) | ||
281 | ("C-c n i" . org-roam-node-insert) | ||
282 | ("C-c n c" . org-roam-capture) | ||
283 | ;; Dailies | ||
284 | ("C-c n j" . org-roam-dailies-capture-today)) | ||
285 | :config | ||
286 | ;; If you're using a vertical completion framework, you might want a more informative completion interface | ||
287 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) | ||
288 | (org-roam-db-autosync-mode)) | ||
289 | |||
290 | (use-package lsp-mode | ||
291 | :commands (lsp lsp-deferred) | ||
292 | :init | ||
293 | (setq lsp-headerline-breadcrumb-enable nil) | ||
294 | (setq lsp-diagnostics-provider :none) | ||
295 | (setq lsp-modeline-diagnostics-enable nil) | ||
296 | (setq lsp-keymap-prefix "C-c l") | ||
297 | :config | ||
298 | (lsp-enable-which-key-integration t)) | ||
299 | |||
300 | (use-package lsp-ivy | ||
301 | :after lsp) | ||
302 | |||
303 | (defun jd/python-mode-setup () | ||
304 | (let ((project-venv-path (concat (projectile-project-root) "venv/"))) | ||
305 | (when (projectile--directory-p project-venv-path) | ||
306 | (pyvenv-activate project-venv-path) | ||
307 | (pyvenv-mode)))) | ||
308 | |||
309 | (use-package python-mode | ||
310 | :hook (python-mode . lsp-deferred) | ||
311 | :hook (python-mode . jd/python-mode-setup)) | ||
312 | |||
313 | (use-package pyvenv | ||
314 | :after python-mode) | ||
315 | |||
316 | (use-package dap-mode | ||
317 | ;; Uncomment the config below if you want all UI panes to be hidden by default! | ||
318 | ;; :custom | ||
319 | ;; (lsp-enable-dap-auto-configure nil) | ||
320 | ;; :config | ||
321 | ;; (dap-ui-mode 1) | ||
322 | :commands dap-debug | ||
323 | :config | ||
324 | ;; Set up Node debugging | ||
325 | (require 'dap-node) | ||
326 | (dap-node-setup) ;; Automatically installs Node debug adapter if needed | ||
327 | |||
328 | ;; Bind `C-c l d` to `dap-hydra` for easy access | ||
329 | (general-define-key | ||
330 | :keymaps 'lsp-mode-map | ||
331 | :prefix lsp-keymap-prefix | ||
332 | "d" '(dap-hydra t :wk "debugger"))) | ||
333 | |||
334 | (use-package company | ||
335 | :after lsp-mode | ||
336 | :hook (lsp-mode . company-mode) | ||
337 | :bind (:map company-active-map | ||
338 | ("<tab>" . company-complete-selection)) | ||
339 | (:map lsp-mode-map | ||
340 | ("<tab>" . company-indent-or-complete-common)) | ||
341 | :custom | ||
342 | (company-minimum-prefix-length 1) | ||
343 | (company-idle-delay 0.0)) | ||
344 | |||
345 | (use-package company-box | ||
346 | :hook (company-mode . company-box-mode)) | ||
347 | |||
236 | (use-package projectile | 348 | (use-package projectile |
237 | :diminish projectile-mode | 349 | :diminish projectile-mode |
238 | :init | 350 | :init |
239 | (when (file-directory-p "~/Documents/code") | 351 | (when (file-directory-p "~/Documents/code") |
240 | (setq projectile-project-search-path '("~/Documents/code/"))) | 352 | (setq projectile-project-search-path '("~/Documents/code/"))) |
241 | :config (projectile-mode) | 353 | :custom ((projectile-Completion-system 'ivy)) |
242 | :custom ((projectile-Completion-system 'ivy))) | 354 | :config |
355 | (setq projectile-switch-project-action #'projectile-dired) | ||
356 | (projectile-mode)) | ||
243 | 357 | ||
244 | (jd/leader-key-def | 358 | (jd/leader-key-def |
245 | "p" '(projectile-command-map :which-key "Project") | 359 | "p" '(projectile-command-map :which-key "Project") |
246 | "p <ESC>" '() | 360 | "p <ESC>" '() |
247 | "SPC" '(projectile-find-file :which-key "Find file in project")) | 361 | "SPC" '(projectile-find-file :which-key "Find file in project")) |
248 | 362 | ||
363 | (defun jd/neotree-project-dir () | ||
364 | "Open NeoTree using the git root." | ||
365 | (interactive) | ||
366 | (let ((project-dir (projectile-project-root)) | ||
367 | (file-name (buffer-file-name))) | ||
368 | (neotree-toggle) | ||
369 | (if project-dir | ||
370 | (if (neo-global--window-exists-p) | ||
371 | (progn | ||
372 | (neotree-dir project-dir) | ||
373 | (neotree-find file-name))) | ||
374 | (message "Could not find git project root.")))) | ||
375 | |||
376 | (use-package neotree | ||
377 | :init | ||
378 | (setq neo-theme 'icons) | ||
379 | :config | ||
380 | |||
381 | (evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter) | ||
382 | (evil-define-key 'normal neotree-mode-map (kbd "C-RET") 'neotree-quick-look) | ||
383 | (evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide) | ||
384 | (evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter) | ||
385 | (evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh) | ||
386 | (evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle) | ||
387 | (evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle)) | ||
388 | |||
389 | (jd/leader-key-def | ||
390 | "op" '(jd/neotree-project-dir :which-key "Open neotree")) | ||
391 | |||
249 | (use-package magit | 392 | (use-package magit |
250 | :custom | 393 | :custom |
251 | (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) | 394 | (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) |
@@ -254,36 +397,43 @@ | |||
254 | "g" '(:ignore t :which-key "Git") | 397 | "g" '(:ignore t :which-key "Git") |
255 | "gg" '(magit-status-here :which-key "Magit status")) | 398 | "gg" '(magit-status-here :which-key "Magit status")) |
256 | 399 | ||
257 | (use-package vterm) | 400 | (defun jd/open-new-vterm () |
258 | (use-package vterm-toggle | 401 | (interactive) |
259 | :init | 402 | (let ((buffer-name (generate-new-buffer-name vterm-buffer-name))) |
260 | (setq vterm-toggle-fullscreen-p nil) | 403 | (switch-to-buffer buffer-name) |
404 | (vterm-mode))) | ||
405 | |||
406 | (use-package vterm | ||
261 | :config | 407 | :config |
262 | (add-to-list 'display-buffer-alist | 408 | (setq vterm-buffer-name "vterm")) |
263 | '((lambda (buffer-or-name _) | ||
264 | (let ((buffer (get-buffer buffer-or-name))) | ||
265 | (with-current-buffer buffer | ||
266 | (or (equal major-mode 'vterm-mode) | ||
267 | (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) | ||
268 | (display-buffer-reuse-window display-buffer-at-bottom) | ||
269 | (reusable-frames . visible) | ||
270 | (window-height . 0.3)))) | ||
271 | 409 | ||
272 | (jd/leader-key-def | 410 | (jd/leader-key-def |
273 | "oT" '(vterm :which-key "Open terminal in current window") | 411 | "ot" '(jd/open-new-vterm :which-key "Open terminal in current window")) |
274 | "ot" '(vterm-toggle :which-key "Toggle terminal")) | ||
275 | 412 | ||
276 | (use-package all-the-icons-dired | 413 | (use-package all-the-icons-dired |
277 | :hook (dired-mode . all-the-icons-dired-mode)) | 414 | :hook (dired-mode . all-the-icons-dired-mode)) |
278 | 415 | ||
279 | (use-package dired-ranger) | 416 | (use-package dired-ranger) |
280 | 417 | ||
418 | (use-package dired-single) | ||
419 | |||
281 | (use-package dired | 420 | (use-package dired |
282 | :ensure nil | 421 | :ensure nil |
283 | :commands (dired dired-jump) | 422 | :commands (dired dired-jump) |
284 | :bind (("C-x C-j" . dired-jump)) | ||
285 | :custom ((dired-listing-switches "-agho --group-directories-first")) | 423 | :custom ((dired-listing-switches "-agho --group-directories-first")) |
286 | :config | 424 | :config |
287 | (evil-collection-define-key 'normal 'dired-mode-map | 425 | (evil-collection-define-key 'normal 'dired-mode-map |
426 | "y" 'dired-ranger-copy | ||
427 | "p" 'dired-ranger-paste | ||
428 | "X" 'dired-ranger-move | ||
288 | "h" 'dired-up-directory | 429 | "h" 'dired-up-directory |
289 | "l" 'dired-single-buffer)) | 430 | "l" 'dired-single-buffer)) |
431 | |||
432 | (use-package emms | ||
433 | :config | ||
434 | (require 'emms-setup) | ||
435 | (emms-all) | ||
436 | (emms-standard) | ||
437 | (emms-default-players) | ||
438 | (emms-mode-line-disable) | ||
439 | (emms-add-directory-tree "~/Documents/music/")) | ||