Repository navigation
Expand file tree
/
Copy pathinit.el
More file actions
490 lines (403 loc) · 12.8 KB
/
Copy pathinit.el
File metadata and controls
490 lines (403 loc) · 12.8 KB
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
;; -*- lexical-binding: t; -*-
;; setup username
(setq user-full-name "Diego Vila")
;; set font
(set-face-attribute 'default nil
:font "iMWritingDuo Nerd Font"
;;:font "CodeNewRoman Nerd Font"
:height 180)
;; stop making backup files
(setq make-backup-files nil)
;; take out startup screen
(setq inhibit-startup-message t)
;; silent native comp warnings
(setq native-comp-async-report-warnings-errors 'silent)
;; cause scroll bar, tool bar, and menu to disapear
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
;; get ride of word wrapping
(setq-default truncate-lines 1)
;; get ride of the fringes from side of window
(set-fringe-mode 10)
;; Set up the visible bell, flashes
(setq visible-bell t)
;; show line numbers
(global-display-line-numbers-mode t)
;; show column number in mode line
(column-number-mode)
;; Enable which-key (Built-in for Emacs 30+)
(which-key-mode 1)
;; show directory first and show hidden for dired
(setq dired-listing-switches "-alh --group-directories-first")
;; setup ispell
(setq ispell-program-name "hunspell")
(setenv "LANG" "en_US.UTF-8")
(setq ispell-dictionary "en_US")
(setq ispell-local-dictionary "en_US")
(when (eq system-type 'windows-nt)
(setq ispell-hunspell-dict-paths-alist
'(("en_US" "C:/Hunspell/en_US.aff"))))
;; setup highlight of line
(add-hook 'emacs-lisp-mode-hook #'hl-line-mode)
(add-hook 'elisp-mode-hook #'hl-line-mode)
;; Disable line numbers for some modes
(dolist (mode '(org-mode-hook
markdown-mode-hook
term-mode-hook
text-mode-hook
shell-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
;; keybind for eshell
(global-set-key (kbd "C-c e") #'eshell)
;; Setup package
(require 'package)
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
;; run M-x package-refresh-contents
;; to update the index
;; Install use-package
(unless (package-installed-p 'use-package)
(package-install 'use-package))
;; load use-package
(require 'use-package)
;; install package if not found
(setq use-package-always-ensure t)
;; Setup markdown-mode
(use-package markdown-mode
:hook
(markdown-mode . hl-line-mode))
;; Setup typescript-mode
(use-package typescript-mode)
;; Setup org-mode
(use-package org
:init
(setq org-directory "~/org/")
;; nicer indent for org headlines
(setq org-startup-indented t)
(setq org-agenda-files
'("~/org/tasks.org"))
;; (setq org-todo-keywords
;; '((sequence "REPEAT(r)" "PROJECT(p)" "TODO(t)" "NEXT(n)" "WAITING(w)" "BACKLOG(b)" "|" "DONE(d!)" "CANCELLED(c!)")))
(setq org-capture-templates
'(
("i" "Inbox" entry
(file+headline "~/org/inbox.org" "Inbox")
"* %?\n %i\n %a"
:empty-lines 1)
("s" "Spanish" entry
(file+headline "~/org/2_areas/spanish.org" "Spanish Vocabulary")
"* %^{Spanish word} :drill:
:PROPERTIES:
:DRILL_CARD_TYPE: twosided
:END:
** Spanish
%^{Spanish word}
** English
%^{English translation}
** Example
%^{Example sentence}
** Notes
%?"
:empty-lines 1)
("v" "Vocabulary" entry
(file+headline "~/org/2_areas/vocabulary.org" "Vocabulary")
"* %^{Word} :drill:
:PROPERTIES:
:DRILL_CARD_TYPE: twosided
:END:
** Word
%^{Word}
** Definition
%^{Definition}
** Example
%^{Example}
** Notes
%?"
:empty-lines 1)))
(setq org-capture-bookmark nil) ;; disable bookmark for capture
(setq org-refile-targets
'(("~/org/inbox.org" :maxlevel . 1)
("~/org/tasks.org" :maxlevel . 1)
("~/org/1_projects/projects.org" :maxlevel . 1)))
;; put logs in drawer
(setq org-log-into-drawer t)
;; add timestamp for done
(setq org-log-done 'time)
;; respect content of header when creating a new one
(setq org-insert-heading-respect-content t)
:config
;; setup org source blocks
(setq org-src-fontify-natively t)
(setq org-src-tab-acts-natively t)
(add-to-list 'org-src-lang-modes '("typescript" . typescript))
:bind
("C-c a" . org-agenda)
("C-c c" . org-capture)
:hook
(markdown-mode . orgtbl-mode)
(org-mode . hl-line-mode)
(org-mode . flyspell-mode))
;; Setup org-superstar
(use-package org-superstar
:init
(setq org-superstar-headline-bullets-list '("◉" "○" "✸" "☆" "♦"))
(setq org-hide-leading-stars t)
:hook
(org-mode . org-superstar-mode))
;; use kanban boards
(use-package org-kanban
:bind
("C-c k" . org-kanban/shift))
;; for space repetition
(use-package org-drill
:init
;; fix timestamp issue
(setq org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")))
;; Setup org-roam
(use-package org-roam
:init
;; where roam looks for notes
(setq org-roam-directory (file-truename "~/org/2_areas/kingdom/personal-study"))
(setq org-roam-dailies-directory "~/org/2_areas/journal/")
:config
;; keep the SQLite database in sync automatically
(org-roam-db-autosync-mode)
;; how to show search results for org-roam-node-find
(setq org-roam-node-display-template
(concat "${title:50} "
(propertize "${tags:*}" 'face 'org-tag)))
;; Capture templates (default + bible)
(setq org-roam-capture-templates
'(("d" "default" plain
"%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n")
:unnarrowed t)
("b" "bible" plain
"%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n#+filetags: :bible:\n")
:unnarrowed t)
("c" "comment" plain
"%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n#+filetags: :comment:\n")
:unnarrowed t)
("s" "consideration" plain
"%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+title: ${title}\n#+filetags: :consideration:\n")
:unnarrowed t)))
:bind
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
("C-c n t" . org-roam-tag-add)
("C-c n d c" . org-roam-dailies-capture-today)
("C-c n d f" . org-roam-dailies-goto-date))
;; integrate consult with roam
(use-package consult-org-roam
:custom
;; Use `ripgrep' for searching with `consult-org-roam-search'
(consult-org-roam-grep-func #'consult-ripgrep)
:config
;; Activate the minor mode
(consult-org-roam-mode 1)
:bind
("C-c n f" . consult-org-roam-file-find)
("C-c n b" . consult-org-roam-backlinks)
("C-c n s" . consult-org-roam-search))
;; Set denote
(use-package denote
:init
;; where notes live (matches your existing org-directory)
(setq denote-directory (expand-file-name "~/org/3_resources"))
:config
;; save denote automatically
(setq denote-save-buffers 1)
;; (setq denote-file-type 'markdown-yaml)'
(setq denote-prompts '(title keywords file-type))
(setq denote-known-keywords '("meta" "tmp" "draft"))
:bind
("C-c d n" . denote)
("C-c d i" . denote-link)
:hook
(dired-mode . denote-dired-mode))
(use-package consult-denote
:config
(consult-denote-mode 1)
(setq consult-denote-grep-command #'consult-ripgrep)
:bind
("C-c d f" . consult-denote-find)
("C-c d s" . consult-denote-grep))
;;; Tempel snippet setup -----------------------------------------------------
(use-package tempel
:bind
("M-+" . tempel-complete)
("M-*" . tempel-insert)
:init
;; Define templates inline instead of in a separate file
(setq tempel-template-sources
(list (lambda ()
'(fundamental-mode
org-mode
(src "#+begin_src " (p "emacs-lisp" language) n> r> n> "#+end_src")
(typescript "#+begin_src typescript" n> r> n> "#+end_src")
(python "#+begin_src python" n> r> n> "#+end_src")))))
;; wires Tempel into Emacs's completion-at-point (capf) system for the current buffer
(defun tempel-setup-capf ()
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
;; hooks tempel to buffer
(add-hook 'org-mode-hook 'tempel-setup-capf)
:config
;; Optional: bind next/previous field navigation while a template is active
(keymap-set tempel-map "M-n" #'tempel-next)
(keymap-set tempel-map "M-p" #'tempel-previous))
;; add project.el
(use-package project
:config
(setq project-vc-extra-root-markers '(".project")))
(use-package company
:hook (eglot-managed-mode . company-mode)
:config
(setq company-minimum-prefix-length 1
company-idle-delay 0.1))
;; (use-package company
;; :init
;; (defun my/company-org-setup ()
;; (setq-local company-minimum-prefix-length 3
;; company-idle-delay 0.3
;; company-backends
;; '((company-capf company-dabbrev company-ispell)))
;; (company-mode 1))
;; :config
;; (setq company-minimum-prefix-length 1
;; company-idle-delay 0.1)
;; (add-to-list 'company-backends 'company-ispell t)
;; :hook
;; (eglot-managed-mode . company-mode)
;; (org-mode . my/company-org-setup))
(use-package eglot
:hook (python-mode . eglot-ensure))
;; formater ????
(use-package apheleia
:config
(apheleia-global-mode +1))
;; (use-package typst-ts-mode
;; :config
;; ;; Ensure the typst tree-sitter grammar is installed
;; (add-to-list 'treesit-language-source-alist
;; '(typst "https://github.com/uben0/tree-sitter-typst"))
;; (unless (treesit-language-available-p 'typst)
;; (treesit-install-language-grammar 'typst))
;; (with-eval-after-load 'eglot
;; (with-eval-after-load 'typst-ts-mode
;; (add-to-list 'eglot-server-programs
;; `((typst-ts-mode) .
;; ,(eglot-alternatives `(,typst-ts-lsp-download-path
;; "tinymist"
;; "typst-lsp"))))))
;; (keymap-set typst-ts-mode-map "C-c C-c" #'typst-ts-tmenu))
;; Setup doom-themes
(use-package doom-themes
:config
(load-theme 'doom-one t))
;; Setup nerd-icons
;;(use-package nerd-icons)
;; Setup nerd-icons-dired
;; (use-package nerd-icons-dired
;; :hook
;; (dired-mode . nerd-icons-dired-mode))
(use-package all-the-icons)
;; Run once:
;; M-x all-the-icons-install-fonts
(use-package all-the-icons-dired
:ensure t
:hook (dired-mode . all-the-icons-dired-mode))
;; Setup dashboard
(use-package dashboard
:config
(dashboard-setup-startup-hook)
;; set heading icons
(setq dashboard-set-heading-icons t)
;; set file icons
(setq dashboard-set-file-icons t)
;; Make emacsclient frames open on the dashboard
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))
;; Setup evil
;(use-package evil)
(use-package evil
:bind
("C-c v" . evil-local-mode)
("C-c C-g" . evil-normal-state)
:hook
(python-mode . evil-local-mode))
(use-package evil-surround
:config
(global-evil-surround-mode 1))
(use-package evil-commentary
:config
(evil-commentary-mode 1))
;; doom-modeline
;; (use-package doom-modeline
;; :config
;; (doom-modeline-mode))
;; Setup magit
(use-package magit
:bind
("C-c m" . magit))
;; pretier mini buffer
(use-package vertico
:ensure t
:init
(vertico-mode))
;; add anotations to mini buffer results
(use-package marginalia
:ensure t
:init
(marginalia-mode))
;; matcher for min buffer
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic)))
;; mini-buffer tools
(use-package consult
:ensure t
:bind
("C-s" . consult-line)
("C-x b" . consult-buffer)
("C-x g" . consult-ripgrep)
("C-x f" . consult-find)
("C-x r l" . consult-bookmark))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(all-the-icons consult-denote dashboard doom-themes evil magit
marginalia markdown-mode nerd-icons-dired orderless
org org-drill org-kanban org-superstar tempel
typescript-mode vertico))
'(safe-local-variable-values
'((eval setq-local org-roam-db-location
(expand-file-name "org-roam.db" org-roam-directory))
(eval setq-local org-roam-directory
(expand-file-name
(locate-dominating-file default-directory ".dir-locals.el"))))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)