-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
454 lines (401 loc) · 12.7 KB
/
init.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
;;; init.el --- Initialisation file for Emacs -*- lexical-binding: t; -*-
;;; Commentary:
;; Emacs Startup File --- initialisation for Emacs
;; Robert Postill's Emacs config
;;
;;; Code:
;; things that don't require packages
(setq-default default-directory "~") ; don't make me traipse all the way from / :)
(setq inhibit-startup-screen +1) ; straight to a buffer
(global-visual-line-mode 1) ; word wrapping
(show-paren-mode 1) ; highlight parentheses
(winner-mode 1) ; working with windows
(desktop-save-mode 1) ; so I can have a stack of buffers open at any one time
(tool-bar-mode -1)
(global-set-key (kbd "s-+") 'text-scale-increase)
(global-set-key (kbd "s--") 'text-scale-decrease)
(set-face-attribute 'default nil :font "Menlo-14" )
(put 'downcase-region 'disabled nil) ; yes I really would like to downcase things
(put 'upcase-region 'disabled nil) ; yes I really want to upcase regions.
(setq-default indent-tabs-mode nil) ; don't use tabs unless your major mode demands it
(fset 'yes-or-no-p 'y-or-n-p) ;; Use y/n instead of yes/no
;; suppress the error message when using dired
(when (string= system-type "darwin")
(setq dired-use-ls-dired nil))
;; custom code used by packages
;;; I pinched this straight from https://github.com/jwiegley/dot-emacs/blob/master/init.el
(eval-and-compile
(defun emacs-path (path)
(expand-file-name path user-emacs-directory)))
;; setup straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; use-package
(straight-use-package 'use-package)
(use-package el-patch
:straight t)
;; load the shell context on *nixes
(use-package exec-path-from-shell
:if (memq window-system '(mac ns))
:straight t
:config
(exec-path-from-shell-initialize))
;; solarized dark theme
(use-package solarized-theme
:straight t
:config
(load-theme 'solarized-dark t))
;; Yasnippet snippets
(use-package yasnippet
:straight t
:bind (:map yas-keymap
("C-i" . yas-next-field-or-maybe-expand))
:mode ("/\\.emacs\\.d/snippets/" . snippet-mode)
:config
(yas-load-directory (emacs-path "snippets"))
(yas-global-mode 1))
(use-package yasnippet-snippets
:straight t
:after (yasnippet))
;; Midnight mode for clearing old buffers
(use-package midnight
:straight t
:config
(midnight-delay-set 'midnight-delay 0))
;; window movement made nice
(use-package ace-window
:straight t
:bind
("C-\"" . 'ace-window))
;; subtrees, visualised
(use-package dired-subtree
:straight t
:config
(bind-keys :map dired-mode-map
("i" . dired-subtree-insert)
(";" . dired-subtree-remove)))
; better region selection
(use-package expand-region
:straight t
:bind ("C-=" . er/expand-region))
;; the best way to git
(use-package magit
:straight t
:init
(setq magit-last-seen-setup-instructions "1.4.0")
:bind
("C-x g" . 'magit-status)
:hook
(('git-commit-setup . 'git-commit-turn-on-flyspell)))
;; (use-package forge
;; :straight t
;; :after magit)
;; get some help with keybindings
(use-package which-key
:straight t
:config
(which-key-mode))
;; make ssh-agent a thing
(use-package keychain-environment
:straight t
:config
(keychain-refresh-environment))
;; CSS indent
(setq-default css-indent-offset 2)
(use-package ag
:straight t)
(use-package free-keys
:straight t)
(use-package flx
:straight t)
;; ivy and friends
(use-package ivy
:straight t
:init
:config
(setq ivy-re-builders-alist
'((read-file-name-internal . ivy--regex-fuzzy)
(counsel-find-file . ivy--regex-fuzzy)
(t . ivy--regex-fuzzy)))
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(setq ivy-count-format "(%d/%d) ")
(setq magit-completing-read-function 'ivy-completing-read)
:bind
(("\C-s" . 'swiper)
("C-c C-r" . 'ivy-resume)
("<f6>" .'ivy-resume)
("M-x" . 'counsel-M-x)
("C-c g" . 'counsel-git)
("C-c j" . 'counsel-git-grep)
("C-c k" . 'counsel-ag)
("C-x l" .'counsel-locate)))
(use-package swiper
:straight t
:after ivy
:bind ("C-M-s" . swiper)
:bind (:map swiper-map
("M-y" . yank)
("M-%" . swiper-query-replace)
("C-." . swiper-avy)
("M-c" . swiper-mc))
:bind (:map isearch-mode-map
("C-o" . swiper-from-isearch)))
(use-package counsel
:straight t
:after ivy
:demand t
:diminish
:custom (counsel-find-file-ignore-regexp
(concat "\\(\\`\\.[^.]\\|"
(regexp-opt completion-ignored-extensions)
"\\'\\)"))
:bind (("C-*" . counsel-org-agenda-headlines)
("C-x C-f" . counsel-find-file)
("C-c e l" . counsel-find-library)
("C-c e q" . counsel-set-variable)
("C-h f" . counsel-describe-function)
("C-x r b" . counsel-bookmark)
("M-x" . counsel-M-x)
;; ("M-y" . counsel-yank-pop)
("M-s f" . counsel-file-jump)
;; ("M-s g" . counsel-rg)
("M-s j" . counsel-dired-jump))
:commands counsel-minibuffer-history
:init
(bind-key "C-r" #'counsel-minibuffer-history minibuffer-local-map))
(use-package emacsql-sqlite3
:straight t)
(use-package tree-sitter
:straight t
:config
;; activate tree-sitter on any buffer containing code for which it has a parser available
(global-tree-sitter-mode)
;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx
;; by switching on and off
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
(use-package tree-sitter-langs
:straight t
:after tree-sitter)
(use-package eglot
:straight t
:config
(add-to-list 'eglot-server-programs
'((rust-ts-mode rust-mode) .
("rust-analyzer" :initializationOptions (:check (:command "clippy"))))))
;; Org usage
(use-package org
:straight t
:init
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t)))
:hook
(('org-mode-hook . 'turn-on-flyspell)))
(setq org-roam-database-connector 'sqlite)
(setq org-directory (concat (getenv "HOME") "/Dropbox/org-roam/"))
(use-package org-roam
:straight t
:custom
(org-roam-directory (file-truename org-directory))
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n i" . org-roam-node-insert)
("C-c n c" . org-roam-capture)
;; Dailies
("C-c n j" . org-roam-dailies-capture-today))
:config
(org-roam-db-autosync-mode)
(require 'org-roam-protocol))
(use-package org-roam-ui
:straight
(:host github :repo "org-roam/org-roam-ui" :branch "main" :files ("*.el" "out"))
:after org-roam
;; normally we'd recommend hooking orui after org-roam, but since org-roam does not have
;; a hookable mode anymore, you're advised to pick something yourself
;; if you don't care about startup time, use
:hook (after-init . org-roam-ui-mode)
: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))
;; terraform development
(use-package terraform-mode
:straight t
:hook (terraform-mode . terraform-format-on-save-mode))
;; nginx
(use-package nginx-mmode
:straight
(:host github :repo "ajc/nginx-mode")
:commands nginx-mode)
;; docker
(use-package dockerfile-mode
:straight t
:mode "Dockerfile[a-zA-Z.-]*\\'")
;; .env files
(use-package dotenv-mode
:straight t
:mode "\\.env\\..*\\'")
;; YAML becuase yuck
(use-package yaml-mode
:straight t
:mode "\\.ya?ml\\'")
;; Ruby/Rails
(use-package haml-mode
:straight t)
;; Javascript
(setq js-indent-level 2)
(use-package js-ts-mode
:mode "\\.js\\'")
(use-package js2-mode
:straight t)
;; Typescript
(use-package typescript-mode
:after tree-sitter
:straight t
:mode "\\.ts\\'"
:config (setq-default typescript-indent-level 2))
(use-package prettier-js
:straight t
;:hook ((js-mode . 'prettier-js-mode))
)
;;(use-package tree-sitter-jsdoc
;; :straight (:host github :repo "tree-sitter/tree-sitter-jsdoc"))
;;(use-package jsdoc
;; :straight (:host github :repo "isamert/jsdoc.el"))
(use-package flycheck
:straight t
:init (global-flycheck-mode))
(use-package company
:straight t
:init (global-company-mode)
:hook ((graphviz-dot-mode . company-mode)))
(use-package tide
:straight t
:init (setq-default typescript-indent-level 2)
:after (typescript-mode company flycheck)
:hook ((typescript-mode . tide-setup)
(typescript-mode . tide-hl-identifier-mode)
(typescript-mode . prettier-js-mode)
(before-save . tide-format-before-save)))
;; Use web-mode for tsx files
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
(use-package web-mode
:straight t
:init (setq web-mode-markup-indent-offset 2)
:init (setq web-mode-code-indent-offset 2))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)
(use-package tsi
:after tree-sitter
:straight (tsi :type git :host github :repo "orzechowskid/tsi.el")
:commands (tsi-typescript-mode tsi-json-mode tsi-css-mode)
:init
(add-hook 'typescript-mode-hook (lambda () (tsi-typescript-mode 1)))
(add-hook 'json-mode-hook (lambda () (tsi-json-mode 1)))
(add-hook 'css-mode-hook (lambda () (tsi-css-mode 1)))
(add-hook 'scss-mode-hook (lambda () (tsi-scss-mode 1))))
;; ReasonML
(use-package reason-mode
:straight t)
(use-package merlin
:straight t)
;; Markdown
(use-package markdown-mode
:straight t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
;; Projectile
(use-package projectile
:straight t
:config (projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(setq projectile-project-search-path '("~/software/")))
;; org notes on projects
(use-package org-project-capture
:bind (("C-c n p" . org-project-capture-project-todo-completing-read))
:straight (:host github :repo "colonelpanic8/org-project-capture")
:config
(progn
(setq org-project-capture-backend
(make-instance 'org-project-capture-projectile-backend)) ; Replace with your backend of choice
(setq org-project-capture-projects-file "~/org/projects.org")
(org-project-capture-single-file)))
;; LISP editing
(use-package lispy-mnemonic
:straight t
;:hook ((emacs-lisp-mode . lispy-mnemonic))
)
(use-package lispy
:straight t
;:hook (lispy-mode . lispy-mnemonic-mode)
)
;; Racket
(use-package racket-mode
:straight t
:hook ((racket-mode . racket-xp-mode)
(racket-mode . (lambda () (lispy-mode 1)))))
(use-package scribble-mode
:straight t)
;; drawing with dot
(use-package graphviz-dot-mode
:straight t
:ensure t
:config
(setq graphviz-dot-indent-width 4))
(use-package asdf
:straight (:host github :repo "tabfugnic/asdf.el")
:after (asdf-enable))
(use-package rust-mode
:straight t
:init
(setq rust-mode-treesitter-derive t)
:hook ((rust-mode . eglot-ensure)))
(use-package go-mode
:straight t)
(provide 'init)
;;; init.el ends here
(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.
'(custom-safe-themes
'("00445e6f15d31e9afaa23ed0d765850e9cd5e929be5e8e63b114a3346236c44c" "7f1d414afda803f3244c6fb4c2c64bea44dac040ed3731ec9d75275b9e831fe5" default))
'(ispell-program-name "aspell"))
(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.
)