blob: b5b3525bd58e330c770f9912ba9cfe4c8b1c473b (
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
|
(pixel-scroll-precision-mode 1)
(setq scroll-conservatively 101)
(display-battery-mode 1)
(setq display-time-24hr-format t)
(display-time-mode 1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(load-theme 'catppuccin :no-confirm)
(setq display-line-numbers-type 'relative)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(add-hook 'org-mode-hook #'display-line-numbers-mode)
(set-face-attribute 'default nil :height 120)
(setq use-short-answers t)
(setq make-backup-files nil)
(setq org-export-with-broken-links t)
(setq org-src-fontify-natively t)
;; (setq org-highlight-latex-and-related '(latex script entities))
(setq warning-minimum-level :emergency)
(add-hook 'text-mode-hook 'visual-line-mode)
(and window-system (server-start))
(setq debug-ignored-errors
(cons 'remote-file-error debug-ignored-errors))
(set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 140)
(setq prettify-symbols-alist
'(("#+begin_src" . ?)
("#+BEGIN_SRC" . ?)
("#+end_src" . ?)
("#+END_SRC" . ?)
("#+begin_example" . ?)
("#+BEGIN_EXAMPLE" . ?)
("#+end_example" . ?)
("#+END_EXAMPLE" . ?)
("#+header:" . ?)
("#+HEADER:" . ?)
("#+name:" . ?﮸)
("#+NAME:" . ?﮸)
("#+results:" . ?)
("#+RESULTS:" . ?)
("#+call:" . ?)
("#+CALL:" . ?)
(":PROPERTIES:" . ?)
(":properties:" . ?)))
(prettify-symbols-mode 1)
(set-frame-parameter nil 'alpha-background 90)
(add-to-list 'default-frame-alist '(alpha-background . 90))
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
(setq mouse-wheel-progressive-speed nil)
(setq mouse-wheel-follow-mouse 't)
(setq scroll-step 1)
(require 'org-habit)
(setq org-agenda-files (list "~/org/agenda.org"
"~/org/notes.org"))
(setq org-default-notes-file (concat org-directory "/notes.org"))
(setq org-habit-preceding-days 1)
(require 'ox-publish)
(setq org-publish-project-alist
'(("website-org"
:base-directory "~/org/website"
:base-extension "org"
:publishing-directory "~/website_html"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4
:html-preamble t
:html-preamble-format (("en" "<p class=\"preamble\"><a href=\"/index.html\">home</a> | <a href=\"./index.html\">section main page</a></p><hr>")))
("website-static"
:base-directory "~/org/website"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|ico"
:publishing-directory "~/website_html/"
:recursive t
:publishing-function org-publish-attachment)
("website" :auto-sitemap t :components ("website-org" "website-static"))))
;; (setq org-export-html-postamble-format '(("en" "<p class=\"preamble\"><a href=\"../index.html\">previous page</a> | <a href=\"/index.html\">home</a></p>")))
(setq org-html-postamble "Copyright © 2024 Preston Pan")
(defun electric-pair ()
"If at end of line, insert character pair without surrounding spaces.
Otherwise, just insert the typed character."
(interactive)
(if (eolp) (let (parens-require-spaces) (insert-pair)) (self-insert-command 1)))
(add-hook 'org-mode-hook
(lambda ()
(define-key org-mode-map "\"" 'electric-pair)
(define-key org-mode-map "(" 'electric-pair)
(define-key org-mode-map "[" 'electric-pair)
(define-key org-mode-map "{" 'electric-pair)))
(add-hook 'prog-mode-hook
(lambda ()
(define-key org-mode-map "\"" 'electric-pair)
(define-key org-mode-map "(" 'electric-pair)
(define-key org-mode-map "[" 'electric-pair)
(define-key org-mode-map "{" 'electric-pair)))
(add-hook 'nix-mode-hook
(lambda ()
(define-key org-mode-map "\"" 'electric-pair)
(define-key org-mode-map "(" 'electric-pair)
(define-key org-mode-map "[" 'electric-pair)
(define-key org-mode-map "{" 'electric-pair)))
(add-hook 'emacs-lisp-mode-hook
(lambda ()
(define-key org-mode-map "\"" 'electric-pair)
(define-key org-mode-map "(" 'electric-pair)
(define-key org-mode-map "[" 'electric-pair)
(define-key org-mode-map "{" 'electric-pair)))
(add-hook 'after-init-hook 'global-company-mode)
(org-babel-do-load-languages 'org-babel-load-languages
'(
(shell . t)
(python . t)
)
)
(require 'org-tempo)
(use-package evil
:init
(setq evil-want-keybinding nil)
:config
(evil-mode 1)
(evil-set-undo-system 'undo-redo))
(use-package evil-collection
:init
(setq evil-want-keybinding nil)
:config
(evil-collection-init))
(with-eval-after-load 'evil-maps
(define-key evil-motion-state-map (kbd "SPC") nil)
(define-key evil-motion-state-map (kbd "RET") nil)
(define-key evil-motion-state-map (kbd "TAB") nil))
(use-package evil-commentary
:config
(evil-commentary-mode))
(use-package evil-org
:after org
:hook (org-mode . (lambda () evil-org-mode))
:config
(require 'evil-org-agenda)
(evil-org-agenda-set-keys))
(use-package which-key
:config
(which-key-mode))
(use-package page-break-lines
:init
(page-break-lines-mode))
(use-package org-journal
:init
(setq org-journal-dir "~/org/website/journal/")
(setq org-journal-date-format "%A, %d %B %Y")
(defun org-journal-file-header-func (time)
"Custom function to create journal header."
(concat
(pcase org-journal-file-type
(`daily "#+TITLE: Daily Journal\n#+STARTUP: showeverything\n#+DESCRIPTION: My daily journal entry\n#+AUTHOR: Preston Pan\n#+HTML_HEAD: <link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" />\n#+html_head: <script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n#+html_head: <script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n#+options: broken-links:t")
(`weekly "#+TITLE: Weekly Journal\n#+STARTUP: folded")
(`monthly "#+TITLE: Monthly Journal\n#+STARTUP: folded")
(`yearly "#+TITLE: Yearly Journal\n#+STARTUP: folded"))))
(setq org-journal-file-header 'org-journal-file-header-func)
(setq org-journal-file-format "%Y%m%d.org")
(setq org-journal-enable-agenda-integration t)
)
(use-package doom-modeline
:config
(doom-modeline-mode 1))
(use-package org-superstar
:config
(add-hook 'org-mode-hook (lambda () (org-superstar-mode 1))))
(use-package eglot
:config
(add-hook 'prog-mode-hook 'eglot-ensure))
(use-package dashboard
:init
(setq dashboard-banner-logo-title "Welcome, Commander!")
(setq dashboard-icon-type 'nerd-icons)
(setq dashboard-vertically-center-content t)
(setq dashboard-set-init-info t)
(setq dashboard-week-agenda t)
(setq dashboard-items '((recents . 5)
(bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
:config
(dashboard-setup-startup-hook))
(use-package projectile
:config
(projectile-mode +1))
(use-package counsel)
(use-package ivy
:init
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
;; enable this if you want `swiper' to use it
;; (setq search-default-mode #'char-fold-to-regexp)
(global-set-key "\C-s" 'swiper)
(global-set-key (kbd "C-c C-r") 'ivy-resume)
(global-set-key (kbd "<f6>") 'ivy-resume)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
:config
(ivy-mode))
(use-package magit)
(setq
erc-nick "prestonpan"
erc-user-full-name "Preston Pan")
(defun prestonpan ()
(interactive)
(erc-tls :server "nullring.xyz"
:port "6697"))
(defun matrix-org ()
(interactive)
(ement-connect :uri-prefix "http://localhost:8009"))
(use-package gptel
:init
(setq gptel-default-mode 'org-mode)
(setq-default
gptel-model "zephyr:latest"
gptel-backend (gptel-make-ollama "Ollama"
:host "localhost:11434"
:stream t
:models '("zephyr:latest"))))
(use-package general
:config
(general-create-definer leader-key
:prefix "SPC")
(leader-key 'normal
"o a" '(org-agenda :wk "Open agenda")
"o c" '(org-capture :wk "Capture")
"n j j" '(org-journal-new-entry :wk "Make new journal entry")
"n r f" '(org-roam-node-find :wk "Find roam node")
"n r i" '(org-roam-node-insert :wk "Insert roam node")
"n r g" '(org-roam-graph :wk "Graph roam database")
"r s s" '(elfeed "rss feed")
"." '(counsel-find-file :wk "find file")
"g /" '(magit-dispatch :wk "git commands")
"g P" '(magit-push :wk "git push")
"g c" '(magit-commit :wk "git commit")
"g p" '(magit-pull :wk "Pull from git")
"o t" '(vterm :wk "Terminal")
"o e" '(eshell :wk "Elisp Interpreter")
"o m" '(mu4e :wk "Email")
"e w w" '(eww :wk "web browser")
"e c c" '(ellama-chat :wk "Chat with Ollama")
"e a b" '(ellama-ask-about :wk "Ask Ollama")
"e s" '(ellama-summarize :wk "Summarize text with Ollama")
"e c r" '(ellama-code-review :wk "Review code with Ollama")
"e c C" '(ellama-code-complete :wk "Complete code with Ollama")
"e c a" '(ellama-code-add :wk "Add code with Ollama")
"e c e" '(ellama-code-edit :wk "Edit code with Ollama")
"e w i" '(ellama-improve-wording :wk "Improve wording with Ollama")
"e g i" '(ellama-improve-grammar :wk "Improve grammar with Ollama")
"g s" '(gptel-send :wk "Send to Ollama")
"g e" '(gptel :wk "Ollama interface")
"p w" '(ivy-pass :wk "Password manager interface")
"m P p" '(org-publish :wk "Publish website components")
"s e" '(sudo-edit :wk "Edit file with sudo")
"m m" '(emms :wk "Music player")
"o p" '(treemacs :wk "Project Drawer")
"f f" '(eglot-format :wk "Format code buffer")
"i c" '(prestonpan :wk "Connect to my IRC server")
"h m" '(woman :wk "Manual")
"h r r" '(lambda () (interactive) (org-babel-load-file (expand-file-name "~/org/website/config/emacs.org")))
))
(use-package elfeed
:init
(add-hook 'elfeed-search-mode-hook #'elfeed-update)
(setq elfeed-search-filter "@1-month-ago +unread")
)
(use-package elfeed-org
:init
(setq rmh-elfeed-org-files '("~/org/website/config/elfeed.org"))
:config
(elfeed-org))
(setq search-engines
'(
(("google" "g") "https://google.com/search?q=%s")
(("duckduckgo" "d" "ddg") "https://duckduckgo.com/?q=%s")
(("rfc" "r") "https://www.rfc-editor.org/rfc/rfc%s.txt")
(("rfc-kw" "rk") "https://www.rfc-editor.org/search/rfc_search_detail.php?title=%s")))
(setq search-engine-default "google")
(setq eww-search-prefix "https://google.com/search?q=")
(setq browse-url-secondary-browser-function 'browse-url-generic browse-url-generic-program "firefox")
(setq browse-url-browser-function 'eww-browse-url)
(add-hook 'eww-mode-hook
(lambda () (local-set-key (kbd "y Y") #'eww-copy-page-url)))
(use-package org-roam
:init
(setq org-roam-db-update-on-save t)
(setq org-roam-graph-viewer "firefox")
(setq org-roam-directory (file-truename "~/org/website/mindmap"))
(setq org-roam-capture-templates '(("d" "default" plain "%?"
:target (file+head "${title}.org"
"#+title: ${title}\n#+author: Preston Pan\n#+html_head: <link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" />\n#+html_head: <script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n#+html_head: <script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n#+options: broken-links:t")
:unnarrowed t)))
:config
(org-roam-db-autosync-mode))
(use-package pinentry
:init (setq epa-pinentry-mode `loopback)
|