about summary refs log tree commit diff
path: root/modules/emacs/doom/config.el
blob: a212e17c46b9faf56a7acc3f1dab50b1dc796eb4 (plain) (blame)
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
;;
;;; Misc
;;

(setq! frame-title-format '("GNU Emacs"))

(setq-hook! '(prog-mode-hook yaml-mode-hook)
  display-line-numbers-type 'relative
  scroll-margin 10
  hscroll-margin 10)

(setq! browse-url-generic-program (executable-find "firefox")
       browse-url-browser-function 'browse-url-generic)

(use-package! xclip
  :config
  (setq xclip-program "wl-copy"
        xclip-select-enable-clipboard t
        xclip-mode t
        xclip-method 'wl-copy))

(setq! migemo-options '("--quiet" "--emacs")
       skk-show-inline t)

;;
;;; Doom-specific
;;

(setq! doom-theme 'modus-operandi
       doom-modeline-icon nil
       doom-modeline-indent-info t
       doom-modeline-total-line-number t
       doom-modeline-height 30)

;;
;;; Editorconfig
;;

(setq! +editorconfig-mode-alist '((sh-mode . "sh"))
       ;; It's never a good idea to force specific indentation rules for Lisp,
       ;; the only rule should be is not to use tabs.
       editorconfig-exclude-modes '(emacs-lisp-mode
                                    clojure-mode
                                    scheme-mode
                                    lisp-mode
                                    racket-mode
                                    fennel-mode
                                    hy-mode
                                    dune-mode))

;;
;;; LSP
;;

(setq! lsp-enable-suggest-server-download nil
       lsp-modeline-code-actions-enable nil)

;;
;;; Nix
;;

(after! nix
  (after! lsp-mode
    (add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
    (lsp-register-client (make-lsp-client
                          :new-connection (lsp-stdio-connection "nixd")
                          :activation-fn (lsp-activate-on "nix")
                          :server-id 'nixd
                          :major-modes 'nix-mode))
    (add-hook 'nix-mode-hook 'lsp-deferred)))

;;
;;; Go
;;

(setq! lsp-go-analyses '((unsedvariable . t)
                         (unusedparams . t)
                         (unusedwrite . t)))

;;
;;; Org
;;

(setq! org-directory "~/doc/org/")

;; For some reason only using `after!' work here. `setq-hook!' and etc doesn't
;; produce expected results.
(after! org
  (setq! org-todo-keywords '((sequence
                              "TODO(t)"
                              "LOOP(r)"
                              "STRT(s@)"
                              "WAIT(w@/!)"
                              "HOLD(h@/!)"
                              "IDEA(i)"
                              "PROJ(p)"
                              "|"
                              "DONE(d@/!)"
                              "KILL(k@/!)"))
         org-todo-keyword-faces '(("STRT" . +org-todo-active)
                                  ("WAIT" . +org-todo-onhold)
                                  ("HOLD" . +org-todo-onhold)
                                  ("PROJ" . +org-todo-project)
                                  ("KILL" . +org-todo-cancel))
         org-capture-templates '(("t" "Todo" entry
                                  (file+headline +org-capture-todo-file "Inbox")
                                  "* TODO %?\n%i\n%a" :prepend t)
                                 ("n" "Note" entry
                                  (file+headline +org-capture-notes-file "Inbox")
                                  "* %u %?\n%i\n%a" :prepend t)
                                 ("j" "Journal" entry
                                  (file+olp+datetree +org-capture-journal-file)
                                  "* %U %?\n%i\n%a" :prepend t))))

(add-hook! 'org-mode-hook 'auto-fill-mode)

(setq-hook! 'org-mode-hook fill-column 80)

(setq! org-roam-directory "~/doc/roam/"
       org-roam-db-location (concat org-roam-directory ".db"))

(use-package! org-roam-ui
  :requires websocket
  :after org-roam
  :config
  (setq org-roam-ui-sync-theme t
        org-roam-ui-follow t
        org-roam-ui-update-on-save t
        org-roam-ui-open-on-start t))

;;
;;; LaTeX
;;

(map! :map cdlatex-mode-map
      :i "TAB" #'cdlatex-tab)

;;
;;; PlantUML
;;

(setq! plantuml-default-exec-mode 'executable
       org-plantuml-exec-mode 'plantuml)

;;
;;; Elisp
;;

(after! flycheck
  (pushnew! flycheck-disabled-checkers 'emacs-lisp-checkdoc))

;;
;;; Haskell
;;

(setq! lsp-haskell-formatting-provider "ormolu")

;;
;;; Nickel
;;

(use-package! nickel-mode
  :config
  (after! lsp-mode
    (add-to-list 'lsp-language-id-configuration '(nickel-mode . "nickel"))
    (lsp-register-client (make-lsp-client
                          :new-connection (lsp-stdio-connection "nls")
                          :activation-fn (lsp-activate-on "nickel")
                          :server-id 'nls
                          :major-modes 'nickel-mode))
    (add-hook 'nickel-mode-hook 'lsp-deferred)))

;;
;;; YAML
;;

;; Turn off `flycheck-mode' and `lsp-mode' for Helm templates.
(add-hook! 'yaml-mode-hook
  (defun nixfiles/disable-flycheck-for-helm-templates-h ()
    (when (and buffer-file-name
               (string-match-p "/templates/" buffer-file-name)
               (or (string-suffix-p ".yaml" buffer-file-name)
                   (string-suffix-p ".yml" buffer-file-name)))
      (remove-hook! 'yaml-mode-local-vars-hook #'lsp!))))

(setq-hook! 'yaml-mode-hook +format-with-lsp nil)

;;
;;; Elfeed
;;

(setq! elfeed-db-directory "~/.elfeed"
       elfeed-enclosure-default-dir (concat elfeed-db-directory "/enclosures")
       rmh-elfeed-org-files (list (concat elfeed-db-directory "/index.org"))
       elfeed-goodies/powerline-default-separator nil
       elfeed-goodies/entry-pane-size 0.75
       elfeed-goodies/entry-pane-position 'bottom)

;;
;;; mu4e
;;

(after! mu4e
  (setq! sendmail-program (executable-find "msmtp")
         send-mail-function #'smtpmail-send-it
         message-sendmail-f-is-evil t
         message-sendmail-extra-arguments '("--read-envelope-from")
         message-send-mail-function #'message-send-mail-with-sendmail))

(setq-hook! 'mu4e-main-mode-hook mu4e-update-interval 30)

;;
;;; Circe
;;

(setq! circe-network-options
       (mapcar (lambda (server)
                 `(,server
                   :server-buffer-name ,server
                   :host "azahi.cc"
                   :port 6697
                   :tls t
                   :logging nil
                   :user ,(concat circe-default-user "/" server)
                   :pass ,(lambda (&rest _)
                            (+pass-get-secret "server/soju.shire.net/azahi"))))
               '("libera" "oftc" "hackint" "rizon")))

;;
;;; Sops
;;

(use-package! sops
  :hook (doom-first-file . global-sops-mode))

;;
;;; Hledger
;;

(use-package! hledger-mode
  :disabled
  :mode ("\\.journal\\'")
  :hook ((hledger-view-mode . hl-line-mode)
         (hledger-view-mode . center-text-for-reading))
  :init
  (setq! hledger-jfile "~/doc/accounting/current.journal")
  :config
  (set-company-backend! 'hledger-mode 'hledger-company)
  (add-hook! 'hledger-mode-hook
    (lambda (&rest _)
      (make-local-variable 'company-backends)
      (add-to-list 'company-backends 'hledger-company))))

(use-package! hledger-input
  :disabled
  :hook ((hledger-input-post-commit . hledger-show-new-balances)
         (hledger-input-mode . auto-fill-mode)
         (hledger-input-mode . (lambda (&rest _)
                                 (make-local-variable 'compay-idle-delay)
                                 (setq-local company-idle-delay 0.1))))
  :init
  (setq! hledger-input-buffer-height 20))

;;
;;; LLM
;;

(use-package! gptel
  :config
  (setq! gptel-model 'codegemma:7b
         gptel-backend (gptel-make-ollama "ollama"
                         :host "eonwe.shire.net:11434"
                         :stream t
                         :models '(dagbs/qwen2.5-coder-7b-instruct-abliterated:latest
                                   qwen2.5-coder:7b
                                   deepseek-coder-v2:16b
                                   codegemma:7b
                                   codellama:7b
                                   llama3.2:3b
                                   mistral:7b))))

(use-package! ellama
  :init
  (setq! ellama-naming-scheme 'ellama-generate-name-by-time)
  :config
  (require 'llm-ollama)
  (setq! ellama-provider (make-llm-ollama
                          :scheme "http"
                          :host "eonwe.shire.net"
                          :port 11434
                          :chat-model "llama3.2:3b"
                          :embedding-model "nomic-embed-text:latest")
         ellama-providers '(("llama" . (make-llm-ollama
                                        :scheme "http"
                                        :host "eonwe.shire.net"
                                        :port 11434
                                        :chat-model "llama3.2:3b"
                                        :embedding-model "nomic-embed-text:latest"))
                            ("codellama" . (make-llm-ollama
                                            :scheme "http"
                                            :host "eonwe.shire.net"
                                            :port 11434
                                            :chat-model "codellama:7b"
                                            :embedding-model "nomic-embed-text:latest"))
                            ("qwen" . (make-llm-ollama
                                       :scheme "http"
                                       :host "eonwe.shire.net"
                                       :port 11434
                                       :chat-model "qwen2.5:7b"
                                       :embedding-model "nomic-embed-text:latest"))
                            ("qwen-coder" . (make-llm-ollama
                                             :scheme "http"
                                             :host "eonwe.shire.net"
                                             :port 11434
                                             :chat-model "qwen2.5-coder:7b"
                                             :embedding-model "nomic-embed-text:latest"))
                            ("qwen-coder-instruct" . (make-llm-ollama
                                                      :scheme "http"
                                                      :host "eonwe.shire.net"
                                                      :port 11434
                                                      :chat-model "dagbs/qwen2.5-coder-7b-instruct-abliterated:latest"
                                                      :embedding-model "nomic-embed-text:latest"))
                            ("gemma" . (make-llm-ollama
                                        :scheme "http"
                                        :host "eonwe.shire.net"
                                        :port 11434
                                        :chat-model "gemma2:9b"
                                        :embedding-model "nomic-embed-text:latest"))
                            ("codegemma" . (make-llm-ollama
                                            :scheme "http"
                                            :host "eonwe.shire.net"
                                            :port 11434
                                            :chat-model "codegemma:7b"
                                            :embedding-model "nomic-embed-text:latest"))
                            ("mistral" . (make-llm-ollama
                                          :scheme "http"
                                          :host "eonwe.shire.net"
                                          :port 11434
                                          :chat-model "mistral:7b"
                                          :embedding-model "nomic-embed-text:latest"))
                            ("hermes" . (make-llm-ollama
                                         :scheme "http"
                                         :host "eonwe.shire.net"
                                         :port 11434
                                         :chat-model "hermes3:8b"
                                         :embedding-model "nomic-embed-text:latest"))
                            ("deepseek" . (make-llm-ollama
                                           :scheme "http"
                                           :host "eonwe.shire.net"
                                           :port 11434
                                           :chat-model "deepseek-coder-v2:16b"
                                           :embedding-model "nomic-embed-text:latest")))
         ellama-translation-provider (make-llm-ollama
                                      :scheme "http"
                                      :host "eonwe.shire.net"
                                      :port 11434
                                      :chat-model "qwen2.5:7b"
                                      :embedding-model "nomic-embed-text:latest")
         ellama-summarization-provider (make-llm-ollama
                                        :scheme "http"
                                        :host "eonwe.shire.net"
                                        :port 11434
                                        :chat-model "mistral:7b"
                                        :embedding-model "nomic-embed-text:latest")))

(use-package! magit-gptcommit
  :after magit
  :config
  (require 'llm-ollama)
  (setq! magit-gptcommit-llm-provider (make-llm-ollama
                                       :scheme "http"
                                       :host "eonwe.shire.net"
                                       :port 11434
                                       :chat-model "dagbs/qwen2.5-coder-7b-instruct-abliterated:latest"
                                       :embedding-model "nomic-embed-text:latest"))

  (magit-gptcommit-status-buffer-setup))

Consider giving Nix/NixOS a try! <3