blob: b9a465c7741b83f715e604a0d5ceaf6519330e42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
(setq gc-cons-threshold (* 50 1000 1000))
(defun jd/display-startup-time ()
(message "Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'jd/display-startup-time)
(setq user-full-name "Jakub Dlugosz"
user-mail-address "jdlugosz963@gmail.com")
(setq backup-directory-alist '(("." . "~/.cache/emacs/backup"))
backup-by-copying t
version-control t
delete-old-versions t
kept-new-versions 20
kept-old-versions 5)
(setq user-emacs-directory "~/.cache/emacs")
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")
("gnu-devel" . "https://elpa.gnu.org/devel/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(setq use-package-always-ensure t)
(require 'use-package)
(use-package general
:config
(general-create-definer jd/leader-key-def
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC")
(general-create-definer jd/ctrl-c-keys
:prefix "C-c"))
(use-package undo-tree
:diminish
:config
(setq undo-tree-auto-save-history nil)
(global-undo-tree-mode 1))
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
(setq evil-undo-system 'undo-tree)
:config
(evil-mode 1))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
(jd/leader-key-def
"w" 'evil-window-map
"wd" '(evil-window-delete :which-key "Window delete"))
(jd/leader-key-def
"ou" '(undo-tree-visualize :which-key "Open"))
;; remove . key
(define-key evil-normal-state-map (kbd ".") '())
(setq inhibit-startup-message t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(set-fringe-mode 10)
(set-face-attribute 'default nil :font "Hack" :height 100)
(add-hook 'prog-mode-hook 'menu-bar--display-line-numbers-mode-relative)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(defalias 'yes-or-no-p 'y-or-n-p)
(use-package doom-themes
:config
(load-theme 'doom-molokai t))
(use-package diminish)
(use-package hl-todo
:init
(setq hl-todo-keyword-faces
'(("TODO" . "#FF0000")
("FIXME" . "#FF0000")
("DEBUG" . "#A020F0")))
:config
(global-hl-todo-mode 1))
(defun jd/switch-buffer ()
(interactive)
(let ((completion-regexp-list '("\\`[^*]"
"\\`\\([^T]\\|T\\($\\|[^A]\\|A\\($\\|[^G]\\|G\\($\\|[^S]\\|S.\\)\\)\\)\\).*")))
(call-interactively 'counsel-switch-buffer)))
(use-package counsel)
(use-package ivy
:diminish
:bind
(("C-s" . swiper)
:map ivy-minibuffer-map
("C-k" . ivy-previous-line)
("C-j" . ivy-next-line)
:map ivy-switch-buffer-map
("C-k" . ivy-previous-line))
:config
(ivy-mode 1))
(jd/leader-key-def
"t" '(:ignore t :which-key "Toogle")
"tt" '(counsel-load-theme :which-key "Choose theme"))
(jd/leader-key-def
"bb" '(jd/switch-buffer :which-key "Buffer switch")
"ba" '(counsel-switch-buffer :which-key "Buffer switch")
"b" '(:ignore t :which-key "Buffer")
"," '(counsel-switch-buffer :which-key "Buffer switch"))
(use-package which-key
:diminish
:config
(which-key-mode)
(setq which-key-idle-delay 0.3))
(use-package all-the-icons)
(use-package doom-modeline
:init (doom-modeline-mode 1)
:custom ((doom-modeline-height 15)))
(use-package beacon
:config
(beacon-mode 1))
(jd/leader-key-def
"f" '(:ignore t :which-key "Files")
"fs" '(save-buffer :which-key "File save")
"." '(find-file :which-key "Find file")
"ff" '(find-file :which-key "Find file"))
(jd/leader-key-def
"e" '(:ignore t :which-key "Eval")
"eb" '(eval-buffer :which-key "Eval buffer"))
(jd/leader-key-def
:keymaps '(visual)
"er" '(eval-region :which-key "Eval region"))
(defun jd/kill-other-buffers ()
(interactive)
(mapc 'kill-buffer (cdr (buffer-list (current-buffer)))))
(jd/leader-key-def
"bK" '(jd/kill-other-buffers :which-key "Kill other buffers"))
"bk" '(kill-current-buffer :which-key "Kill buffer")
"bB" '(ibuffer :which-key "Open ibuffer"))
(defun jd/org-mode-setup ()
(org-indent-mode)
(variable-pitch-mode 1)
(visual-line-mode 1))
(use-package org
:pin org
:commands (org-capture org-agenda)
:hook (org-mode . jd/org-mode-setup)
:init
(setq org-ellipsis " ▾")
(setq org-agenda-start-with-log-mode t)
(setq org-log-done 'time)
(setq org-log-into-drawer t)
(setq org-return-follows-link t)
:config
(menu-bar--display-line-numbers-mode-none)
(require 'org-tempo))
(jd/leader-key-def
"o" '(:ignore t :which-key "Open")
"oa" '(org-agenda :which-key "Open org-agenda"))
(use-package toc-org
:config
(add-hook 'org-mode-hook 'toc-org-mode))
(defun jd/org-font-setup ()
;; Replace list hyphen with dot
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•-"))))))
;; Set faces for heading levels
(dolist (face '((org-level-1 . 1.3)
(org-level-2 . 1.2)
(org-level-3 . 1.1)
(org-level-4 . 1.0)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil :font "Monospace" :weight 'Bold :height (cdr face)))
;; Ensure that anything that should be fixed-pitch in Org files appears that way
(set-face-attribute 'org-block nil :font "mononoki Nerd Font" :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
(set-face-attribute 'line-number nil :inherit 'fixed-pitch)
(set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch))
(with-eval-after-load 'org-faces (jd/org-font-setup))
(defun jd/org-tempo-setup ()
(add-to-list 'org-structure-template-alist '("sh" . "src sh"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("li" . "src lisp"))
(add-to-list 'org-structure-template-alist '("sc" . "src scheme"))
(add-to-list 'org-structure-template-alist '("ts" . "src typescript"))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(add-to-list 'org-structure-template-alist '("go" . "src go"))
(add-to-list 'org-structure-template-alist '("yaml" . "src yaml")))
(with-eval-after-load 'org-tempo (jd/org-tempo-setup))
(defun jd/org-babel-tangle-config ()
(when (string-equal (file-name-directory (buffer-file-name))
(expand-file-name "~/dotfiles/"))
;; Dynamic scoping to the rescue
(let ((org-confirm-babel-evaluate nil))
(org-babel-tangle))))
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'jd/org-babel-tangle-config)))
(defun jd/org-mode-visual-fill ()
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(use-package visual-fill-column
:hook (org-mode . jd/org-mode-visual-fill))
(use-package org-superstar
:hook (org-mode . org-superstar-mode)
:init
(setq org-superstar-special-todo-items t)
(setq org-superstar-remove-leading-stars t)
(setq org-superstar-headline-bullets-list '("◉" "○" "●" "○" "●" "○" "●")))
(use-package org-roam
:custom
(org-roam-directory (file-truename "~/Documents/org/roam/"))
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
;; Dailies
("C-c n j" . org-roam-dailies-capture-today))
:config
;; If you're using a vertical completion framework, you might want a more informative completion interface
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
(org-roam-db-autosync-mode))
(use-package lsp-mode
:commands (lsp lsp-deferred)
:init
(setq lsp-headerline-breadcrumb-enable nil)
(setq lsp-diagnostics-provider :none)
(setq lsp-modeline-diagnostics-enable nil)
(setq lsp-keymap-prefix "C-c l")
:config
(lsp-enable-which-key-integration t))
(use-package lsp-ivy
:after lsp)
(defun jd/python-mode-setup ()
(let ((project-venv-path (concat (projectile-project-root) "venv/")))
(when (projectile--directory-p project-venv-path)
(pyvenv-activate project-venv-path)
(pyvenv-mode))))
(use-package python-mode
:hook (python-mode . lsp-deferred)
:hook (python-mode . jd/python-mode-setup))
(use-package pyvenv
:after python-mode)
(use-package dap-mode
;; Uncomment the config below if you want all UI panes to be hidden by default!
;; :custom
;; (lsp-enable-dap-auto-configure nil)
;; :config
;; (dap-ui-mode 1)
:commands dap-debug
:config
;; Set up Node debugging
(require 'dap-node)
(dap-node-setup) ;; Automatically installs Node debug adapter if needed
;; Bind `C-c l d` to `dap-hydra` for easy access
(general-define-key
:keymaps 'lsp-mode-map
:prefix lsp-keymap-prefix
"d" '(dap-hydra t :wk "debugger")))
(use-package company
:after lsp-mode
:hook (lsp-mode . company-mode)
:bind (:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
(use-package company-box
:hook (company-mode . company-box-mode))
(use-package projectile
:diminish projectile-mode
:init
(when (file-directory-p "~/Documents/code")
(setq projectile-project-search-path '("~/Documents/code/")))
:custom ((projectile-Completion-system 'ivy))
:config
(setq projectile-switch-project-action #'projectile-dired)
(projectile-mode))
(jd/leader-key-def
"p" '(projectile-command-map :which-key "Project")
"p <ESC>" '()
"SPC" '(projectile-find-file :which-key "Find file in project"))
(defun jd/neotree-project-dir ()
"Open NeoTree using the git root."
(interactive)
(let ((project-dir (projectile-project-root))
(file-name (buffer-file-name)))
(neotree-toggle)
(if project-dir
(if (neo-global--window-exists-p)
(progn
(neotree-dir project-dir)
(neotree-find file-name)))
(message "Could not find git project root."))))
(use-package neotree
:init
(setq neo-theme 'icons)
:config
(evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "C-RET") 'neotree-quick-look)
(evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide)
(evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)
(evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh)
(evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle)
(evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle))
(jd/leader-key-def
"op" '(jd/neotree-project-dir :which-key "Open neotree"))
(use-package magit
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1))
(jd/leader-key-def
"g" '(:ignore t :which-key "Git")
"gg" '(magit-status-here :which-key "Magit status"))
(defun jd/open-new-vterm ()
(interactive)
(let ((buffer-name (generate-new-buffer-name vterm-buffer-name)))
(switch-to-buffer buffer-name)
(vterm-mode)))
(use-package vterm
:config
(setq vterm-buffer-name "vterm"))
(jd/leader-key-def
"ot" '(jd/open-new-vterm :which-key "Open terminal in current window"))
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package dired-ranger)
(use-package dired-single)
(use-package dired
:ensure nil
:commands (dired dired-jump)
:custom ((dired-listing-switches "-agho --group-directories-first"))
:config
(evil-collection-define-key 'normal 'dired-mode-map
"y" 'dired-ranger-copy
"p" 'dired-ranger-paste
"X" 'dired-ranger-move
"h" 'dired-up-directory
"l" 'dired-single-buffer))
(use-package emms
:config
(require 'emms-setup)
(emms-all)
(emms-standard)
(emms-default-players)
(emms-mode-line-disable)
(emms-add-directory-tree "~/Documents/music/"))
|