-
Notifications
You must be signed in to change notification settings - Fork 0
/
emacs
315 lines (267 loc) · 10.4 KB
/
emacs
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
;; -*- mode: emacs-lisp; fill-column: 79; -*-
;; emacs-kicker
;; https://github.com/dimitri/emacs-kicker/blob/master/init.el
;; emacs-prelude
;; https://github.com/bbatsov/prelude
(package-initialize)
(require 'cl) ; common lisp goodies, loop
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(unless (require 'el-get nil 'noerror)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.github.com/dimitri/el-get/master/el-get-install.el")
(let (el-get-master-branch)
(goto-char (point-max))
(eval-print-last-sexp))))
;; now either el-get is `require'd already, or have been `load'ed by the
;; el-get installer.
;; set local recipes
(setq
el-get-sources
'((:name keychain-environment
:description "Loads keychain environment variables into emacs"
:type github
:pkgname "tarsius/keychain-environment"
:post-init (keychain-refresh-environment)
(:name ctable ; jedi dep
:description "Table Component for elisp"
:type github
:pkgname "kiwanami/emacs-ctable")
(:name epc ; jedi dep
:description "An RPC stack for Emacs Lisp"
:type github
:pkgname "kiwanami/emacs-epc"
:depends (deferred ctable)) ; concurrent is in deferred package
(:name jedi ; jedi
:description "An awesome Python auto-completion for Emacs"
:type github
:pkgname "tkf/emacs-jedi"
:build (("make" "requirements"))
:depends (epc auto-complete)
:after (progn
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:setup-keys t) ; optional
(setq jedi:complete-on-dot t))) ; optional
(:name flycheck
:after (progn
;;(add-hook 'after-init-hook #'global-flycheck-mode) ;; enable Flycheck mode in all buffers, in which it can be used
(add-hook 'python-mode-hook 'flycheck-mode)
(setq flycheck-flake8-maximum-line-length 120)))
(:name buffer-move ; have to add your own keys
:after (progn
(global-set-key (kbd "<C-S-up>") 'buf-move-up)
(global-set-key (kbd "<C-S-down>") 'buf-move-down)
(global-set-key (kbd "<C-S-left>") 'buf-move-left)
(global-set-key (kbd "<C-S-right>") 'buf-move-right)))
(:name smex ; a better (ido like) M-x
:after (progn
(setq smex-save-file "~/.emacs.d/.smex-items")
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)))
(:name magit ; git meet emacs, and a binding
:after (progn
(global-set-key (kbd "C-x C-z") 'magit-status)))
(:name goto-last-change ; move pointer back to last change
:after (progn
;; when using AZERTY keyboard, consider C-x C-_
(global-set-key (kbd "C-x C-/") 'goto-last-change))))))
;; now set our own packages
(setq
my:el-get-packages
'(el-get ; el-get is self-hosting
frame-fns ;; TODO required by frame-cmds
frame-cmds ;; TODO make pull req on GH: ^^^^^
keychain-environment
;; escreen ; screen for emacs, C-\ C-h
rbenv ;; using proper ruby version
ace-jump-mode
multiple-cursors
expand-region
highlight-current-line
highlight-indentation
highlight-parentheses
rainbow-mode
rainbow-delimiters
magit
grizzl
projectile
auto-complete ; complete as you type with overlays
ag
markdown-mode
yaml-mode
scala-mode2
ensime
coffee-mode
flymake-coffee
web-mode
smartparens
flycheck
jedi
;; zencoding-mode ; http://www.emacswiki.org/emacs/ZenCoding
bash-completion
color-theme ; nice looking emacs
color-theme-tangotango)) ; check out color-theme-solarized
;; install new packages and init already installed packages
(el-get 'sync my:el-get-packages)
;; -----------------------------------------------------------------------------
;; Look & Feel
;; -----------------------------------------------------------------------------
;; Remove bars
(unless (string-match "apple-darwin" system-configuration)
;; on mac, there's always a menu bar drown, don't have it empty
(menu-bar-mode -1))
(tool-bar-mode -1) ; no tool bar with icons
(scroll-bar-mode -1) ; no scroll bars
;; Theme (check if theme is installed by el-get.el)
(add-to-list 'custom-theme-load-path "~/.emacs.d/el-get/color-theme-tangotango")
(load-theme 'tangotango t)
;; Font
(if window-system
(if (string-match "apple-darwin" system-configuration)
(set-face-font 'default "Monaco-13")
(set-face-font 'default "Monospace-11")))
;; cursor colors
(set-cursor-color "#ff0000")
;; Display continuous lines
(setq-default truncate-lines nil)
;; Do not use tabs for indentation
(setq-default indent-tabs-mode nil)
;; -----------------------------------------------------------------------------
;; Remove whitespaces at the end of file
;; -----------------------------------------------------------------------------
(add-hook 'before-save-hook 'whitespace-cleanup)
;; -----------------------------------------------------------------------------
;; Unique buffer names
;; -----------------------------------------------------------------------------
(require 'uniquify)
(setq uniquify-buffer-name-style 'reverse)
;; -----------------------------------------------------------------------------
;; Clipboard
;; -----------------------------------------------------------------------------
(defun copy-from-x11 ()
(call-process "/usr/bin/xsel" nil t nil "-b"))
(defun paste-to-x11 (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "xsel" "*Messages*" "/usr/bin/xsel" "-ib")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-x11)
(setq interprogram-paste-function 'copy-from-x11)
;; ----------------------------------------------------------------------------
;; Terminal & File Manager
;; ----------------------------------------------------------------------------
(setq terminal-program "/usr/bin/rxvt-unicode")
(setq terminal-fm-program "/usr/bin/ranger")
(defun buffer-dir-name ()
(file-name-directory buffer-file-name))
(defun terminal-option-buffer-dir ()
(let ((dir (buffer-dir-name)))
`("-cd" ,dir)))
(setq terminal-option-ranger '("-e" terminal-fm-program))
(defun run-terminal ()
(interactive)
(start-process "terminal" "*Messages*" terminal-program) (terminal-option-buffer-dir))
(defun run-file-manager ()
(interactive)
(let ((args (append (terminal-option-buffer-dir) terminal-option-ranger)))
(message (second args))
(apply 'start-process "filemanager" "*Messages*" terminal-program args)))
;; ACE jump
(require 'ace-jump-mode)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
;; Smartparens
(require 'smartparens-config)
(require 'smartparens-ruby)
(smartparens-global-mode 1)
;; Rainbow Mode
(require 'rainbow-mode)
(rainbow-mode 1)
;; Rainbow delimiters
(require 'rainbow-delimiters)
(global-rainbow-delimiters-mode 1)
;; Projectile
(require 'grizzl)
(require 'projectile)
(projectile-global-mode)
(setq projectile-enable-caching t)
(setq projectile-completion-system 'grizzl)
;;(setq projectile-completion-system 'ido)
(global-set-key (kbd "C-S-b") 'projectile-find-file)
;; AC mode
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
(setq ac-ignore-case t)
(append ac-modes '('ruby-mode
'python-mode
'web-mode))
;; Magit
;;(magit-file-header ((t (:foreground "violet"))))
;;(magit-hunk-header ((t (:foreground "blue"))))
;;(magit-header ((t (:foreground "cyan"))))
;;(magit-tag-label ((t (:background "blue" :foreground "orange"))))
;;(magit-diff-add ((t (:foreground "MediumSlateBlue"))))
;;(magit-diff-del ((t (:foreground "maroon"))))
;;(magit-item-highlight ((t (:background "#000012"))))
;; Exchange point and mark hack
(defun exchange-point-and-mark-no-activate ()
"Identical to \\[exchange-point-and-mark] but will not activate the region."
(interactive)
(exchange-point-and-mark)
(deactivate-mark nil))
;;(define-key global-map [remap exchange-point-and-mark] 'exchange-point-and-mark-no-activate)
;;(global-unset-key (kbd "C-x C-x"))
(global-set-key (kbd "C-x C-x") 'exchange-point-and-mark-no-activate)
;; magit
(require 'magit)
(global-set-key (kbd "C-x v g") 'magit-status)
;; ensime
(require 'ensime)
;; rbenv
(require 'rbenv)
(global-rbenv-mode)
;; javascript-mode
(setq js-indent-level 2)
;; markdown-mode
(require 'markdown-mode)
(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.mkd\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))
;; web-mode
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.scala\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-engines-alist
'(("razor" . "\\.scala\\.html\\'"))
)
;; expand-region
(require 'expand-region)
(global-set-key (kbd "C-=") 'er/expand-region)
(global-set-key (kbd "C--") 'er/contract-region)
;; highlight-indentation
(require 'highlight-indentation)
;;(highlight-indentation-mode 1)
(add-hook 'prog-mode-hook 'highlight-indentation-current-column-mode)
(set-face-background 'highlight-indentation-face "dim gray")
(set-face-background 'highlight-indentation-current-column-face "azure4")
;; ido-mode
(require 'ido)
(ido-mode t)
(put 'upcase-region 'disabled nil)
;; dired
(require 'dired)
(add-hook 'dired-mode-hook 'ensure-buffer-name-starts-with-dired)
(defun ensure-buffer-name-starts-with-dired ()
"change buffer name to start with 'dired|'"
(let ((name (buffer-name)))
(if (not (string-match "/$" name))
(rename-buffer (concat name "/dired")))))
;; set frame title
(require 'frame-fns)
(require 'frame-cmds)
(setq frame-title-format '("" "%f @ emacs-" emacs-version))
;; ssh-agent gnupg-agent
(require 'keychain-environment)
(keychain-refresh-environment)