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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
;;; ________ _______ __ __
;;; / | / \ / | / |
;;; $$$$$$$$/ _____ ____ ______ _______ _______ $$$$$$$ | ______ ____$$ | ______ ______ _______$$ | __
;;; $$ |__ / \/ \ / \ / |/ | $$ |__$$ |/ \ / $$ |/ \ / \ / $$ | / |
;;; $$ | $$$$$$ $$$$ |$$$$$$ /$$$$$$$//$$$$$$$/ $$ $$</$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$/$$ |_/$$/
;;; $$$$$/ $$ | $$ | $$ |/ $$ $$ | $$ \ $$$$$$$ $$ $$ $$ | $$ $$ | $$/$$ | $$ $$ | $$ $$<
;;; $$ |_____$$ | $$ | $$ /$$$$$$$ $$ \_____ $$$$$$ | $$ |__$$ $$$$$$$$/$$ \__$$ $$ | $$ \__$$ $$ \_____$$$$$$ \
;;; $$ $$ | $$ | $$ $$ $$ $$ / $$/ $$ $$/$$ $$ $$ $$ | $$ $$/$$ $$ | $$ |
;;; $$$$$$$$/$$/ $$/ $$/ $$$$$$$/ $$$$$$$/$$$$$$$/ $$$$$$$/ $$$$$$$/ $$$$$$$/$$/ $$$$$$/ $$$$$$$/$$/ $$/
;;; Minimal init.el
;;; Contents:
;;;
;;; - Basic settings
;;; - Discovery aids
;;; - Minibuffer/completion settings
;;; - Interface enhancements/defaults
;;; - Tab-bar configuration
;;; - Theme
;;; - Optional extras
;;; - Built-in customization framework
(when (< emacs-major-version 29)
(error (format "Emacs Bedrock only works with Emacs 29 and newer; you have version ~a" emacs-major-version)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Basic settings
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Package initialization
;;
;; We'll stick to the built-in GNU and non-GNU ELPAs (Emacs Lisp Package
;; Archive) for the base install, but there are some other ELPAs you could look
;; at if you want more packages. MELPA in particular is very popular. See
;; instructions at:
;;
;; https://melpa.org/#/getting-started
;;
;; You can simply uncomment the following if you'd like to get started with
;; MELPA packages quickly:
;;
(with-eval-after-load 'package
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t))
;; If you want to turn off the welcome screen, uncomment this
(setopt inhibit-splash-screen t)
(setopt initial-major-mode 'fundamental-mode) ; default mode for the *scratch* buffer
(setopt display-time-default-load-average nil) ; this information is useless for most
;; Automatically reread from disk if the underlying file changes
(setopt auto-revert-avoid-polling t)
;; Some systems don't do file notifications well; see
;; https://todo.sr.ht/~ashton314/emacs-bedrock/11
(setopt auto-revert-interval 5)
(setopt auto-revert-check-vc-info t)
(global-auto-revert-mode)
;; Save history of minibuffer
(savehist-mode)
;; Move through windows with Ctrl-<arrow keys>
(windmove-default-keybindings 'control) ; You can use other modifiers here
;; Fix archaic defaults
(setopt sentence-end-double-space nil)
;; Make right-click do something sensible
(when (display-graphic-p)
(context-menu-mode))
;; Don't litter file system with *~ backup files; put them all inside
;; ~/.emacs.d/backup or wherever
(defun bedrock--backup-file-name (fpath)
"Return a new file path of a given file path.
If the new path's directories does not exist, create them."
(let* ((backupRootDir "~/.emacs.d/emacs-backup/")
(filePath (replace-regexp-in-string "[A-Za-z]:" "" fpath )) ; remove Windows driver letter in path
(backupFilePath (replace-regexp-in-string "//" "/" (concat backupRootDir filePath "~") )))
(make-directory (file-name-directory backupFilePath) (file-name-directory backupFilePath))
backupFilePath))
(setopt make-backup-file-name-function 'bedrock--backup-file-name)
(setq epg-pinentry-mode 'loopback)
(setopt use-short-answers t)
(add-to-list 'load-path "~/.emacs.d/elisp/")
(add-to-list 'exec-path "~/.local/share/asdf/shims/")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Discovery aids
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Show the help buffer after startup
(add-hook 'after-init-hook 'help-quick)
;; which-key: shows a popup of available keybindings when typing a long key
;; sequence (e.g. C-x ...)
(use-package which-key
:ensure t
:config
(which-key-mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Minibuffer/completion settings
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; For help, see: https://www.masteringemacs.org/article/understanding-minibuffer-completion
(setopt enable-recursive-minibuffers t) ; Use the minibuffer whilst in the minibuffer
(setopt completion-cycle-threshold 1) ; TAB cycles candidates
(setopt completions-detailed t) ; Show annotations
(setopt tab-always-indent 'complete) ; When I hit TAB, try to complete, otherwise, indent
(setopt completion-styles '(basic initials substring)) ; Different styles to match input to candidates
(setopt completion-auto-help 'always) ; Open completion always; `lazy' another option
(setopt completions-max-height 20) ; This is arbitrary
(setopt completions-detailed t)
(setopt completions-format 'one-column)
(setopt completions-group t)
(setopt completion-auto-select 'second-tab)
(keymap-set minibuffer-mode-map "TAB" 'minibuffer-complete) ; TAB acts more like how it does in the shell
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Interface enhancements/defaults
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mode line information
(setopt line-number-mode t) ; Show current line in modeline
(setopt column-number-mode t) ; Show column as well
(setopt x-underline-at-descent-line nil) ; Prettier underlines
(setopt switch-to-buffer-obey-display-actions t) ; Make switching buffers more consistent
(setopt show-trailing-whitespace nil) ; By default, don't underline trailing spaces
(setopt indicate-buffer-boundaries 'left) ; Show buffer top and bottom in the margin
;; Enable horizontal scrolling
(setopt mouse-wheel-tilt-scroll t)
(setopt mouse-wheel-flip-direction t)
(setopt indent-tabs-mode nil)
(blink-cursor-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setopt cursor-type 'bar)
(pixel-scroll-precision-mode)
(add-hook 'prog-mode-hook 'display-line-numbers-mode)
(setopt display-line-numbers-width 3)
(add-hook 'text-mode-hook 'visual-line-mode)
(let ((hl-line-hooks '(text-mode-hook prog-mode-hook)))
(mapc (lambda (hook) (add-hook hook 'hl-line-mode)) hl-line-hooks))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Tab-bar configuration
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Show the tab-bar as soon as tab-bar functions are invoked
(setopt tab-bar-show 1)
;; Add the time to the tab-bar, if visible
(add-to-list 'tab-bar-format 'tab-bar-format-align-right 'append)
(add-to-list 'tab-bar-format 'tab-bar-format-global 'append)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Face
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun pinoinha/set-face ()
(set-face-attribute 'default nil :font (font-spec :family "Iosevka Nerd Font" :weight 'normal :size 18))
(load-theme 'dracula t))
(if (daemonp)
(add-hook 'server-after-make-frame-hook
'pinoinha/set-face)
(pinoinha/set-face))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Built-in customization framework
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(use-package emacs
:config
(setq major-mode-remap-alist
'((yaml-mode . yaml-ts-mode)
(bash-mode . bash-ts-mode)
(js2-mode . js-ts-mode)
(typescript-mode . typescript-ts-mode)
(json-mode . json-ts-mode)
(css-mode . css-ts-mode)
(python-mode . python-ts-mode)
(rust-mode . rust-ts-mode)
(go-mode . go-ts-mode)
(c-mode . c-ts-mode))))
(use-package recentf
:bind (("C-x C-r" . recentf-open))
:config
(setopt recentf-max-menu-items 25)
(setopt recentf-max-saved-items 25)
:hook
(after-init . recentf-mode))
(use-package org
:hook ((org-mode . visual-line-mode))
:bind (:map global-map
("C-c l s" . org-store-link)
("C-c l i" . org-insert-link-global))
:config
(require 'oc-csl) ; citation support
(add-to-list 'org-export-backends 'md)
;; Make org-open-at-point follow file links in the same window
(setf (cdr (assoc 'file org-link-frame-setup)) 'find-file)
;; Make exporting quotes better
(setq org-export-with-smart-quotes t))
(use-package org-bullets
:ensure t
:hook
(org-mode . org-bullets-mode))
(setq org-directory "~/notas")
(setq org-agenda-files '("agenda.org"))
(setopt org-agenda-include-diary t)
;; Org-refile: where should org-refile look?
(setq org-refile-targets 'FIXME)
;; Consult: Misc. enhanced commands
(use-package consult
:ensure t
:bind (
;; Drop-in replacements
("C-c M-x" . consult-mode-command)
("C-x b" . consult-buffer)
("M-y" . consult-yank-pop)
;; Searching
("M-s r" . consult-ripgrep)
("C-s" . consult-line)
("M-s L" . consult-line-multi)
("M-s o" . consult-outline)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi))
:config
;; Narrowing lets you restrict results to certain groups of candidates
(setq consult-narrow-key "<"))
(use-package embark
:ensure t
:demand t
:after avy
:bind (("C-c a" . embark-act)) ; bind this to an easy key to hit
:init
(defun bedrock/avy-action-embark (pt)
(unwind-protect
(save-excursion
(goto-char pt)
(embark-act))
(select-window
(cdr (ring-ref avy-ring 0))))
t)
;; After invoking avy-goto-char-timer, hit "." to run embark at the next
;; candidate you select
(setf (alist-get ?. avy-dispatch-alist) 'bedrock/avy-action-embark))
(use-package embark-consult
:ensure t)
;; Vertico: better vertical completion for minibuffer commands
(use-package vertico
:ensure t
:init
(vertico-mode))
(use-package vertico-directory
:after vertico
:bind (:map vertico-map
("M-DEL" . vertico-directory-delete-word)))
;; Marginalia: annotations for minibuffer
(use-package marginalia
:ensure t
:config
(marginalia-mode))
;; Popup completion-at-point
(use-package corfu
:ensure t
:init
(global-corfu-mode)
:bind
(:map corfu-map
("SPC" . corfu-insert-separator)
("C-n" . corfu-next)
("C-p" . corfu-previous)))
;; Part of corfu
(use-package corfu-popupinfo
:after corfu
:hook (corfu-mode . corfu-popupinfo-mode)
:custom
(corfu-popupinfo-delay '(0.25 . 0.1))
(corfu-popupinfo-hide nil)
:config
(corfu-popupinfo-mode))
;; Make corfu popup come up in terminal overlay
(use-package corfu-terminal
:if (not (display-graphic-p))
:ensure t
:config
(corfu-terminal-mode))
;; Fancy completion-at-point functions; there's too much in the cape package to
;; configure here; dive in when you're comfortable!
(use-package cape
:ensure t
:init
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file))
;; Pretty icons for corfu
(use-package kind-icon
:if (display-graphic-p)
:ensure t
:after corfu
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
;; Orderless: powerful completion style
(use-package orderless
:ensure t
:config
(setq completion-styles '(orderless)))
;; Modify search results en masse
(use-package wgrep
:ensure t
:config
(setq wgrep-auto-save-buffer t))
(use-package eglot
;; no :ensure t here because it's built-in
;; Configure hooks to automatically turn-on eglot for selected modes
:hook
(rust-ts-mode . eglot-ensure)
:custom
(eglot-send-changes-idle-time 0.5)
(eglot-extend-to-xref t)
:config
(fset #'jsonrpc--log-event #'ignore)
;; Sometimes you need to tell Eglot where to find the language server
; (add-to-list 'eglot-server-programs
; '(haskell-mode . ("haskell-language-server-wrapper" "--lsp")))
)
(use-package treesit-auto
:custom
(treesit-auto-install 'prompt)
:ensure t
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
;; Magit: best Git client to ever exist
(use-package magit
:ensure t
:bind (("C-x g" . magit-status)))
(use-package git-gutter
:ensure t
:hook (prog-mode . git-gutter-mode)
:config
(setopt git-gutter:update-interval 1))
(use-package markdown-mode
:hook ((markdown-mode . visual-line-mode)))
(use-package yaml-mode
:ensure t)
(use-package json-mode
:ensure t)
(defun set-exec-path-from-shell-PATH ()
"Set up Emacs' `exec-path' and PATH environment variable to match
that used by the user's shell.
This is particularly useful under Mac OS X and macOS, where GUI
apps are not started from a shell."
(interactive)
(let ((path-from-shell (replace-regexp-in-string
"[ \t\n]*$" "" (shell-command-to-string
(if (string= (getenv "SHELL") "/bin/fish")
"$SHELL --login -c 'string join : $PATH'"
"$SHELL --login -c 'echo $PATH'")))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(set-exec-path-from-shell-PATH)
(defun sudo-find-file (filename)
(interactive "Find file as sudo: ")
(find-file (concat "/sudo::" filename)))
(use-package avy
:ensure t
:demand t
:init
(setq avy-timeout-seconds 1.0)
:bind (("C-;" . avy-goto-char-timer)))
(use-package dracula-theme :ensure t)
(use-package vterm
:ensure t
:commands vterm
:config
(setq term-prompt-regexp "^[^#$%>\n]*[#$%>] *")
(setq vterm-shell "/bin/fish")
(setq vterm-max-scrollback 10000))
(use-package vterm-toggle
:ensure t
:after vterm)
(use-package smartparens-mode
:ensure smartparens
:hook (prog-mode text-mode markdown-mode org-mode)
:config
(require 'smartparens-config))
(use-package meow
:ensure t
:init
(defun meow-setup ()
(setopt meow-use-clipboard t)
(define-key meow-normal-state-keymap (kbd "i") nil)
(define-key meow-normal-state-keymap (kbd "a") nil)
;; -------------------- ;;
;; THING TABLE ;;
;; -------------------- ;;
(meow-thing-register 'angle
'(pair ("<") (">"))
'(pair ("<") (">")))
(setq meow-char-thing-table
'((?f . round)
(?d . square)
(?s . curly)
(?a . angle)
(?r . string)
(?v . paragraph)
(?c . line)
(?x . buffer)))
;; -------------------- ;;
;; MAPPINGS ;;
;; -------------------- ;;
(meow-define-keys 'normal
'("0" . meow-expand-0)
'("1" . meow-expand-1)
'("2" . meow-expand-2)
'("3" . meow-expand-3)
'("4" . meow-expand-4)
'("5" . meow-expand-5)
'("6" . meow-expand-6)
'("7" . meow-expand-7)
'("8" . meow-expand-8)
'("9" . meow-expand-9)
'("/" . meow-reverse)
'("o" . meow-prev)
'("e" . meow-next)
'("n" . meow-left)
'("i" . meow-right)
'("z" . meow-search)
'("." . meow-visit)
'("O" . meow-prev-expand)
'("E" . meow-next-expand)
'("N" . meow-left-expand)
'("I" . meow-right-expand)
'("x" . meow-back-word)
'("X" . meow-back-symbol)
'("u" . meow-next-word)
'("U" . meow-next-symbol)
'("c" . meow-mark-word)
'("C" . meow-mark-symbol)
'("r" . meow-line)
'("R" . meow-goto-line)
'("l" . meow-block)
'("w" . meow-join)
'("b" . meow-grab)
'("B" . meow-pop-grab)
'("h" . meow-swap-grab)
'("H" . meow-sync-grab)
'(";" . meow-cancel-selection)
'(":" . meow-pop-selection)
'("ç" . meow-cancel-selection)
'("Ç" . meow-pop-selection)
'("v" . meow-till)
'("j" . meow-find)
'("/" . meow-beginning-of-thing)
'("," . meow-end-of-thing)
'("?" . meow-inner-of-thing)
'("<" . meow-bounds-of-thing)
'("s" . meow-kill)
'("t" . meow-change)
'("k" . meow-delete)
'("g" . meow-save)
'("d" . meow-yank)
'("D" . meow-yank-pop)
'("y" . meow-insert)
'("Y" . meow-open-above)
'("P" . meow-append)
'("P" . meow-open-below)
'("f" . undo-only)
'("F" . undo-redo)
'("q" . open-line)
'("Q" . split-line)
'("[" . indent-rigidly-left-to-tab-stop)
'("]" . indent-rigidly-right-to-tab-stop)
'("mt" . meow-comment)
'("mk" . meow-start-kmacro-or-insert-counter)
'("mp" . meow-start-kmacro)
'("my" . meow-end-or-call-kmacro)
'("at" . save-buffer)
'("aT" . save-some-buffers)
'("as" . meow-query-replace-regexp)
'("<escape>" . ignore)
(meow-leader-define-key
'("t" . vterm-toggle-cd)
'("bs" . consult-buffer)
'("bk" . kill-buffer)
'("vs" . magit-status)
'("pb" . project-list-buffers)
'("pp" . project-switch-project)
'("pd" . project-find-dir)
'("pf" . project-find-file)
'("ff" . find-file)
'("fs" . sudo-find-file)
'("fr" . recentf-open))))
:config
(meow-setup)
(meow-global-mode 1))
(use-package fish-mode
:ensure t)
(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.
'(auth-source-save-behavior nil)
'(custom-safe-themes
'("603a831e0f2e466480cdc633ba37a0b1ae3c3e9a4e90183833bc4def3421a961" default))
'(package-selected-packages
'(git-gutter vterm-toggle fish-completion fish-mode org-bullets smartparens meow vterm dracula-theme treesit-auto org-roam-ui json-mode yaml-mode magit wgrep orderless kind-icon cape corfu-terminal corfu marginalia vertico embark-consult embark consult avy which-key)))
(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.
)
|