forked from thearthur/arthur-s-emacs-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
291 lines (244 loc) · 11.3 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
;; -----------------------------------------
;; -- Allow for different startup directory --
;; -- Startup with: emacs -q -l some-file --
;; ------------------------------------------
;; PLEASE REVIEW IF CLOJURE OR JULIA ARE NOT WORKING
;; CBD:: comment/uncomment (load "ess-site") in order to speed up when not using clojure or julia
;; Search for CBD
(setenv "TERM" "linux") ;; Work around for Blink to use ssh
;;(setenv "TERM" "dumb") ;; Work around for Blink to use ssh
;; Customize .emacs.d and emacs -l to load an alternative directory
(setq args command-line-args)
(setq my-init-directory user-emacs-directory)
(setq init-file nil)
(while args
(if (string-equal "-l" (car args))
(setq init-file (car (cdr args))))
(pop args))
(if init-file
(if (file-name-directory init-file)
(setq my-init-directory (file-name-directory init-file))
(error "Error: when indicating a startup file with 'emacs -l' specify a directory in it's path, not just a filename.")))
(if (not (string-equal my-init-directory "~/.emacs.d/" ))
(add-to-list 'load-path my-init-directory))
(add-to-list 'load-path (concat my-init-directory "custom.d/"))
(setq package-user-dir (concat my-init-directory "elpa/"))
;; ---------------------
;; -- Package Settings --
;; ---------------------
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
;; Add in your own as you wish:
(defvar my-packages '(
ansi-color
smooth-scrolling ; Provide smooth scrolling
whitespace ;Toggles on whitespace
magit
use-package
helm
company
undo-tree
smartparens
rainbow-delimiters
;; cider ; breaks-queue not found; Include in profiles.clj: {:user {:plugins [[cider/cider-nrepl "0.8.2"]]}}
aggressive-indent
julia-mode ; Julia
julia-repl
ample-zen-theme ; Several themes
ample-theme
atom-dark-theme
elpy ; Python
)
"A list of packages to ensure are installed at launch.")
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
;; ---------------------
;; -- Global Settings --
;; ---------------------
(menu-bar-mode -1) ; Disable menu bar at top of screen
;(normal-erase-is-backspace-mode 0) ; Delete key should delete backwards
(setq column-number-mode t)
(setq inhibit-startup-message t)
(setq ns-alternate-modifier 'meta) ; Set Mac's Fn key to Hyper
(setq ns-command-modifier 'super) ; Set Mac's Fn key to Hyper ;; Not working on OSx 10.9 , but reminder to find a fix
(defun next5()(interactive) (next-line 5)) ; Quicker next
(defun prev5()(interactive) (previous-line 5)) ; Quicker previous
;; --------------------------
;; -- Global Key Bindings --
;; --------------------------
(fset 'align-equals "\C-[xalign-regex\C-m=\C-m")
(global-set-key "\M-n" 'next5) ; Next-five-Key
(global-set-key "\M-p" 'prev5) ; Previous-five-Key
(global-set-key "\M-?" 'help) ; Help-Key
(global-set-key "\C-?" 'help-command) ; Help-Command
(global-set-key "\C-z" 'zap-to-char) ; Zap-point-to-char-Key
(global-set-key "\M-h" 'backward-delete-word) ; Bacward-delete-word-key
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\M-=" 'align-equals) ; Aligment-Key
(global-set-key "\C-c;"'comment-or-uncomment-region) ; Commment/Uncomment-Key
(global-set-key "\M-o" 'other-window) ; Other-window-Key
(global-set-key "\M-i" 'back-window) ; Prior-window-Key
;;(global-set-key "\C-d" 'delete-backward-char)
(global-set-key (kbd "DEL") 'delete-backward-char) ; kbd required to fix DEL key
(require 'epa-file)
(epa-file-enable)
;; ---------------------------
;; -- uniquify --
;; ---------------------------
(require 'uniquify)
;; ---------------------------
;; -- dired-x --
;; ---------------------------
(require 'dired-x)
;; ---------------------------
;; -- compile --
;; ---------------------------
(require 'compile)
;; ---------------------------
;; -- smooth-scrolling --
;; ---------------------------
(smooth-scrolling-mode t)
;; ---------------------------
;; -- helm configuration --
;; ---------------------------
(require 'helm)
(require 'helm-config)
(helm-mode t)
(global-set-key (kbd "C-c h") 'helm-command-prefix) ; Helm-command (Changed to "C-c h"); "C-c h i" opens i-menu. VERY USEFUL
(global-set-key (kbd "M-x") 'helm-M-x) ; Alternative binding for "M-x"
(global-unset-key (kbd "C-x c")) ; Cannot change `helm-command-prefix-key' once `helm-config' is loaded.
(define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action); Rebind tab to run persistent action
(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; Make TAB work in terminal
(define-key helm-map (kbd "C-z") 'helm-select-action) ; List actions using C-z
(global-set-key (kbd "M-y") 'helm-show-kill-ring) ; Uber version of kill-ring
(global-set-key (kbd "C-x b") 'helm-mini) ; Helm version of searching buffer
(global-set-key (kbd "C-c h o") 'helm-occur) ; Helm version of occur
(global-set-key (kbd "C-x C-f") 'helm-find-files) ; Helm file navigation
(setq helm-M-x-fuzzy-match t) ; Fuzzy matching for helm-M-x
(setq helm-buffers-fuzzy-matching t ; Fuzzy matching for buffers
helm-recentf-fuzzy-match t
helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-apropos-fuzzy-match t)
(when (executable-find "curl")
(setq helm-google-suggest-use-curl-p t))
(setq helm-split-window-in-side-p t ; open helm buffer inside current window, not occupy whole other window
helm-move-to-line-cycle-in-source t ; move to end or beginning of source when reaching top or bottom of source.
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-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(helm-autoresize-mode 1)
;; ---------------------------
;; -- company configuration --
;; ---------------------------
(global-company-mode)
(define-key company-active-map (kbd "\C-n") 'company-select-next)
(define-key company-active-map (kbd "\C-p") 'company-select-previous)
(define-key company-active-map (kbd "\C-d") 'company-show-doc-buffer)
(define-key company-active-map (kbd "<tab>") 'company-complete)
;; ---------------------------
;; -- smartparens configuration --
;; ---------------------------
;; New/simpler/default configuration
(require 'smartparens-config)
(smartparens-global-strict-mode)
(show-smartparens-global-mode)
;; -----------------------------------------
;; -- Rainbow-delimiters-mode configuration --
;; -----------------------------------------
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
;; -----------------------------------------
;; -- Undo-tree--mode configuration --
;; -----------------------------------------
(require 'undo-tree)
(global-undo-tree-mode)
;; -----------------------------------------
;; -- Misc configuration --
;; -----------------------------------------
(setq-default ispell-program-name "aspell") ; Change default spell-checking program
;;(setq-default ispell-program-name "hunspell") ; package-install hunspell; package-install hunspell_en
(setq user-mail-address "[email protected]") ; Set my email address
;; -----------------------------------------
;; -- Themes --
;; -----------------------------------------
;; Make sure that this is in .bashrc: export TERM="xterm-256color"
;;ample-zen-theme
;;ample-theme
;;atom-dark-theme
(load-theme 'ample-zen t)
(enable-theme 'ample-zen)
;; -------------------------------------------
;; -- Ess Mode Configuration (R)---
;; -------------------------------------------
;; Ess is not part of package management system, so need to run 'setup.sh' in order to install ess.d.
(add-to-list 'load-path (concat my-init-directory "ess.d/lisp"))
;; CBD comment/uncomment (load "ess-site") in order to speed up when not using clojure or julia
;;(load "ess-site")
;;(require 'ess-eldoc) ; OK TO LEAVE COMMENTED
(setq-default inferior-R-args "--no-restore-history --no-save ")
(setq ess-default-style 'RRR)
(setq ess-tab-complete-in-script t) ; Autocomplete in .R files M-tab
(setq ess-first-tab-never-complete t)
(setq ess-eldoc-show-on-symbol t)
(setq ess-eldoc-abbreviation-style 'strong)
(defun run-R()
(interactive)
(if (not (member "*R*" (mapcar (function buffer-name) (buffer-list))))
(progn
(delete-other-windows)
(setq w1 (selected-window))
(setq w1name (buffer-name))
(setq w2 (split-window w1 nil t))
(R)
;; (set-window-buffer w1 "*R*") ; R on the left
;; (set-window-buffer w2 w1name))))
(set-window-buffer w2 "*R*")
(set-window-buffer w1 w1name))))
;; -------------------------------------------
;; -- Julia Mode Configuration ---
;; -------------------------------------------
(require 'julia-mode)
(require 'julia-repl)
(add-hook 'julia-mode-hook 'julia-repl-mode)
(set-language-environment "UTF-8")
;;(setq inferior-julia-program-name "/usr/local/bin/julia")
;; (defun run-julia()
;; (interactive)
;; (if (not (member "*julia*" (mapcar (function buffer-name) (buffer-list))))
;; (progn
;; (delete-other-windows)
;; (setq w1 (selected-window))
;; (setq w1name (buffer-name))
;; (setq w2 (split-window w1 nil t))
;; (julia)
;; (set-window-buffer w2 "*julia*")
;; (set-window-buffer w1 w1name))))
;; -------------------------------------------
;; -- Clojure(cider) Mode Configuration ---
;; -------------------------------------------
(add-hook 'cider-mode-hook #'eldoc-mode) ; Enable eldoc in Clojure buffers
(setq nrepl-hide-special-buffers t) ; Hide the *nrepl-connection* and *nrepl-server* buffers from appearing in some buffer switching commands
(setq cider-show-error-buffer nil)
;;(setq cider-show-error-buffer 'only-in-repl)
;; -------------------------------------------
;; -- Clojure (Other) Mode Configuration ---
;; -------------------------------------------
(require 'aggressive-indent)
(global-aggressive-indent-mode 1)
;; Python
;; ---------------------------
;; -- Python configuration --
;; ---------------------------
(elpy-enable)
(setq python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")
(message "Let's get started...")