-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.el
454 lines (401 loc) · 19.4 KB
/
config.el
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
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;; (after! PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Sylvain Bougerel"
user-mail-address "[email protected]")
;; Fonts
;;
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-unicode-font' -- for unicode glyphs
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
(setq doom-font-increment 1)
(if (featurep :system 'macos)
(setq doom-font (font-spec :family "JetBrainsMono Nerd Font" :size 14 :weight 'light)
doom-big-font (font-spec :family "JetBrainsMono Nerd Font" :size 20)
doom-variable-pitch-font (font-spec :family "Source Serif Pro" :size 16)
doom-serif-font (font-spec :family "JetBrainsMono Nerd Font" :size 14 :weight 'bold))
(setq doom-font (font-spec :family "JetBrainsMono Nerd Font" :size 22)
doom-big-font (font-spec :family "JetBrainsMono Nerd Font" :size 32)
doom-variable-pitch-font (font-spec :family "Source Serif Pro" :size 26)
;; 'fixed-pitch-serif' face is generally for emphasis only
doom-serif-font (font-spec :family "JetBrainsMono Nerd Font" :size 22 :weight 'bold)))
(after! org-faces
(dolist
(attr
'((org-document-title 1.6 bold)
(org-level-1 1.5 semi-bold)
(org-level-2 1.4 semi-bold)
(org-level-3 1.3 normal)
(org-level-4 1.2 normal)
(org-level-5 1.1 normal)
(org-level-6 1.0 normal)
(org-level-7 1.0 normal)
(org-level-8 1.0 normal)))
(set-face-attribute (nth 0 attr) nil :weight (nth 2 attr) :height (nth 1 attr)))
(set-face-attribute 'org-table nil :weight 'normal :height 1.0))
(after! mixed-pitch
(setq mixed-pitch-set-height t))
(after! (:and mixed-pitch org-faces)
(add-to-list 'mixed-pitch-fixed-pitch-faces 'org-drawer))
(defvar-keymap doom-font-size-repeat-map
:doc "Keymap to repeat doom font-size sequences. Used in `repeat-mode'."
:repeat t
"+" #'doom/increase-font-size
"-" #'doom/decrease-font-size)
(map! (:leader
(:desc "Increase font" "+" #'doom/increase-font-size
:desc "Decrease font" "-" #'doom/decrease-font-size)))
;; Editing
;;
(after! eglot
(advice-add 'eglot--signal-textDocument/didOpen :override
(lambda ()
"Send textDocument/didOpen to server."
(eglot--track-changes-fetch eglot--track-changes)
(setq eglot--recent-changes nil
eglot--versioned-identifier 0
eglot--TextDocumentIdentifier-cache nil)
(jsonrpc-notify
(eglot--current-server-or-lose)
:textDocument/didOpen `(:textDocument ,(eglot--TextDocumentItem))))))
;; This is temporary, until Emacs ships with treesitter's grammars
(use-package! treesit-auto
:config
(setq treesit-auto-langs '(tsx typescript json))
;; This could take a long time at installation, so use manually.
;;(treesit-auto-install-all)
(treesit-auto-add-to-auto-mode-alist 'all))
(after! typescript-ts-mode
(add-hook! 'typescript-ts-base-mode-hook
#'npm-mode
#'rainbow-delimiters-mode
(lambda ()
;; Function below is an extract from Emacs30.0.50 source:
(defun c-ts-common-comment-indent-new-line (&optional soft)
"Break line at point and indent, continuing comment if within one.
This is like `comment-indent-new-line', but specialized for C-style //
and /* */ comments. SOFT works the same as in
`comment-indent-new-line'."
;; I want to experiment with explicitly listing out all each cases and
;; handle them separately, as opposed to fiddling with `comment-start'
;; and friends. This will have more duplicate code and will be less
;; generic, but in the same time might save us from writing cryptic
;; code to handle all sorts of edge cases.
;;
;; For this command, let's try to make it basic: if the current line
;; is a // comment, insert a newline and a // prefix; if the current
;; line is in a /* comment, insert a newline and a * prefix. No
;; auto-fill or other smart features.
(let ((insert-line-break
(lambda ()
(delete-horizontal-space)
(if soft
(insert-and-inherit ?\n)
(newline 1)))))
(cond
;; Line starts with //, or ///, or ////...
;; Or //! (used in rust).
((save-excursion
(beginning-of-line)
(re-search-forward
(rx "//" (group (* (any "/!")) (* " ")))
(line-end-position)
t nil))
(let ((offset (- (match-beginning 0) (line-beginning-position)))
(whitespaces (match-string 1)))
(funcall insert-line-break)
(delete-region (line-beginning-position) (point))
(insert (make-string offset ?\s) "//" whitespaces)))
;; Line starts with /* or /**.
((save-excursion
(beginning-of-line)
(re-search-forward
(rx "/*" (group (? "*") (* " ")))
(line-end-position)
t nil))
(let ((offset (- (match-beginning 0) (line-beginning-position)))
(whitespace-and-star-len (length (match-string 1))))
(funcall insert-line-break)
(delete-region (line-beginning-position) (point))
(insert
(make-string offset ?\s)
" *"
(make-string whitespace-and-star-len ?\s))))
;; Line starts with *.
((save-excursion
(beginning-of-line)
(looking-at (rx (group (* " ") (any "*|") (* " ")))))
(let ((prefix (match-string 1)))
(funcall insert-line-break)
(delete-region (line-beginning-position) (point))
(insert prefix)))
;; Line starts with whitespaces or no space. This is basically the
;; default case since (rx (* " ")) matches anything.
((save-excursion
(beginning-of-line)
(looking-at (rx (* " "))))
(let ((whitespaces (match-string 0)))
(funcall insert-line-break)
(delete-region (line-beginning-position) (point))
(insert whitespaces))))))
(setq-local comment-line-break-function
#'c-ts-common-comment-indent-new-line)))
(add-hook! 'typescript-ts-mode-hook #'eglot-ensure)
(add-hook! 'tsx-ts-mode-hook #'eglot-ensure)
)
(after! json-ts-mode
(add-hook! 'json-mode-hook #'doom--enable-+javascript-npm-mode-in-json-mode-h))
(after! doom-editor
;; Doom thinks this is expensive, but I can't leave with having to scroll
;; horizontally due to me displaying multiple vertical windows. Wrapping lines
;; lifts this inconvenience.
(setq-default truncate-lines nil)
;; Given the above, I got used to wrapping at any point in the line.
(setq-default word-wrap nil)
;; Given that I regularly dispay 3 to 4 vertical buffers, I find 60 is good
;; limit.
(setq-default truncate-partial-width-windows 60))
(after! (:and elisp-mode doom-editor)
(add-hook 'emacs-lisp-mode-hook (lambda () (setq sentence-end-double-space t))))
(use-package! hideshow
:hook (prog-mode . hs-minor-mode)
)
(after! hideshow
(map! :leader
(:prefix ("h" . "hide/show")
:desc "Toggle hidding block" "h" #'hs-toggle-hiding
:desc "Hide all blocks" "a" #'hs-hide-all
:desc "Show all blocks" "A" #'hs-show-all
:desc "Hide blocks below" "l" #'hs-hide-level
)))
;; UI, Look & Feel
;;
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)
;; Enable mixed-pitch-mode for Org-mode, Org-roam and Markdown
(use-package! mixed-pitch
:hook ((org-mode . mixed-pitch-mode)
(markdown-mode . mixed-pitch-mode)))
(after! emojify
;; Enable only when needed, e.g. text modes
(mapc (lambda (m)
(add-to-list 'emojify-inhibit-major-modes m))
'(rust-mode json-mode typescript-mode prog-mode)
))
;; Navigation
;;
(put 'scroll-left 'disabled t)
(repeat-mode)
(map! "C-S-y" (cmd!
(beginning-of-line)
(yank)))
;; Org-mode and Org-roam configuration
;;
;; Setup to make Org, Org-roam and Org-roam-dailies work together nicely, with
;; Logseq. Switch most of the workflow to Org-roam, but keep the Org-agenda.
;;
;; - Logseq uses the same directory as Org-roam
;; - Org-agenda searches the Org-roam directory
;;
;; My Org-roam notes are version controlled, and the push-pull workflow is being
;; worked on. The Notes directory should contains all the "graphs" (with the
;; default one being "roam/").
(setq org-directory "~/Notes/"
org-roam-directory (file-truename (file-name-concat org-directory "roam/"))
org-attach-id-dir (expand-file-name "assets" org-roam-directory)
org-attach-auto-tag nil
org-roam-dailies-directory "journals/")
(after! org
(setq org-log-done 'time
org-log-into-drawer t
org-hide-emphasis-markers t
org-startup-with-inline-images t
org-ellipsis " ▼"
;; Override the default Doom keywords settings
org-todo-keywords '((sequence "TODO(t)" "IDEA(i)" "DOING(n!)" "STRT(s!)" "HOLD(h!)" "|" "DONE(d!)" "KILL(k!)")
(sequence "[ ](T)" "[-](S)" "[?](W)" "|" "[X](D)"))))
(after! org-agenda
;; TODO the list below is extremely long and slow, need to build it from an org-roam-db-query instead
(setq org-agenda-files
(append (list org-directory org-roam-directory)
(mapcar (lambda (dir)
(file-truename (file-name-concat org-roam-directory dir)))
'("pages/" "journals/")))))
(after! org-roam
(setq
org-roam-database-connector 'sqlite-builtin
org-roam-file-exclude-regexp "\\.git/.*\\|logseq/.*$"
org-roam-capture-templates
'(("d" "default" plain
"%?"
;; Accomodates for the fact that Logseq uses the "pages" directory
:target (file+head "pages/${slug}.org" "#+title: ${title}\n")
:unnarrowed t)
("b" "blog" plain
"%?"
;; Accomodates for the fact that Logseq uses the "pages" directory
:target (file+head "pages/${slug}.org"
"#+title: ${title}\n#+filetags: :blog:\n* ${title} :@blog:\n:PROPERTIES:\n:EXPORT_FILE_NAME: ${slug}\n:END:\n")
:unnarrowed t))
org-roam-dailies-capture-templates
'(("d" "default" entry
"* %?"
:target (file+head "%<%Y-%m-%d>.org"
"#+title: %<%Y-%m-%d>\n")))
org-roam-mode-sections '(org-roam-backlinks-section
org-roam-reflinks-section
org-roam-unlinked-references-section))
;; Merge ~org-roam~ bindings with module ~:lang org~ keybindings in localleader map
(map! :map org-mode-map
:localleader
"D" #'org-roam-demote-entire-buffer
"i" #'org-roam-node-insert
;; Unbinds all settings from ~modules/lang/org/contrib/roam2.el~
"m" #'org-toggle-item
"r" #'org-roam-refile
"R" #'org-roam-link-replace-all
(:prefix ("o" . "node properties")
"." #'org-set-property
"a" #'org-roam-alias-add
"A" #'org-roam-alias-remove
"q" #'org-set-tags-command
"t" #'org-roam-tag-add
"T" #'org-roam-tag-remove
"r" #'org-roam-ref-add
"R" #'org-roam-ref-remove
)))
(after! (:and org-roam popup)
;; Display the popup buffer below the current window, by slpitting the window
;; NOTE Should this be automated for all ~@pages~ buffers?
;; NOTE Doom Emacs does not seem to allow creation of normal windows
(set-popup-rules!
`(("\\*org-roam\\*"
:actions (display-buffer-below-selected)
:size 0.33 :ttl nil :modeline nil :quit nil :slot 1 :select nil)
("^\\*org-roam: "
:actions (display-buffer-below-selected)
:size 0.33 :ttl nil :modeline nil :quit nil :slot 2 :select nil))))
(map! :leader
;; Overwrite default keybindings of Org from Doom Emacs to add Org-roam autoloads
"n" nil ; Unbind settings from ~modules/config/default/+emacs-bindings.el~
(:prefix ("n" . "notes")
:desc "Search notes for symbol" "." #'+default/search-notes-for-symbol-at-point
:desc "Sync database" "-" #'org-roam-db-sync
:desc "Find ref" "/" #'org-roam-ref-find
:desc "Org agenda" "a" #'org-agenda
(:when (modulep! :tools biblio)
:desc "Bibliographic notes" "b"
(cond ((modulep! :completion vertico) #'citar-open-notes)
((modulep! :completion ivy) #'ivy-bibtex)
((modulep! :completion helm) #'helm-bibtex)))
:desc "Toggle last org-clock" "c" #'+org/toggle-last-clock
:desc "Cancel current org-clock" "C" #'org-clock-cancel
(:prefix ("d" . "by date")
:desc "Goto previous note" "b" #'org-roam-dailies-goto-previous-note
:desc "Goto date" "d" #'org-roam-dailies-goto-date
:desc "Capture date" "D" #'org-roam-dailies-capture-date
:desc "Goto next note" "f" #'org-roam-dailies-goto-next-note
:desc "Find directory" "F" #'org-roam-dailies-find-directory
:desc "Goto tomorrow" "m" #'org-roam-dailies-goto-tomorrow
:desc "Capture tomorrow" "M" #'org-roam-dailies-capture-tomorrow
:desc "Capture today" "n" #'org-roam-dailies-capture-today
:desc "Goto today" "t" #'org-roam-dailies-goto-today
:desc "Capture today" "T" #'org-roam-dailies-capture-today
:desc "Goto yesterday" "y" #'org-roam-dailies-goto-yesterday
:desc "Capture yesterday" "Y" #'org-roam-dailies-capture-yesterday)
(:when (modulep! :ui deft)
:desc "Open deft" "D" #'deft)
(:when (modulep! :lang org +noter)
:desc "Org noter" "e" #'org-noter)
:desc "Find node" "f" #'org-roam-node-find
:desc "Browse notes" "F" #'+default/browse-notes
:desc "Show graph" "g" #'org-roam-graph
:desc "Insert node" "i" #'org-roam-node-insert
:desc "Goto today" "j" #'org-roam-dailies-goto-today
:desc "Capture today" "J" #'org-roam-dailies-capture-today
:desc "Capture new node" "n" #'org-roam-capture
:desc "Active org-clock" "o" #'org-clock-goto
:desc "Toggle roam buffer" "r" #'org-roam-buffer-toggle
:desc "Dedicated roam buffer" "R" #'org-roam-buffer-display-dedicated
:desc "Search notes" "s" #'+default/org-notes-search
;; TODO Optimize with proper queries when org is used
:desc "Todo list" "t" #'org-todo-list
;; Terribly slow (based of ~org-agenda~), avoid.
;; :desc "Tags search" "m" #'org-tags-view
;; :desc "Search org agenda headlines" "S" #'+default/org-notes-headlines
;; :desc "View search" "v" #'org-search-view
:desc "Org export to clipboard" "y" #'+org/export-to-clipboard
:desc "Org export to clipboard as RTF" "Y" #'+org/export-to-clipboard-as-rich-text))
;; Assistants
;;
(after! spell-fu
;; Requires aspell for spell checking.
(setq spell-fu-idle-delay 0.5)) ; default is 0.25
(after! flycheck
(setq-default flycheck-disabled-checkers
;; Disable proselint for now, it's very noisy, esp. with org-mode.
'(proselint)))
;; Versioning and utilities
;;
(use-package! autosync-magit)
(use-package! logseq-org-roam
:config
(add-hook 'logseq-org-roam-updated-hook #'org-roam-db-sync))
;; Major modes settings
;;
(after! dap-mode
(setq dap-python-debugger 'debugpy))