blob: 46c8db8254b9e1bb9a6fd4274e28c42ac767d7d5 (
plain) (
blame)
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
|
;;; wpc-misc.el --- Hosting miscellaneous configuration -*- lexical-binding: t -*-
;; Author: William Carroll <wpcarro@gmail.com>
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
;;; Commentary:
;; This is the home of any configuration that couldn't find a better home.
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'project)
(require 'f)
(require 'dash)
(require 'constants)
(require 'region)
(require 'general)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; I'm borrowing from the dot-time format (i.e. https://dotti.me) to encode the
;; timestamp. This displays the UTC time and an offset to show the number of
;; hours East or West of UTC my current timezone is using `current-time-zone'.
;;
;; Reminder to me:
;; LON: +00 (UTC) or +01 (BST)
;; NYC: -05
;; SF: -07
(setq display-time-format
(concat "%H·%M"
(format "%0+3d" (/ (car (current-time-zone)) 3600))
" %a %d %b"))
(display-time-mode 1)
;; Remove the boilerplate in the *scratch* buffer
(setq initial-scratch-message "")
;; disable custom variable entries from being written to ~/.emacs.d/init.el
(setq custom-file (f-join user-emacs-directory "custom.el"))
(load custom-file 'noerror)
;; integrate Emacs with X11 clipboard
(setq select-enable-primary t)
(setq select-enable-clipboard t)
(general-def 'insert
"s-v" #'clipboard-yank
"C-S-v" #'clipboard-yank)
;; transparently edit compressed files
(auto-compression-mode t)
;; autowrap when over the fill-column
(setq-default auto-fill-function #'do-auto-fill)
;; link to Emacs source code
;; TODO: Update this link.
(setq find-function-C-source-directory
"~/Dropbox/programming/emacs/src")
;; change emacs prompts from "yes or no" -> "y or n"
(fset 'yes-or-no-p 'y-or-n-p)
;; open photos in Emacs
(auto-image-file-mode 1)
;; disable line-wrapping
(setq-default truncate-lines 1)
;; shell file indentation
(setq sh-basic-offset 2)
(setq sh-indentation 2)
;; Emacs library that interfaces with my Linux password manager.
(use-package password-store)
(use-package vterm
:config
(general-define-key
:keymaps '(vterm-mode-map)
:states '(insert)
"C-S-v" #'vterm-yank)
(general-define-key
:keymaps '(vterm-mode-map)
:states '(normal)
"K" #'evil-scroll-line-up
"J" #'evil-scroll-line-down
"C-b" #'evil-scroll-page-up
"C-f" #'evil-scroll-page-down))
;; Use en Emacs buffer as a REST client.
;; For more information: http://emacsrocks.com/e15.html
(use-package restclient)
;; Run `package-lint' before publishing to MELPA.
(use-package package-lint)
;; Parser combinators in Elisp.
(use-package parsec)
;; disable company mode when editing markdown
;; TODO: move this out of wpc-misc.el and into a later file to call
;; `(disable company-mode)'
(use-package markdown-mode
:config
;; TODO: Add assertion that pandoc is installed and it is accessible from
;; Emacs.
(setq markdown-command "pandoc")
(setq markdown-split-window-direction 'right)
;; (add-hook 'markdown-mode-hook #'markdown-live-preview-mode)
)
(use-package alert)
(use-package refine)
;; Required by some google-emacs package commands.
(use-package deferred)
;; git integration
(use-package magit
:config
(setq magit-display-buffer-function
#'magit-display-buffer-fullframe-status-v1))
(use-package magit-popup)
;; http
(use-package request)
;; perl-compatible regular expressions
(use-package pcre2el)
;; alternative to help
(use-package helpful)
;; Emacs integration with direnv
(use-package direnv
:config
(direnv-mode))
;; Superior Elisp library for working with dates and times.
;; TODO: Put this where my other installations for dash.el, s.el, a.el, and
;; other utility Elisp libraries are located.
(use-package ts)
;; persist history etc b/w Emacs sessions
(setq desktop-save 'if-exists)
(desktop-save-mode 1)
(setq desktop-globals-to-save
(append '((extended-command-history . 30)
(file-name-history . 100)
(grep-history . 30)
(compile-history . 30)
(minibuffer-history . 50)
(query-replace-history . 60)
(read-expression-history . 60)
(regexp-history . 60)
(regexp-search-ring . 20)
(search-ring . 20)
(shell-command-history . 50)
tags-file-name
register-alist)))
;; config Emacs to use $PATH values
(use-package exec-path-from-shell
:if (memq window-system '(mac ns))
:config
(exec-path-from-shell-initialize))
;; Emacs autosave, backup, interlocking files
(setq auto-save-default nil
make-backup-files nil
create-lockfiles nil)
;; ensure code wraps at 80 characters by default
(setq-default fill-column constants-fill-column)
(put 'narrow-to-region 'disabled nil)
;; trim whitespace on save
(add-hook 'before-save-hook #'delete-trailing-whitespace)
;; call `git secret hide` after saving secrets.json
(add-hook 'after-save-hook
(lambda ()
(when (f-equal? (buffer-file-name)
(f-join constants-briefcase "secrets.json"))
(shell-command "git secret hide"))))
;; use tabs instead of spaces
(setq-default indent-tabs-mode nil)
;; automatically follow symlinks
(setq vc-follow-symlinks t)
;; fullscreen settings
(setq ns-use-native-fullscreen nil)
(use-package yasnippet
:config
(setq yas-snippet-dirs (list (f-join user-emacs-directory "snippets")))
(yas-global-mode 1))
(use-package projectile
:config
(projectile-mode t))
;; TODO: Consider moving this into a briefcase.el module.
(defun wpc-misc--briefcase-find (dir)
"Find the default.nix nearest to DIR."
;; I use 'vc only at the root of my monorepo because 'transient doesn't use my
;; .gitignore, which slows things down. Ideally, I could write a version that
;; behaves like 'transient but also respects my monorepo's .gitignore and any
;; ancestor .gitignore files.
(if (f-equal? constants-briefcase dir)
(cons 'vc dir)
(when (f-ancestor-of? constants-briefcase dir)
(if (f-exists? (f-join dir "default.nix"))
(cons 'transient dir)
(wpc-misc--briefcase-find (f-parent dir))))))
(add-to-list 'project-find-functions #'wpc-misc--briefcase-find)
(defun wpc-misc-pkill (name)
"Call the pkill executable using NAME as its argument."
(interactive "sProcess name: ")
(call-process "pkill" nil nil nil name))
(use-package deadgrep
:config
(general-define-key
:keymaps 'deadgrep-mode-map
:states 'normal
"o" #'deadgrep-visit-result-other-window)
(setq-default deadgrep--context '(0 . 3))
(defun wpc-misc-deadgrep-region ()
"Run a ripgrep search on the active region."
(interactive)
(deadgrep (region-to-string)))
(defun wpc-misc-deadgrep-dwim ()
"If a region is active, use that as the search, otherwise don't."
(interactive)
(with-current-buffer (current-buffer)
(if (region-active-p)
(setq deadgrep--additional-flags '("--multiline"))
(wpc-misc-deadgrep-region)
(call-interactively #'deadgrep))))
(advice-add
'deadgrep--format-command
:filter-return
(lambda (cmd)
(replace-regexp-in-string
"^rg " "rg --hidden " cmd))))
;; TODO: Do I need this when I have swiper?
(use-package counsel)
(use-package counsel-projectile)
;; search Google, Stackoverflow from within Emacs
(use-package engine-mode
:config
(defengine google
"http://www.google.com/search?ie=utf-8&oe=utf-8&q=%s"
:keybinding "g")
(defengine stack-overflow
"https://stackoverflow.com/search?q=%s"
:keybinding "s"))
;; EGlot (another LSP client)
(use-package eglot)
;; Microsoft's Debug Adapter Protocol (DAP)
(use-package dap-mode
:after lsp-mode
:config
(dap-mode 1)
(dap-ui-mode 1))
;; Microsoft's Language Server Protocol (LSP)
(use-package lsp-ui
:config
(add-hook 'lsp-mode-hook #'lsp-ui-mode))
(use-package company-lsp
:config
(push 'company-lsp company-backends))
;; Wilfred/suggest.el - Tool for discovering functions basesd on declaring your
;; desired inputs and outputs.
(use-package suggest)
;; Malabarba/paradox - Enhances the `list-packages' view.
(use-package paradox
:config
(paradox-enable))
;; Start the Emacs server
(server-start)
(provide 'wpc-misc)
;;; wpc-misc.el ends here
|