aboutsummaryrefslogtreecommitdiff
path: root/share/home/emacs/emacs.el
blob: 31512c8dcc7e5306b51d3211b6c55616b4e81b5c (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
;;; init.el --- Initalization -*- lexical-binding: t; -*-
;;;
;;; Commentary:
;;; Various resources were used to hack together this config:
;;; - https://sanemacs.com/
;;; - https://rossabaker.com/configs/emacs/
;;;
;;; Code:

;;;;;;;;;;;;;;;;;;;;;;;
;;;     Startup     ;;;
;;;;;;;;;;;;;;;;;;;;;;;

;;; Startup - Use package ;;;

;; some packages complain if I don't have this
(use-package bind-key
  :demand t
  :bind
  (:prefix-map rab/files-map
   :prefix "C-c f")
  :bind
  (:prefix-map rab/toggles-map
   :prefix "C-c t"))

;;; Startup - Benchmarking ;;;

(use-package benchmark-init
  :ensure t
  :demand t
  :hook (after-init . benchmark-init/deactivate)
  :config
  (benchmark-init/activate))

;;; Startup - Garbage collection ;;;

(use-package gcmh
  :ensure t
  :diminish
  :init (setq gc-cons-threshold (* 80 1024 1024))
  :hook (emacs-startup . gcmh-mode))

;;; Startup - Better cache location ;;;
(use-package no-littering
  :ensure t
  :init
  (setq no-littering-etc-directory "~/.cache/emacs/etc/"
        no-littering-var-directory "~/.cache/emacs/var/")
  (when (fboundp 'startup-redirect-eln-cache)
    (startup-redirect-eln-cache
     (convert-standard-filename
      (expand-file-name  "eln-cache/" no-littering-var-directory))))
  :config
  (no-littering-theme-backups))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     Customization     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Customization - General settings ;;;

(use-package emacs
  :init
  (setq inhibit-startup-screen t
        initial-scratch-message nil
        initial-major-mode 'text-mode
        ring-bell-function 'ignore
        use-file-dialog nil)

  (tool-bar-mode -1)
  (scroll-bar-mode -1)

  (setq-default cursor-type 'bar
		frame-title-format '("%b")
		;; Use spaces, but configure tab-width for modes that use tabs
		indent-tabs-mode nil
		tab-width 2)

  (fset 'yes-or-no-p 'y-or-n-p)
  (show-paren-mode 1)            ; Show closing parens
  (global-auto-revert-mode t)    ; Auto-update buffer on file change
  (setopt create-lockfiles nil)
  (electric-pair-mode 1)         ; Autopairs
  (global-hl-line-mode)

  (defun mb/enable-line-numbers ()
    "Enable relative line numbers"
    (interactive)
    (display-line-numbers-mode)
    (setq display-line-numbers 'relative))

  (defun mb/enable-fill-column ()
    "Enable vertical ruler"
    (interactive)
    (setq fill-column 80)
    (display-fill-column-indicator-mode))

  (defun display-startup-echo-area-message ()
    (message ""))

  (global-display-line-numbers-mode)

  :hook ((prog-mode . mb/enable-line-numbers)
         (prog-mode . mb/enable-fill-column))

  :bind (("C-z" . undo)
         ("C-S-z" . undo-redo)
         ("C-x h" . previous-buffer)
         ("C-x l" . next-buffer)))

;;; Customization - Scrolling ;;;
;; TODO: Smooth scroll

;;; Customization - Theme ;;;

(use-package doom-themes
  :demand
  :config
  ;; Global settings (defaults)
  (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
        doom-themes-enable-italic t) ; if nil, italics is universally disabled
  (load-theme 'doom-laserwave t))


;;; Customization - Modeline ;;;
(use-package doom-modeline
  :ensure t
  :config (doom-modeline-mode 1))

(use-package nerd-icons
  :custom
  (nerd-icons-font-family "FiraCode Nerd Font Mono"))

(use-package nyan-mode
  :config (nyan-mode))

;;; Customization - Evil ;;;

;; Set up vi keybinds
(use-package evil
  :demand
  :hook ((prog-mode . evil-local-mode)
	 (text-mode . evil-local-mode)))

;;; Customization - Direnv support ;;;

(use-package envrc
  :ensure t
  :hook (on-first-file . envrc-global-mode))

;;; Customziation - Completion framework ;;;

(use-package helm
  :config
  (setq helm-completion-style 'emacs))
(use-package helm-mode
  :config
  (helm-mode 1))

(use-package fussy
  :config
  (push 'fussy completion-styles)
  (setq
   ;; For example, project-find-file uses 'project-files which uses
   ;; substring completion by default. Set to nil to make sure it's using
   ;; flx.
   completion-category-defaults nil
   completion-category-overrides nil))

;;; Customization - Project management ;;;

(use-package projectile
  :bind-keymap ("C-c p" . projectile-command-map)
  :config
  (projectile-mode +1))

;;; Customization - Completions ;;;

(use-package company
  :hook (prog-mode . company-mode))

;;; Customization - Syntax checking ;;;

(use-package flycheck
  :hook (prog-mode . flycheck-mode))

;;; Customization - Which key ;;;

(use-package which-key
  :init
  (setq which-key-idle-delay 0.1)
  :config
  (which-key-mode +1))

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     Languages     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Languages - Nix ;;;

(use-package nix-mode
  :mode "\\.nix\\'")

;;; Languages - Coq ;;;

(use-package proof-general
  :mode ("\\.v\\'" . coq-mode))


;;; Languages - Rust ;;;
;; TODO

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;     Useful modes     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; Useful modes - magit ;;;

(use-package magit)

;;; emacs.el ends here