-
Notifications
You must be signed in to change notification settings - Fork 0
/
+bindings.el
407 lines (358 loc) · 14.1 KB
/
+bindings.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
;;; ~/.doom.d/+bindings.el -*- lexical-binding: t; -*-
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c g k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c g d') to jump to their definition and see how
;; they are implemented.
;; toggle flycheck on and off
(map! "C-z" nil)
(setq iedit-toggle-key-default nil)
(setq-default indent-tabs-mode nil)
;;(setq doom-localleader-alt-key "C-z")
(global-set-key (kbd "<f5>") 'revert-buffer)
;; Not sure if i want this
(global-set-key (kbd "M-/") 'hippie-expand)
(setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-complete-lisp-symbol-partially try-complete-lisp-symbol))
;; Backups
;; Settled by doom in .local/cache/backup
;;
;; (defvar --backup-directory (concat user-emacs-directory "backups"))
;; (if (not (file-exists-p --backup-directory))
;; (make-directory --backup-directory t))
;; (setq backup-directory-alist `(("." . ,--backup-directory)))
(setq make-backup-files t ; backup of a file the first time it is saved.
backup-by-copying t ; don't clobber symlinks
version-control t ; version numbers for backup files
vc-make-backup-files t ; backup versioned files (git?)
delete-old-versions t ; delete excess backup files silently
delete-by-moving-to-trash t
kept-old-versions 6 ; oldest versions to keep when a new numbered backup is made (default: 2)
kept-new-versions 9 ; newest versions to keep when a new numbered backup is made (default: 2)
)
;; No persistent undo history
;; (remove-hook 'undo-fu-mode-hook #'global-undo-fu-session-mode)
(use-package! windmove
:config
(windmove-default-keybindings)
;; Make windmove work in Org mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right))
;; To consider removing
(use-package! swiper
:bind ("C-s" . swiper)
("C-r" . swiper))
(use-package! undo-fu
:bind ("C-?" . undo-fu-only-redo))
;; From nov website
(use-package! nov
:hook (nov-mode . variable-pitch-mode)
:mode ("\\.\\(epub\\|mobi\\)\\'" . nov-mode)
:config
;; Default Font
(defun my-nov-font-setup ()
(face-remap-add-relative 'variable-pitch :family "Liberation Serif"
:height 1.2))
(add-hook 'nov-mode-hook 'my-nov-font-setup)
;; Rendering
(require 'justify-kp)
(setq nov-text-width t)
(setq visual-fill-column-center-text t)
(add-hook 'nov-mode-hook 'visual-line-mode)
(add-hook 'nov-mode-hook 'visual-fill-column-mode)
(defun my-nov-window-configuration-change-hook ()
(my-nov-post-html-render-hook)
(remove-hook 'window-configuration-change-hook
'my-nov-window-configuration-change-hook
t))
(defun my-nov-post-html-render-hook ()
(if (get-buffer-window)
(let ((max-width (pj-line-width))
buffer-read-only)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(when (not (looking-at "^[[:space:]]*$"))
(goto-char (line-end-position))
(when (> (shr-pixel-column) max-width)
(goto-char (line-beginning-position))
(pj-justify)))
(forward-line 1))))
(add-hook 'window-configuration-change-hook
'my-nov-window-configuration-change-hook
nil t)))
(add-hook 'nov-post-html-render-hook 'my-nov-post-html-render-hook))
(after! org-noter
org-noter-doc-split-fraction '(0.57 0.43))
(use-package! aggressive-indent
:hook
(clojure-mode . aggressive-indent-mode))
(use-package! kibit-helper
:bind ("C-x C-'" . kibit-accept-proposed-change))
(use-package! clojure-essential-ref-nov
:after cider
:init
(setq clojure-essential-ref-nov-epub-path "~/Dropbox/Books/Clojure/Clojure_The_Essential_Reference_v29_MEAP.epub")
:bind (
:map cider-mode-map
("C-c C-d C-r" . clojure-essential-ref)
("C-c C-d r" . clojure-essential-ref-nov)
:map cider-repl-mode-map
("C-c C-d C-r" . clojure-essential-ref)))
(use-package! cider
:bind ("C-c C-e" . cider-pprint-eval-defun-to-comment)
:config
;; (setq nrepl-log-messages t)
(setq nrepl-use-ssh-fallback-for-remote-hosts t)
(add-hook 'cider-repl-mode-hook #'eldoc-mode)
(add-hook 'cider-repl-mode-hook #'rainbow-delimiters-mode)
;; (add-hook 'cider-repl-mode-hook #'cider-company-enable-fuzzy-completion)
;; (add-hook 'cider-mode-hook #'cider-company-enable-fuzzy-completion)
)
(after! clojure-mode
;;; (define-clojure-indent
;; (PUT 2)
;; (POST 2)
;; (GET 2)
;; (PATCH 2)
;; (DELETE 2)
;; (context 2)
;; (for-all 2)
;; (checking 3)
;; (>defn :defn)
;; (>defn- :defn)
;; (match 1)
;; (cond 0)
;; (case 1)
;; (describe 1)
;; (it 2)
;; (fn-traced :defn)
;; (defn-traced :defn)
;; (assert-match 1))
(setq clojure-indent-style 'align-arguments)
(add-to-list 'clojure-align-binding-forms "let-flow")
;; (setq clojure-indent-style 'always-align)
;; (setq clojure-indent-style 'always-indent)
;; (setq cider-default-cljs-repl 'shadow)
(put '>defn 'clojure-doc-string-elt 2)
(put '>defn- 'clojure-doc-string-elt 2)
(put 'defsys 'clojure-doc-string-elt 2)
(put 'defn-traced 'clojure-doc-string-elt 2)
;; (setq clojure-align-forms-automatically t)
;; See if i use below
(setq cljr-magic-require-namespaces
'(("io" . "clojure.java.io")
("sh" . "clojure.java.shell")
("jdbc" . "clojure.java.jdbc")
("set" . "clojure.set")
("time" . "java-time")
("str" . "cuerdas.core")
("path" . "pathetic.core")
("walk" . "clojure.walk")
("zip" . "clojure.zip")
("async" . "clojure.core.async")
("component" . "com.stuartsierra.component")
("http" . "clj-http.client")
("url" . "cemerick.url")
("sql" . "honeysql.core")
("csv" . "clojure.data.csv")
("json" . "cheshire.core")
("s" . "clojure.spec.alpha")
("fs" . "me.raynes.fs")
("ig" . "integrant.core")
("cp" . "com.climate.claypoole")
("re-frame" . "re-frame.core")
("rf" . "re-frame.core")
("rf.db" . "re-frame.db")
("re" . "reagent.core")
("reagent" . "reagent.core")
("w" . "wing.core")
("gen" . "clojure.spec.gen.alpha"))))
(use-package! emms
:config
(require 'emms-setup)
(emms-all)
;; (emms-standard)
(emms-default-players)
;; (emms-mode-line 1)
;; (emms-playing-time-disable-display)
(setq emms-source-file-default-directory "~/Music/")
;; Added /usr/local/bin/emms-info-libtag
(require 'emms-info-libtag)
(require 'emms-volume)
(setq emms-info-functions '(emms-info-libtag))
;; might not be working, had to copy to get working
(setq emms-browser-covers 'emms-browser-cache-thumbnail-async)
(defun my-emms-play-url-at-point ()
"Same as `emms-play-url' but with url at point."
(interactive)
(emms-play-url (url-get-url-at-point))))
(use-package! magit
:bind ("C-c g" . magit-file-dispatch))
(use-package! dired-narrow
:commands (dired-narrow-fuzzy)
:init
(map! :map dired-mode-map
:desc "narrow" "/" #'dired-narrow-fuzzy))
(use-package! org
:config
(setq org-refile-targets (quote (("newgtd.org" :maxlevel . 1)
("someday.org" :level . 2))))
;; (setq org-image-actual-width (/ (display-pixel-width) 3))
(setq org-image-actual-width nil)
(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
(setq org-plantuml-jar-path "/home/zackteo/Documents/plantuml.jar"))
;; (add-to-list 'org-latex-classes
;; '("article"
;; "\\documentclass[10pt,article,oneside]{memoir}"
;; ("\\chapter{%s}" . "\\chapter*{%s}")
;; ("\\section{%s}" . "\\section*{%s}")
;; ("\\subsection{%s}" . "\\subsection*{%s}")
;; ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
;; ("\\paragraph{%s}" . "\\paragraph*{%s}")
;; ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
;; '("book"
;; "\\documentclass[10pt]{memoir}"
;; ("\\chapter{%s}" . "\\chapter*{%s}")
;; ("\\section{%s}" . "\\section*{%s}")
;; ("\\subsection{%s}" . "\\subsection*{%s}")
;; ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
;; ("\\paragraph{%s}" . "\\paragraph*{%s}")
;; ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
;; )
;; If image folder not created, stringp error
(use-package! org-download
:commands
org-download-dnd
org-download-yank
org-download-screenshot
org-download-dnd-base64
:init
(map! :map org-mode-map
"s-Y" #'org-download-screenshot
"s-y" #'org-download-yank)
(pushnew! dnd-protocol-alist
'("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . +org-qdragndrop-download-dnd-fn)
'("^data:" . org-download-dnd-base64))
(advice-add #'org-download-enable :override #'ignore)
:config
(defun +org/org-download-method (link)
(let* ((filename
(file-name-nondirectory
(car (url-path-and-query
(url-generic-parse-url link)))))
;; Create folder name with current buffer name, and place in root dir
(dirname (concat "./images/"
(replace-regexp-in-string " " "_"
(downcase (file-name-base buffer-file-name)))))
(filename-with-timestamp (format "%s%s.%s"
(file-name-sans-extension filename)
(format-time-string org-download-timestamp)
(file-name-extension filename))))
(make-directory dirname t)
(expand-file-name filename-with-timestamp dirname)))
:config
(setq org-download-screenshot-method
(cond ((executable-find "maim") "maim -u -s %s")
((executable-find "scrot") "scrot -s %s")))
(setq org-download-method '+org/org-download-method))
(defun screenshot-svg ()
"Save a screenshot of the current frame as an SVG image.
Saves to a temp file and puts the filename in the kill ring."
(interactive)
(let* ((filename (make-temp-file "Emacs" nil ".svg"))
(data (x-export-frames nil 'svg)))
(with-temp-file filename
(insert data))
(kill-new filename)
(message filename)))
(use-package! mathpix.el
:commands (mathpix-screenshot)
:init
(setq mathpix-screenshot-method (cond ((executable-find "maim") "maim -u -s %s")
((executable-find "scrot") "scrot -s %s"))
mathpix-app-id ""
mathpix-app-key "")
(map! "C-x m" #'mathpix-screenshot))
;; active Babel languages
(org-babel-do-load-languages
'org-babel-load-languages
'((clojure . t)
(shell . t)
(emacs-lisp . t)))
(setq org-confirm-babel-evaluate nil)
(require 'org)
(require 'ob-clojure)
(setq org-babel-clojure-backend 'cider)
(require 'cider)
(after! format
(set-formatter! 'clang-format
'("clang-format"
"-style={BasedOnStyle: Google, IndentWidth: 4, SortIncludes: false}"
("-assume-filename=%S" (or buffer-file-name mode-result "")))))
(setq-hook! 'c++-mode-hook +format-with 'clang-format)
;; (setq +format-on-save-enabled-modes
;; '(not c++-mode))
;; (require 'lsp-java-boot)
;; to enable the lenses
;; (add-hook 'lsp-mode-hook #'lsp-lens-mode)
;; (add-hook 'java-mode-hook #'lsp-java-boot-lens-mode)
;; (use-package! lsp-mode
;; :hook ((clojure-mode . lsp)
;; (clojurec-mode . lsp)
;; (clojurescript-mode . lsp))
;; :config
;; ;; add paths to your local installation of project mgmt tools, like lein
;; ;; (setenv "PATH" (concat
;; ;; "/usr/local/bin" path-separator
;; ;; (getenv "PATH")))
;; (dolist (m '(clojure-mode
;; clojurec-mode
;; clojurescript-mode
;; clojurex-mode))
;; (add-to-list 'lsp-language-id-configuration `(,m . "clojure"))))
;; telega
(set-fontset-font t 'unicode "Symbola" nil 'append)
;; (use-package! telega
;; :init
;; ;; (setq telega-chat-show-deleted-messages-for nil)
;; )
;; For more intense debugging
;; (defun doom--backtrace ()
;; (let* ((n 0)
;; (frame (backtrace-frame n))
;; (frame-list nil)
;; (in-program-stack nil))
;; (while frame
;; (when in-program-stack
;; (push (cdr frame) frame-list))
;; (when (eq (elt frame 1) 'doom-debugger)
;; (setq in-program-stack t))
;; (setq n (1+ n)
;; frame (backtrace-frame n)))
;; (reverse frame-list)))
;; (defun doom-debugger (error data)
;; "A custom debugger for `debugger'.
;; Writes the backtrace to another buffer, in case it is lost for whatever reason."
;; (with-current-buffer (get-buffer-create "*rescued-backtrace*")
;; (let ((standard-output (current-buffer)))
;; (prin1 error)
;; (prin1 data)
;; (mapc #'print (doom--backtrace)))
;; (kill-new (buffer-string))
;; (message "Backtrace copied to your clipboard"))
;; (debug error data))
;; (setq debugger #'doom-debugger)
;; (toggle-debug-on-error)