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
|
#+TITLE: Oreodave's Emacs configuration
#+AUTHOR: Oreodave
#+DESCRIPTION: My Doom Emacs configuration!
* Preclude
This is my [[https://github.com/hlissner/doom-emacs][Doom Emacs]] configuration, which I try to use for as many things as
possible. It is currently my main editor overall, literally overtaking my life.
* Simple variables
Setting up variables and basic stuff that doesn't require a lot of work.
** Doom Variables
#+BEGIN_SRC elisp
(setq doom-localleader-key ",")
(setq doom-font (font-spec :family "Hack" :size 19))
(setq doom-theme 'doom-gruvbox)
#+END_SRC
- Set the doom localleader to "," because it's faster
- Using the font [[https://sourcefoundry.org/hack/][Hack]] with Fira code ligatures
- Themes sanctioned by me:
- doom-solarized-dark: just the right everything. best for day.
- doom-gruvbox: good contrast, better for night.
- Themes not sanctioned:
- Any of the base16 themes for anything other than editing code, not org.
Contrast isn't good enough
- Light themes other than Emacs default, maybe sometimes solarized-light
- Horrid low contrast ones with no colour. Grayscale particularly. I can't
handle those.
** Interface
#+BEGIN_SRC elisp
(setq completion-ignore-case t)
(setq truncate-lines t)
(setq display-line-numbers-type nil)
#+END_SRC
Some quality of life things that I couldn't really put in one category
- Displaying line numbers isn't usually something I do. If need be, I'll just
open them with *<SPC>tl*.
** Org directory
#+BEGIN_SRC elisp
(setq org-directory "~/Text")
#+END_SRC
Set the org directory to Text.
** Search providers
#+BEGIN_SRC elisp
(cl-pushnew '("Libgen" . "https://libgen.me/search/all?search=%s") +lookup-provider-url-alist :key #'car)
#+END_SRC
Uniquely append "Libgen" to the search provider alist. Libgen is a nice book site.
* Custom functions
These functions help me with adding functionality to Emacs.
** Reload
#+BEGIN_SRC elisp
(defun oreodave/reload ()
"Reload instance of doom"
(interactive)
(load-file (concat doom-private-dir "config.el")))
#+END_SRC
Reload the doom session by brute force fully loading the "config.el" file in the
doom private directory.
** Go to Books
#+BEGIN_SRC elisp
(defun oreodave/goto-books ()
"Goto the books section"
(interactive)
(dired (concat org-directory "/Books")))
#+END_SRC
Open a Dired session to the books directory in the org-directory.
** Go to School directory
#+BEGIN_SRC elisp
(defun oreodave/goto-school ()
"Goto the school directory"
(interactive)
(dired (expand-file-name "~/School")))
#+END_SRC
** Hook for font ligatures
#+BEGIN_SRC elisp
(add-hook 'after-make-frame-functions
(lambda (_)
(set-fontset-font t '(#Xe100 . #Xe16f)
+pretty-code-fira-code-font-name)))
#+END_SRC
This hook was given to me by our lord and saviour Henrik. Fixes a single font
issue I had with font ligatures.
** Oreomode
#+BEGIN_SRC elisp
(defun oreodave/oreomode()
(interactive)
(evil-window-vsplit) ; Full length vertical
(evil-window-split) ; half length horizontal
(+treemacs/toggle)
(message "Oreomode complete!"))
#+END_SRC
A little function to turn on most of my helper things that I use on a daily
basis but put into its own routine because I don't want it active all the time.
* Packages Config
** Projectile
#+BEGIN_SRC elisp
(after! projectile
(setq oreodave-tags-alist '("Makefile" "node_modules" "bin" "dist" "obj" "'*.json'"))
(defun oreodave/config/construct-tags ()
(reduce (lambda (x y) (concat x y)) (mapcar (lambda (i) (concat " --exclude=" i)) oreodave-tags-alist)
:initial-value "exctags -Re ")
)
(setq projectile-tags-command (oreodave/config/construct-tags)))
#+END_SRC
Really simple, just want to set projectile-tags-command when projectile has
loaded, and easily add new ignores if necessary. Add a new ignore to the tags-alist.
** Dired
#+BEGIN_SRC elisp
(after! dired
(map!
:map dired-mode-map
:n "RET" nil
:ng "^" nil)
)
#+END_SRC
** DAP
#+BEGIN_SRC elisp
(after! dap-mode
(defun oreodave/debug ()
(interactive)
(dap-ui-mode)
(dap-ui-locals)
(dap-ui-sessions))
(map!
:leader
:desc "Start debugging setup" "cD" 'oreodave/debug)
)
#+END_SRC
** Wakatime
#+BEGIN_SRC elisp
(setq wakatime-api-key (shell-command-to-string "pass Keys/Wakatime"))
#+END_SRC
Using new password holder (pass) to help with secure transactions.
** Elfeed
#+BEGIN_SRC elisp
(after! elfeed
(defun oreodave/elfeed/load-feeds ()
(interactive)
(setq elfeed-feeds nil)
(elfeed-load-opml (concat org-directory "/elfeed.opml")))
(defun oreodave/elfeed/on-new-feed ()
(interactive)
(elfeed-org-export-opml)
(write-file (concat org-directory "/elfeed.opml"))
(kill-current-buffer)
)
(map!
(:map elfeed-search-mode-map
:localleader
:desc "Update feeds" "u" #'elfeed-update)
(:leader
:prefix "o"
:desc "Open RSS" "f" #'=rss)
)
(add-hook 'elfeed-org-new-entry-hook 'oreodave/elfeed/on-new-feed)
;; (oreodave/elfeed/load-feeds)
)
#+END_SRC
** Dash
#+BEGIN_SRC elisp
(setq dash-docs-docsets-path "~/.docsets")
#+END_SRC
My docsets are stored in .docsets for ease of use
** wttrin
#+BEGIN_SRC elisp
(defun oreodave/weather ()
"Check the weather at the 'location' stored in password store"
(interactive)
(wttrin (shell-command-to-string "pass location")))
#+END_SRC
** Dashboard
#+BEGIN_SRC elisp
; Setup dashboard to do some stuff for me
(setq fancy-splash-image "~/Pictures/emacs-backgrounds/killerqueen.png")
(setq +doom-dashboard-functions
'(doom-dashboard-widget-banner
doom-dashboard-widget-shortmenu
doom-dashboard-widget-loaded))
(setq +doom-dashboard-menu-sections
'(("Open org-agenda"
:icon (all-the-icons-octicon "calendar" :face 'font-lock-keyword-face)
:when (fboundp 'org-agenda)
:action org-agenda)
("Open books"
:icon (all-the-icons-octicon "book" :face 'font-lock-keyword-face)
:action oreodave/goto-books)
("Check the weather"
:icon (all-the-icons-octicon "globe" :face 'font-lock-keyword-face)
:action oreodave/weather)
("Jump to bookmark"
:icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face)
:action bookmark-jump)
))
#+END_SRC
- Killer queen image comes from this Reddit [[https://www.reddit.com/r/StardustCrusaders/comments/974qwh/fanart_killer_queens_shadow/][post]]
- Remove the Github link to the official Doom Emacs repository: it's in muscle memory
at this point.
- Added my own menu items:
- Books
- Weather
* Language Config
** C#
#+BEGIN_SRC elisp
(after! csharp-mode
(defun oreodave/csharp/get-unit-test-in-project ()
(interactive)
(let* ((tags-file (counsel-etags-locate-tags-file))
(cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name))) ; void.*Test assumes your tests are using something like XUnit and end with Test
(ivy-read "Choose test: "
cands
:action
(lambda (item)
;; From the counsel-etags file-open-api function
(when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item)
(let* ((file (match-string-no-properties 1 item))
(linenum (match-string-no-properties 2 item))
;; always calculate path relative to TAGS
(default-directory (counsel-etags-tags-file-directory)))
(when counsel-etags-debug
(message "counsel-etags-open-file-api called => dir=%s, linenum=%s, file=%s" dir linenum file))
(counsel-etags-push-marker-stack (point-marker))
(find-file file)
(counsel-etags-forward-line linenum)
(omnisharp-unit-test-at-point))
))
:caller 'oreodave/csharp/get-unit-tests-in-project)))
(setq omnisharp-server-executable-path "~/bin/omnisharp/run")
(add-hook 'csharp-mode-hook '(lambda()
(setq c-basic-offset 4)
(c-set-style "java"))) ; Hook for csharp setting variables
(map! ; CSharp Keybinds
:map csharp-mode-map
:localleader
:desc "Format buffer" "=" 'omnisharp-code-format-entire-file
(:prefix "t"
:desc "Select Test in Project" "t" 'oreodave/csharp/get-unit-test-in-project))
)
#+END_SRC
- I have custom installed the omnisharp roslyn executable, so I'd rather use that
- C# code is better at 4 space indents, but I indent most of my C code at 2 space indents because it looks nicer :)
- Implemented my own function which piggy backs counsel etags to globally search
tags for test specific context, then goes to it and uses an omnisharp test
command to unit test it. Basically global test search in C# projects
** Python
#+BEGIN_SRC elisp
(after! python
(setq python-version-checked t)
(setq python-python-command "python3")
(setq python-shell-interpreter "python3")
(setq flycheck-python-pycompile-executable "python3")
(map! ; Python keybinds
:map python-mode-map
:localleader
:desc "Start python minor" "c" 'run-python
:desc "Format buffer" "=" 'py-yapf-buffer
(:prefix "s"
:desc "Send region REPL" "r" 'python-shell-send-region
:desc "Send buffer" "b" 'python-shell-send-buffer
:desc "Send function" "f" 'python-shell-send-defun))
)
#+END_SRC
- I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3
- Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
- I run my python code a LOT and thus need commands for sending bits or whole scripts into the REPL
** JavaScript/TypeScript
#+BEGIN_SRC elisp
(after! typescript-mode
(setq typescript-indent-level 2)
(setq tide-format-options '(:indentSize 2 :tabSize 2))
(map!
:localleader
:map typescript-mode-map
:desc "Format code" "=" 'tide-format)
)
#+END_SRC
- Typescript (in my opinion) should be indented by 2
- I like having one keybind to format a file, thus need to rebind
** Org
#+BEGIN_SRC elisp
(after! org
(add-hook 'org-mode-hook #'visual-line-mode)
(remove-hook 'org-mode-hook #'auto-fill-mode)
(define-abbrev-table 'org-mode-abbrev-table
(mapcar
(lambda (char-string)
(let ((character-property-elements
(split-string (get-char-code-property (encode-char (string-to-char char-string) 'unicode) 'name) " ")))
(list
(concat
(if (member "CAPITAL" character-property-elements)
(capitalize (-last-item character-property-elements))
(downcase (-last-item character-property-elements)))
"x")
char-string)))
'("α" "β" "γ" "δ" "ε" "ζ" "η" "θ" "ι" "κ" "λ" "μ" "ν" "ξ" "ο" "π" "ρ" "σ" "τ" "υ" "φ" "χ" "ψ" "ω"
"Α" "Β" "Γ" "Δ" "Ε" "Ζ" "Η" "Θ" "Ι" "Κ" "Λ" "Μ" "Ν" "Ξ" "Ο" "Π" "Ρ" "Σ" "Τ" "Υ" "Φ" "Χ" "Ψ" "Ω")))
(map! ; Org keybinds
:map org-mode-map
:localleader
:desc "Org dispatch" "e" #'org-export-dispatch
:desc "Export to ODT" "E" #'org-pandoc-export-to-odt
(:prefix ("N" . "+narrow")
:desc "Narrow to subtree" "n" #'org-narrow-to-subtree
:desc "Go out of narrow" "o" #'widen
:desc "Narrow tags" "t" #'org-tags-sparse-tree))
)
#+END_SRC
I like using the org dispatch facilities more than the default export keybinds
in Doom, so I need this binding
* Keymap
#+BEGIN_SRC elisp
(map!
:leader
:desc "M-x" "<SPC>" 'counsel-M-x ; Redefine as M-x because of my muscle memory with spacemacs
:desc "Switch to p-buffer" ">" 'projectile-switch-to-buffer ; Opposing <SPC>< which counsel's all buffers
:desc "Reload emacs" "r" 'oreodave/reload ; Reload is necessary
:desc "Compile via make" "cC" '+make/run ; I compile stuff all the time
:desc "Open books" "B" 'oreodave/goto-books ; I like my books
:desc "Open school dir" "S" 'oreodave/goto-school ; I like my schooling
(:prefix "/" ; Search ; in comparison to <SPC>s it's closer together, and makes more sense (vim bindings)
:after counsel
:desc "Ag!" "a" '+ivy/ag
:desc "FZF!" "f" 'counsel-fzf ; Just in case I need a counsel-ui for a gitignored directory
:desc "RipGrep!" "r" 'counsel-rg ; Ripgrep is faster than Ag in most cases and makes me feel cool
:desc "Search Tags" "t" 'counsel-etags-find-tag
:desc "List Tags" "T" 'counsel-etags-list-tag
:desc "Buffer Tags" "s" 'counsel-imenu
:desc "Search buffer" "/" 'swiper); is quicker to do than <SPC>/b, for something that is done so often
(:prefix "w" ; Windows
:desc "Close window" "d" '+workspace/close-window-or-workspace ; is slightly closer together than <SPC>wc
:desc "Switch window" "W" 'ace-window ; is also used in spacemacs so I'd rather use this
:desc "Swap windows" "S" 'ace-swap-window) ; allows me to switch windows more efficiently than before, better than just motions
(:prefix "c" ; Code
:desc "Fold all in level" "f" 'hs-hide-level
(:after format-all
:desc "Format code universally" "=" 'format-all-buffer))
(:prefix "b" ; Buffers
:desc "Close buffer" "d" 'doom/kill-this-buffer-in-all-windows)
(:prefix "p" ; Projects
:after projectile
:desc "Regen tags" "g" 'projectile-regenerate-tags
:desc "Open project files" "f" 'projectile-find-file)
(:prefix ("z" . "Font") ; Fonts
:desc "Increase font" "+" 'doom/increase-font-size
:desc "Decrease font" "-" 'doom/decrease-font-size
:desc "Adjust font" "z" 'text-scale-adjust)
(:prefix ("F" . "Frame") ; Frames
:desc "Kill frame" "d" 'delete-frame
:desc "Make current buffer frame" "m" 'make-frame
:desc "Choose buffer to make frame" "n" 'display-buffer-other-frame
:desc "Switch frames" "o" 'other-frame)
(:prefix "o"
:after org
:desc "Calendar" "c" '=calendar))
#+END_SRC
|