-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
573 lines (480 loc) · 18.8 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
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
;;; init.el -- Non-site-specific initialization -*- lexical-binding: t; -*-
;; Copyright © 2024 A. Lloyd Flanagan
;;
;; Author: A. Lloyd Flanagan <lloyd.flanagan@proton.me>
;; Maintainer: A. Lloyd Flanagan <lloyd.flanagan@proton.me>
;; Created: 2014
;; Version: ??
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;; This file is not part of GNU Emacs.
;;; Commentary:
;; see repository file README.md
;;; Code:
;; contents of .config/emacs/init.el: (load "~/.config/emacs/my_emacs/init")
;; custom lisp directory
(let ((default-directory (directory-file-name (concat (expand-file-name user-emacs-directory) "my_emacs/lisp"))))
(add-to-list 'load-path default-directory)
(normal-top-level-add-subdirs-to-load-path))
;; this needs to go first so it can affect rest of the file. It also needs some setup?
;; see my_emacs/lisp/no-littering/migrate.org
;; (require 'no-littering)
(require 'alf-alists (directory-file-name (concat (expand-file-name user-emacs-directory) "my_emacs/lisp/alists")))
(require 'secrets)
;; various settings gleaned from package better-defaults
(ido-mode t)
(setopt ido-enable-flex-matching t)
;; these modes are discouraged because they use mouse -- keep hands on the keyboard!
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(require 'uniquify)
(save-place-mode t)
(show-paren-mode 1)
(global-auto-revert-mode 1)
(keymap-set global-map "M-/" 'hippie-expand)
(keymap-set global-map "C-x C-b" 'ibuffer)
(keymap-set global-map "C-s" 'isearch-forward-regexp)
(keymap-set global-map "C-r" 'isearch-backward-regexp)
(keymap-set global-map "C-M-s" 'isearch-forward)
(keymap-set global-map "C-M-r" 'isearch-backward)
(setq-default indent-tabs-mode nil)
(setopt
apropos-do-all
t
backup-directory-alist
`(("." . ,(concat user-emacs-directory "backups")))
column-number-mode
t
custom-file
(concat user-emacs-directory "my_emacs/custom.el")
default-frame-alist
'((horizontal-scroll-bars) (vertical-scroll-bars) (width . 180) (height . 70)) ;; see also early-init.el
mouse-yank-at-point
t
save-interprogram-paste-before-kill
t
save-place-file
(concat user-emacs-directory "places")
select-enable-clipboard
t
select-enable-primary
t
sentence-end-double-space
nil
uniquify-buffer-name-style
'post-forward-angle-brackets
user-email-address
"lloyd.flanagan@proton.me"
selection-coding-system
'utf-8)
(load custom-file)
;; Fix directories
;; get HOME directory
;; check entries in org-agenda-files to see if they are in subdirs of HOME
;; if not, substitute actual home dir for home in variable (tricky-ish)
;; and this needs to be added to use-package so org-agenda-files exists
;; (let ((home-dir (getenv "HOME")))(dolist (agenda-file org-agenda-files))
;; (if (not (or (void agenda-file) (string-prefix-p home-dir agenda-file)))
;; (print agenda-file)))
;;; Packages
;;; Eventual goal is to remove from customization entirely, and use use-package for all.
;; ... except in practice it's easier to add from list-packages and thus it sets variable
;; package-select-packages anyway -- should we advise use-package to do that also??
;; heck, why not rewrite list-packages so insert adds a use-package declaration to a
;; section of this file?
;; first we add melpa archive (use with caution!)
(setq package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
;; set up use-package
;; so I don't have to specify :ensure t on every call
(require 'use-package-ensure)
(setq use-package-always-ensure t)
(package-initialize)
;;; Use Packages
;; KEEP THIS SORTED!
(use-package all-the-icons :if (display-graphic-p))
(use-package bbdb :defer t)
(use-package
casual-info
:defer t
:bind
(:map
Info-mode-map ("C-o" . casual-info-tmenu) ("M-[" . Info-history-back)
;; Use web-browser history navigation bindings
("M-]" . Info-history-forward)
;; Bind p and n to paragraph navigation
("p" . casual-info-browse-backward-paragraph) ("n" . casual-info-browse-forward-paragraph)
;; Bind h and l to navigate to previous and next nodes
;; Bind j and k to navigate to next and previous references
("h" . Info-prev) ("j" . Info-next-reference) ("k" . Info-prev-reference) ("l" . Info-next)
;; Bind / to search
("/" . Info-search)
;; Set Bookmark
("B" . bookmark-set))
:hook ((Info-mode . hl-line-mode) (Info-mode . scroll-lock-mode)))
(use-package coffee-mode :defer t)
;; don't load company until a source file has loaded (check: startup load of org file doesn't load it)
(use-package company :hook prog-mode)
(use-package company-terraform :defer t)
(use-package company-web :defer t)
(use-package csv-mode :defer t)
(use-package dashboard-hackernews)
(use-package
dashboard
:after
dashboard-hackernews
page-break-lines
:custom
(dashboard-items '((recents . 5) (bookmarks . 5) (projects . 10) (agenda . 5)))
(dashboard-startupify-list
'(dashboard-insert-banner
dashboard-insert-newline
dashboard-insert-banner-title
dashboard-insert-newline
dashboard-insert-init-info
dashboard-insert-items
dashboard-insert-newline
(lambda () (dashboard-hackernews-insert 5))
dashboard-insert-newline
dashboard-insert-footer))
(dashboard-banner-logo-title "My Dashboard")
(dashboard-startup-banner 'logo)
(dashboard-set-init-info t)
;; dashboard-set-heading-icons t
(dashboard-set-file-icons t)
;; somehow this was getting set to nil?
(dashboard-heading-icons
'((recents . "history")
(bookmarks . "bookmark")
(agenda . "calendar")
(projects . "rocket")
(hackernews . "hacker-news")))
;; (hackernews . (all-the-icons-faicon "hacker-news")))
(dashboard-icon-type 'all-the-icons)
(dashboard-projects-backend 'projectile)
(dashboard-center-content t)
(dashboard-week-agenda t)
:config (dashboard-setup-startup-hook))
(use-package devdocs :defer t)
(use-package dockerfile-mode :defer t)
(use-package
dogears
:config (dogears-mode 1)
:bind
(:map
global-map
("M-g d" . dogears-go)
("M-g M-b" . dogears-back)
("M-g M-f" . dogears-forward)
("M-g M-d" . dogears-list)
("M-g M-D" . dogears-sidebar)
("M-g M-r" . dogears-remember)))
(use-package editorconfig :config (editorconfig-mode 1))
(use-package eldoc :defer t :hook (typescript-ts-mode python-ts-mode))
(use-package easysession :defer t)
(use-package eldoc-box :defer t :after eldoc)
(use-package
elisp-autofmt
:defer t
:commands (elisp-autofmt-mode elisp-autofmt-buffer)
:hook ((emacs-lisp-mode . elisp-autofmt-mode) (lisp-data-mode . elisp-autofmt-mode))
:bind (:map lisp-mode-shared-map (("C-c f" . elisp-autofmt-buffer))))
(use-package elpy :defer t :init (advice-add 'python-mode :before 'elpy-enable))
(use-package emacsql :defer t)
(use-package emacsql-pg :defer t :after 'emacsql)
(use-package emmet-mode :hook html-mode)
(use-package erblint)
;; also check out package 'ligature'
(use-package
fira-code-mode
;; == and === come out as set operators on linux?
:custom (fira-code-mode-disabled-ligatures '("[]" "===" "==" ":")) ; ligatures you don't want
:hook prog-mode) ; mode to enable fira-code-mode in
;; Flycheck
(use-package flycheck :hook ((after-init . global-flycheck-mode)) :pin "nongnu")
(use-package form-feed-st :hook (emacs-lisp-mode lisp-data-mode))
(use-package graphql-doc :defer t)
(use-package graphql-ts-mode :defer t)
(use-package highlight-parentheses)
(use-package inf-ruby :defer t)
(use-package ivy :config (ivy-mode 1))
(use-package
lsp-mode
:defer t
:commands lsp
;; it's preferable, I think, to set lsp-mode in each mode's use-package, but some don't have one
:hook (ruby-base-mode python-ts-mode))
(use-package lsp-origami :hook ((lsp-after-open . lsp-origami-try-enable)))
; why is this not registering with lsp??
(use-package
lsp-sourcekit
:after lsp-mode
:config
;; TODO: we need to figure out how to set this up on non-Mac machines
(setq lsp-sourcekit-executable (string-trim (shell-command-to-string "xcrun --find sourcekit-lsp"))))
;; (setq lsp-sourcekit-executable "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/sourcekit-lsp"))
;; "unavailable" ???
;; (use-package lsp-treemacs: :after lsp-mode)
(use-package lsp-ui :after lsp-mode)
(use-package magit :defer t)
(use-package magit-todos :defer t)
(use-package
markdown-mode
:mode ("README\\.md\\'" . gfm-mode)
:init
; flycheck uses markdownlint, but generates very annoying error message instead of useful checks
(flycheck-mode 0)
:custom
(markdown-code-lang-modes
'(("ocaml" . tuareg-mode) ("elisp" . emacs-lisp-mode) ("ditaa" . artist-mode) ("asymptote" . asy-mode)
("dot" . fundamental-mode) ("sqlite" . sql-mode) ("calc" . fundamental-mode) ("C" . c-mode) ("cpp" . c++-mode)
("C++" . c++-mode) ("screen" . shell-script-mode) ("shell" . sh-mode) ("bash" . sh-mode) ("sh" . sh-mode)))
(markdown-command "/Users/adrianflanagan/bin/markdown2"))
(use-package minitest :hook ruby-base-mode)
(use-package ng2-mode :defer t)
(use-package nodejs-repl)
;; org-mode packages
(use-package
org
:pin "gnu"
:bind (("C-c l" . org-store-link) ("C-c a" . org-agenda) ("C-c c" . org-capture))
:custom
(org-adapt-indentation 'headline-data)
(org-ctrl-k-protect-subtree t)
(org-special-ctrl-a/e t)
(org-return-follows-link t))
(use-package org-beautify-theme)
(use-package
org-contacts
:defer t
;; :config
;; (push org-capture-templates
;; '("c" "Contacts" entry (file "~/org/contacts.org")
;; "* %(org-contacts-template-name)
;; :PROPERTIES:
;; :EMAIL: %(org-contacts-template-email)
;; :PHONE:
;; :ALIAS:
;; :NICKNAME:
;; :IGNORE:
;; :ICON:
;; :NOTE:
;; :ADDRESS:
;; :BIRTHDAY:
;; :END:"))
)
(use-package org-chef :defer t)
(use-package org-elisp-help :defer t)
(use-package org-node :after org)
(use-package
org-recur
:hook ((org-mode . org-recur-mode) (org-agenda-mode . org-recur-agenda-mode))
:demand t
:bind
(:map
org-recur-mode-map ("C-c d" . org-recur-finish)
;; Rebind the 'd' key in org-agenda (default: `org-agenda-day-view').
:map org-recur-agenda-mode-map ("d" . org-recur-finish) ("C-c d" . org-recur-finish))
:custom (org-recur-finish-done t) (org-recur-finish-archive t))
(use-package org-shoplist :defer t)
(use-package org-superstar :defer t)
;; http://alhassy.com/org-special-block-extras/ -- define your own Org blocks
(use-package org-special-block-extras :defer t)
(use-package ox-gfm :defer t :after org)
(use-package
origami
:defer t
;; don't want global origami mode -- it activates in org buffers, etc. where it shouldn't
:bind (("C-+" . origami-forward-toggle-node) ("C-=" . origami-forward-toggle-node)))
(use-package page-break-lines)
(use-package poly-erb :defer t)
(use-package prettier :hook (html-mode ng2-html-mode))
(use-package pyenv-mode :defer t)
(use-package reaper :ensure t :bind ("C-c h" . reaper))
(use-package robe :defer t)
;; attempt to set up equivalent keys on Mac and my PC.
(if (equal system-type 'darwin)
(progn
(use-package
projectile
:init (keymap-global-unset "s-p")
:config (projectile-mode +1)
:bind (:map projectile-mode-map ("s-p" . projectile-command-map))))
;; on GNOME desktop, "s-p" opens desktop menu
(use-package
projectile
:init (keymap-global-unset "M-p")
:config (projectile-mode +1)
:bind (:map projectile-mode-map ("M-p" . projectile-command-map))))
(use-package smart-mode-line :config (sml/setup))
(use-package smart-mode-line-powerline-theme :config (sml/apply-theme 'light-powerline))
(use-package sql-indent :defer t)
(use-package swift-ts-mode :mode ("\\.swift\\'" . swift-ts-mode) :hook (swift-ts-mode . (lambda () (lsp))))
(use-package terraform-doc :defer t)
(use-package terraform-mode :defer t)
;; Treemacs https://github.com/Alexander-Miller/treemacs?tab=readme-ov-file#installation
(use-package
treemacs
:custom
(treemacs-is-never-other-window t)
(treemacs-sorting 'alphabetic-case-insensitive-asc)
(treemacs-width-is-initially-locked t)
(treemacs-project-follow-mode t)
:bind
;; some of these replace functions from tab-bar, which I don't use anyway
(:map
global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t d" . treemacs-select-directory)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-projectile :after (treemacs projectile))
(use-package treemacs-magit :after (treemacs magit))
;; see git page above for other related package setups
(treemacs-start-on-boot)
(use-package tree-sitter :defer t)
(defun mp-setup-install-grammars ()
"Install Tree-sitter grammars if they are absent."
(interactive)
;; it's not clear there's much advantage to specifying the version here
(dolist (grammar
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(css . ("https://github.com/tree-sitter/tree-sitter-css"))
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(go "https://github.com/tree-sitter/tree-sitter-go")
(html . ("https://github.com/tree-sitter/tree-sitter-html"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript"))
(json . ("https://github.com/tree-sitter/tree-sitter-json"))
(make "https://github.com/alemuller/tree-sitter-make")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(python . ("https://github.com/tree-sitter/tree-sitter-python"))
(rust "https://github.com/tree-sitter/tree-sitter-rust")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src")
(typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src")
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
(add-to-list 'treesit-language-source-alist grammar)
;; Only install `grammar' if we don't already have it
;; installed. However, if you want to *update* a grammar then
;; this obviously prevents that from happening.
(unless (treesit-language-available-p (car grammar))
(treesit-install-language-grammar (car grammar)))))
(use-package
typescript-ts-mode
:defer t
:ensure nil ;; built-in mode
:hook prettier-mode)
(use-package
; see https://web-mode.org/!!
web-mode
:defer t
:mode
(("\\.phtml\\'" . web-mode)
("\\.php\\'" . web-mode)
("\\.tpl\\'" . web-mode)
("\\.[agj]sp\\'" . web-mode)
("\\.as[cp]x\\'" . web-mode)
("\\.erb\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("\\.djhtml\\'" . web-mode))
:custom (web-mode-enable-comment-interpolation t) (web-mode-enable-engine-detection t)
; this assumes we're always using django
(web-mode-engines-alist '(("django" . "\\.html\\'"))))
(use-package weyland-yutani-theme :defer t)
(use-package whitespace-cleanup-mode :config (global-whitespace-cleanup-mode 1))
(use-package xkcd :defer t)
;;; Everything Else
;; visible-bell is very nice on Linux and very obnoxious on a Mac
(setq visible-bell (not (equal system-type 'darwin)))
(setq
fill-column 120
indent-tabs-mode nil)
(push '("\\.ts\\'" . typescript-ts-mode) auto-mode-alist)
(push '("\\.tsx\\'" . tsx-ts-mode) auto-mode-alist)
(push '("\\.js[mx]?\\'" . js-ts-mode) auto-mode-alist)
(push '("\\.har\\'" . js-ts-mode) auto-mode-alist)
;; why is this not working for .yml files?
(push '("\\.ya?ml\\'" . yaml-ts-mode) auto-mode-alist)
(push '("\\.yml\\'" . yaml-ts-mode) auto-mode-alist)
;; not having a lot of luck setting up emacs as a brew service, so far
;; and this doesn't seem to work either.
(use-package
server
:config
(when (null server-process)
(server-start)))
;; because I often hit this key by accident and use "C-x C-c" instead anyway
(keymap-global-unset "s-q" nil)
;; (keymap-global-set "C-x C-p" (lambda (x) (interactive) (project-list-buffers t)))
;; doesn't use use-package -- see lisp directory
;; nifty interface for execute-extended-command (M-x)
(require 'smex "smex/smex")
;; (smex-initialize) ;; not required, might make first use faster
;; MAC-specific setup
;; TODO: move this to site.macos.el
(when (equal system-type 'darwin)
(setq mac-command-modifier 'meta)
(setq mac-option-modifier 'super)
(set-fontset-font t 'symbol (font-spec :family "Apple Symbols") nil 'prepend)
(set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend)
(use-package org-mac-link)
(use-package osx-lib :defer t)
(setq ring-bell-function
(lambda ()
"do nothing and do it well"
())))
;; Mac keybindings that conflict with Emacs defaults
;; M-% launches screen capture
;; C-M-k brings up calender in MacOS topbar
;; C-M-q locks the screen
;; enable these for all environments so I don't have to remember on non-Macs
(bind-keys ("C-c C-q" . indent-pp-sexp) ("C-c C-s" . kill-sexp) ("C-%" . query-replace))
(keymap-set global-map "C-x M-r" #'remember)
(keymap-set global-map "C-x M-R" #'remember-region)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
;; Tell emacs lisp mode to do the right thing on build.
(add-hook
'emacs-lisp-mode-hook
(lambda ()
(setq-local compile-command
(concat
"emacs -batch -f batch-byte-compile "
(if buffer-file-name
(shell-quote-argument buffer-file-name))))))
;;; buffer(s) opened on startup
(find-file (expand-file-name "~/org/personal/todo-main.org"))
;; enabled "risky" commands
(put 'downcase-region 'disabled nil)
(message "%s" "init.el completed")
;; Blacklisted Packages
;; this is reminder (to myself) not to use these packages, and why
;; angular-mode -- so very out of date...
;; djangonaut -- currently, djangonaut commands are failing
;; eglot -- built-in, fine as far as I know, superceded by lsp-mode
;; enh-ruby-mode -- doesn't support ruby-ts-mode??
;; fold-dwim -- it almost never Does What I Mean.
;; go -- the game, not the language -- causes crash in ivy?
;; org-modern -- makes org mode look really nice, but it makes editing much harder
;; paradox -- nice, but has problems like putting all its output into minibuffer and freezing emacs :-(
;; speedbar -- OK, but treemacs is better (for file lists anyway)
;;; init.el ends here :-)