forked from anishathalye/dotfiles_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemacs-clj
318 lines (250 loc) · 9.88 KB
/
emacs-clj
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
(when (>= emacs-major-version 24)
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t))
(defun ensure-package-installed (&rest packages)
"Assure every package is installed, ask for installation if it’s not.
Return a list of installed packages or nil for every skipped package."
(mapcar
(lambda (package)
;; (package-installed-p 'evil)
(if (package-installed-p package)
nil
(if (y-or-n-p (format "Package %s is missing. Install it? " package))
(package-install package)
package)))
packages))
(or (file-exists-p package-user-dir)
(package-refresh-contents))
(ensure-package-installed 'zenburn-theme 'nyan-mode 'paredit 'rainbow-delimiters 'ace-window 'align-cljlet 'ido-vertical-mode 'clj-refactor 'clojure-mode 'column-enforce-mode 'magit 'ivy)
(require 'ido)
(ido-mode t)
(require 'ido-vertical-mode)
(ido-vertical-mode t)
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
(require 'nyan-mode)
(nyan-mode t)
(setq nyan-animate-nyancat t)
(setq nyan-wavy-trail t)
(require 'rainbow-delimiters)
;; seems broken after upgrading to emacs 26?
;;(require 'thrift)
;;(add-to-list 'auto-mode-alist '("\\.thrift$" . thrift-mode))
(add-to-list 'auto-mode-alist '("\\.sls\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.aurora\\'" . python-mode))
(require 'align-cljlet)
; Replace metakey on OSX
(setq ns-alternate-modifier 'meta
ns-command-modifier 'meta)
(global-set-key (kbd "C-x p") 'previous-multiframe-window)
(load-theme 'zenburn t)
(add-to-list 'exec-path "/usr/local/bin")
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
;; Depends on having your nrepl properly configured in profiles.clj
;; e.g.
;; {:user {:plugins [
;; [lein-repo "0.2.1"]
;; [cider/cider-nrepl "0.12.0"]]}
;; :dependencies [[org.clojure/tools.nrepl "0.2.12"]]}
;; :uberjar {:plugins [[lein-repo "0.2.1"]]}}
(setq cider-inject-dependencies-at-jack-in nil)
(global-set-key (kbd "<end>") 'move-end-of-line)
(setq cider-auto-select-error-buffer nil)
(setq cider-repl-use-pretty-printing t)
(setq cider-pprint-fn 'fipp)
;;(setq cider-pprint-fn 'puget)
(global-set-key (kbd "C-z") 'noop)
(global-set-key (kbd "C-x C-z") 'noop)
(defun paredit-mode-config ()
(local-set-key (kbd "C-c k") 'paredit-hack-kill-region))
(global-set-key (kbd "C-c g") 'magit-status)
(add-hook 'clojure-mode-hook #'paredit-mode)
(add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
(add-hook 'clojure-mode-hook #'show-paren-mode)
(add-hook 'clojure-mode-hook (lambda () (add-hook 'before-save-hook 'whitespace-cleanup)))
(add-hook 'paredit-mode-hook #'paredit-mode-config)
;(add-hook 'before-save-hook 'delete-blank-lines)
(global-set-key (kbd "C-x o") 'ace-window)
;; this seems to break when cider takes over buffers
(global-set-key (kbd "C-x j") 'aw-flip-window)
;;(global-set-key (kbd "C-x j") (lambda () (interactive) (other-window -1)))
(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.
'(cider-lein-parameters "with-profiles +feature-dtab repl :headless :host ::")
'(helm-mode t)
'(ido-vertical-mode t)
'(package-selected-packages
(quote
(helm-ag helm-projectile projectile helm-cider helm clojure-mode-extra-font-locking zenburn-theme yaml-mode thrift terraform-mode switch-window realgud rainbow-delimiters powerline org-trello nyan-mode magit list-utils jedi ido-vertical-mode git-link git-auto-commit-mode emojify company column-marker column-enforce-mode clj-refactor autopair align-cljlet ace-window ace-jump-mode)))
'(safe-local-variable-values
(quote
((eval define-clojure-indent
(:require 0)
(:import
(quote
(0
(0))))
(defrecord
(quote
(1 nil
(:defn))))
(forv 1)
(for+ 1)
(future-with 1)
(start-unless 1)
(stop-when 1)
(do-at 1)
(thrown\? 1)
(thrown-with-msg\? 2))
(eval define-clojure-indent
(:require 0)
(:import
(quote
(0
(0))))
(defrecord
(quote
(1 nil
(:defn))))
(forv 1)
(for+ 1)
(future-with 1)
(do-at 1)
(thrown\? 1)
(thrown-with-msg\? 2))
(eval define-clojure-indent
(:require 0)
(:import
(quote
(0
(0))))
(defrecord
(quote
(1 nil
(:defn))))
(forv 1)
(for+ 1))))))
(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.
)
(setenv "MESOS_NATIVE_JAVA_LIBRARY" "/usr/local/Cellar/mesos/0.28.0/lib/libmesos.dylib")
(require 'clj-refactor)
(defun my-clojure-mode-hook ()
(clj-refactor-mode 1)
(yas-minor-mode 1) ; for adding require/use/import statements
;; This choice of keybinding leaves cider-macroexpand-1 unbound
(column-enforce-mode 1)
(cljr-add-keybindings-with-prefix "C-c C-m"))
(add-hook 'clojure-mode-hook #'my-clojure-mode-hook)
(define-clojure-indent
(on-success '(2 nil nil [1]))
(on-failure '(2 nil nil [1]))
(register-sub '(0 [1]))
(register-handler '(0 [1]))
(GET '(1 nil nil [1]))
(POST '(1 nil nil [1]))
(PUT '(1 nil nil [1]))
(DELETE '(1 nil nil [1]))
(service '(1 nil [1]))
(defrecord '(1 nil [1]))
(:require '(0 [1]))
(:import '(0 [1])))
(require 'ansi-color)
(defun display-ansi-colors ()
(interactive)
(ansi-color-apply-on-region (point-min) (point-max)))
(add-hook 'post-command-hook
#'display-ansi-colors)
(global-set-key (kbd "C-x <deletechar>") 'erase-buffer)
(put 'erase-buffer 'disabled nil)
(setenv "VAULT_ADDR" "https://vault.amperity.top:8200")
(setq column-number-mode t)
(defun copy-backward-sexp ()
(interactive)
(save-excursion
(copy-region-as-kill (point) (progn (backward-sexp) (point)))))
(global-set-key (kbd "C-c w") 'copy-backward-sexp)
(defun sort-words (reverse beg end)
"Sort words in region alphabetically, in REVERSE if negative.
Prefixed with negative \\[universal-argument], sorts in reverse.
The variable `sort-fold-case' determines whether alphabetic case
affects the sort order.
See `sort-regexp-fields'."
(interactive "*P\nr")
(sort-regexp-fields reverse "\\w+" "\\&" beg end))
(defun sort-symbols (reverse beg end)
"Sort symbols in region alphabetically, in REVERSE if negative.
See `sort-words'."
(interactive "*P\nr")
(sort-regexp-fields reverse "\\(\\sw\\|\\s_\\)+" "\\&" beg end))
(require 'helm-config)
(helm-mode 1)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x b") 'helm-mini)
(when (executable-find "ag")
(setq helm-grep-default-command "ag -Hn --smart-case --no-group --color %e %p %f"
helm-grep-default-recurse-command "ag -H --smart-case --no-group --color --clojure --terraform --salt %e %p %f"))
;; (when (executable-find "ack")
;; (setq helm-grep-default-command "ack -Hn --smart-case --no-group --color %e %p %f"
;; helm-grep-default-recurse-command "ack -H --smart-case --no-group --color %e %p %f"))
(helm-cider-mode 1)
(projectile-global-mode)
(define-key projectile-mode-map (kbd "M-p") 'projectile-command-map)
(setq projectile-completion-system 'helm)
(helm-projectile-on)
(require 'helm-grep)
(defun helm-projectile-ack-types (&optional dir)
"Helm version of projectile-ack."
(interactive)
(let ((project-root (or dir (projectile-project-root) (error "You're not in a project"))))
(let (;; (ack-ignored (mapconcat
;; 'identity
;; (cl-union (mapcar (lambda (path)
;; (concat "--ignore-dir=" (file-name-nondirectory (directory-file-name path))))
;; (projectile-ignored-directories))
;; (mapcar (lambda (path)
;; (concat "--ignore-file=match:" (shell-quote-argument path)))
;; (append (projectile-ignored-files) (projectile-patterns-to-ignore)))) " "))
(ack-ignored (helm-grep-read-ack-type))
(helm-ack-grep-executable (cond
((executable-find "ack") "ack")
((executable-find "ack-grep") "ack-grep")
(t (error "ack or ack-grep is not available")))))
(funcall 'run-with-timer 0.01 nil
#'helm-projectile-grep-or-ack project-root t ack-ignored helm-ack-grep-executable))))
(define-key projectile-mode-map (kbd "M-p s g") 'helm-projectile-ag)
(require 'ivy)
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(require 'swiper)
(global-set-key (kbd "C-s") 'swiper)
;; (defun dabbrev-complation-at-point ()
;; (dabbrev--reset-global-variables)
;; (let* ((abbrev (dabbrev--abbrev-at-point))
;; (candidates (dabbrev--find-all-expansions abbrev t))
;; (bnd (bounds-of-thing-at-point 'symbol)))
;; (list (car bnd) (cdr bnd) candidates)))
;; (add-to-list 'completion-at-point-functions 'dabbrev-complation-at-point)
;;(global-set-key (kbd "M-/") 'completion-at-point)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 30)
(helm-autoresize-mode 1)
(setq helm-split-window-in-side-p nil ; open helm buffer inside current window, not occupy whole other window
;; move to end or beginning of source when reaching top or bottom of source.
;; also makes it so that sources are locked in helm-mini, need to use C-o to get around
helm-move-to-line-cycle-in-source nil
helm-ff-search-library-in-sexp t ; search for library in `require' and `declare-function' sexp.
helm-scroll-amount 8 ; scroll 8 lines other window using M-<next>/M-<prior>
helm-ff-file-name-history-use-recentf t
helm-echo-input-in-header-line t)
(setq helm-buffers-fuzzy-matching t
helm-recentf-fuzzy-match t)