-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
465 lines (351 loc) · 14.2 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
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
;; Start Emacs as a server
(require 'server)
(unless (server-running-p)
(server-start)) ;; запустить Emacs как сервер, если ОС - GNU/Linux
(package-initialize)
(load "~/.emacs.rc/rc.el")
(load "~/.emacs.rc/misc-rc.el")
(load "~/.emacs.rc/org-mode-rc.el")
(load "~/.emacs.rc/autocommit-rc.el")
;;; Appearance
(defun rc/get-default-font ()
(cond
((eq system-type 'windows-nt) "Consolas-13")
((eq system-type 'gnu/linux) "Iosevka-12")))
(add-to-list 'default-frame-alist `(font . ,(rc/get-default-font)))
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
(column-number-mode 1)
(show-paren-mode 1)
;; (rc/require-theme 'gruber-darker)
(rc/require-theme 'zenburn)
(eval-after-load 'zenburn
(set-face-attribute 'line-number nil :inherit 'default))
;;; ido
(rc/require 'smex 'ido-completing-read+)
(require 'ido-completing-read+)
(ido-mode 1)
(ido-everywhere 1)
(ido-ubiquitous-mode 1)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
;;; c-mode
(setq-default c-basic-offset 4
c-default-style '((java-mode . "java")
(awk-mode . "awk")
(other . "bsd")))
(add-hook 'c-mode-hook (lambda ()
(interactive)
(c-toggle-comment-style -1)))
;;; Paredit
(rc/require 'paredit)
(defun rc/turn-on-paredit ()
(interactive)
(paredit-mode 1))
(add-hook 'emacs-lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'clojure-mode-hook 'rc/turn-on-paredit)
(add-hook 'lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'common-lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'scheme-mode-hook 'rc/turn-on-paredit)
(add-hook 'racket-mode-hook 'rc/turn-on-paredit)
;;; Emacs lisp
(add-hook 'emacs-lisp-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-j")
(quote eval-print-last-sexp))))
(add-to-list 'auto-mode-alist '("Cask" . emacs-lisp-mode))
;;; Haskell mode
(rc/require 'haskell-mode)
(setq haskell-process-type 'cabal-new-repl)
(setq haskell-process-log t)
(add-hook 'haskell-mode-hook 'haskell-indent-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'haskell-doc-mode)
(add-hook 'haskell-mode-hook 'hindent-mode)
;;; Whitespace mode
(defun rc/set-up-whitespace-handling ()
(interactive)
(whitespace-mode 1)
(add-to-list 'write-file-functions 'delete-trailing-whitespace))
(add-hook 'tuareg-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'c++-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'c-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'emacs-lisp-mode 'rc/set-up-whitespace-handling)
(add-hook 'java-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'lua-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'rust-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'scala-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'markdown-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'haskell-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'python-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'erlang-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'asm-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'nasm-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'go-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'nim-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'yaml-mode-hook 'rc/set-up-whitespace-handling)
;;; display-line-numbers-mode
(when (version<= "26.0.50" emacs-version)
(global-display-line-numbers-mode))
;;; magit
;; magit requres this lib, but it is not installed automatically on
;; Windows.
(rc/require 'cl-lib)
(rc/require 'magit)
(setq magit-auto-revert-mode nil)
(global-set-key (kbd "C-c m s") 'magit-status)
(global-set-key (kbd "C-c m l") 'magit-log)
;;; multiple cursors
(rc/require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-\"") 'mc/skip-to-next-like-this)
(global-set-key (kbd "C-:") 'mc/skip-to-previous-like-this)
;;; dired
(require 'dired-x)
(setq dired-omit-files
(concat dired-omit-files "\\|^\\..+$"))
(setq-default dired-dwim-target t)
(setq dired-listing-switches "-alh")
;;; helm
(rc/require 'helm 'helm-cmd-t 'helm-git-grep 'helm-ls-git)
(setq helm-ff-transformer-show-only-basename nil)
(global-set-key (kbd "C-c h t") 'helm-cmd-t)
(global-set-key (kbd "C-c h g g") 'helm-git-grep)
(global-set-key (kbd "C-c h g l") 'helm-ls-git-ls)
(global-set-key (kbd "C-c h f") 'helm-find)
(global-set-key (kbd "C-c h a") 'helm-org-agenda-files-headings)
(global-set-key (kbd "C-c h r") 'helm-recentf)
;;; yasnippet
(rc/require 'yasnippet)
(require 'yasnippet)
(setq yas/triggers-in-field nil)
(setq yas-snippet-dirs '("~/.emacs.snippets/"))
(yas-global-mode 1)
;;; word-wrap
(defun rc/enable-word-wrap ()
(interactive)
(toggle-word-wrap 1))
(add-hook 'markdown-mode-hook 'rc/enable-word-wrap)
;;; nxml
(add-to-list 'auto-mode-alist '("\\.html\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.xsd\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.ant\\'" . nxml-mode))
;;; tramp
;;; http://stackoverflow.com/questions/13794433/how-to-disable-autosave-for-tramp-buffers-in-emacs
(setq tramp-auto-save-directory "/tmp")
;;; powershell
(rc/require 'powershell)
(add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode))
(add-to-list 'auto-mode-alist '("\\.psm1\\'" . powershell-mode))
;;; eldoc mode
(defun rc/turn-on-eldoc-mode ()
(interactive)
(eldoc-mode 1))
(add-hook 'emacs-lisp-mode-hook 'rc/turn-on-eldoc-mode)
;;; Company
(rc/require 'company)
(require 'company)
(global-company-mode)
(add-hook 'tuareg-mode-hook
(lambda ()
(interactive)
(company-mode 0)))
;;; Tide
(rc/require 'tide)
(defun rc/turn-on-tide ()
(interactive)
(tide-setup))
(add-hook 'typescript-mode-hook 'rc/turn-on-tide)
;;; Editorconfig
(rc/require 'editorconfig)
(editorconfig-mode 1)
;;; Proof general
(rc/require 'proof-general)
(add-hook 'coq-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-q C-n")
(quote proof-assert-until-point-interactive))))
;;; Nasm Mode
(rc/require 'nasm-mode)
(add-to-list 'auto-mode-alist '("\\.asm\\'" . nasm-mode))
;;; LaTeX mode
(add-hook 'tex-mode-hook
(lambda ()
(interactive)
(add-to-list 'tex-verbatim-environments "code")))
;;; Move Text
(rc/require 'move-text)
(global-set-key (kbd "M-p") 'move-text-up)
(global-set-key (kbd "M-n") 'move-text-down)
;;; Ebisp
(add-to-list 'auto-mode-alist '("\\.ebi\\'" . lisp-mode))
;;; Packages that don't require configuration
(rc/require
'scala-mode
'd-mode
'yaml-mode
'glsl-mode
'tuareg
'lua-mode
'less-css-mode
'graphviz-dot-mode
'clojure-mode
'cmake-mode
'rust-mode
'csharp-mode
'nim-mode
'jinja2-mode
'markdown-mode
'purescript-mode
'nix-mode
'dockerfile-mode
;;'love-minor-mode
'toml-mode
'nginx-mode
'kotlin-mode
'go-mode
'php-mode
'racket-mode
'qml-mode
'ag
'hindent
'elpy
'typescript-mode
'rfc-mode
'sml-mode
)
(load "~/.emacs.shadow/shadow-rc.el" t)
(add-to-list 'load-path "~/.emacs.local/")
(require 'basm-mode)
(require 'simpc-mode)
(add-to-list 'auto-mode-alist '("\\.[hc]\\(pp\\)?\\'" . simpc-mode))
(defun astyle-buffer (&optional justify)
(interactive)
(let ((saved-line-number (line-number-at-pos)))
(shell-command-on-region
(point-min)
(point-max)
"astyle --style=kr"
nil
t)
(goto-line saved-line-number)))
(add-hook 'simpc-mode-hook
(lambda ()
(interactive)
(setq-local fill-paragraph-function 'astyle-buffer)))
(require 'compile)
;; pascalik.pas(24,44) Error: Can't evaluate constant expression
compilation-error-regexp-alist-alist
(add-to-list 'compilation-error-regexp-alist
'("\\([a-zA-Z0-9\\.]+\\)(\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?) \\(Warning:\\)?"
1 2 (4) (5)))
(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.
'(display-line-numbers-type 'relative)
'(org-agenda-dim-blocked-tasks nil)
'(org-agenda-exporter-settings '((org-agenda-tag-filter-preset (list "+personal"))))
'(org-cliplink-transport-implementation 'url-el)
'(org-enforce-todo-dependencies nil)
'(org-modules
'(org-bbdb org-bibtex org-docview org-gnus org-habit org-info org-irc org-mhe org-rmail org-w3m))
'(org-refile-use-outline-path 'file)
'(package-selected-packages
'(rainbow-mode proof-general elpy hindent ag qml-mode racket-mode php-mode go-mode kotlin-mode nginx-mode toml-mode love-minor-mode dockerfile-mode nix-mode purescript-mode markdown-mode jinja2-mode nim-mode csharp-mode rust-mode cmake-mode clojure-mode graphviz-dot-mode lua-mode tuareg glsl-mode yaml-mode d-mode scala-mode move-text nasm-mode editorconfig tide company powershell js2-mode yasnippet helm-ls-git helm-git-grep helm-cmd-t helm multiple-cursors magit haskell-mode paredit ido-completing-read+ smex gruber-darker-theme org-cliplink dash-functional dash))
'(safe-local-variable-values
'((eval progn
(auto-revert-mode 1)
(rc/autopull-changes)
(add-hook 'after-save-hook 'rc/autocommit-changes nil 'make-it-local))))
'(whitespace-style
'(face tabs spaces trailing space-before-tab newline indentation empty space-after-tab space-mark tab-mark)))
(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.
)
;; Display the name of the current buffer in the title bar
(setq frame-title-format "Emacs: %b")
;; Electric-modes settings
(electric-pair-mode 1) ;; автозакрытие {},[],() с переводом курсора внутрь скобок
(electric-indent-mode -1) ;; отключить индентацию electric-indent-mod'ом (default in Emacs-24.4)
(blink-cursor-mode -1) ;; курсор не мигает
(setq use-dialog-box nil) ;; никаких графических диалогов и окон - все через минибуфер
(setq redisplay-dont-pause t) ;; лучшая отрисовка буфера
(setq ring-bell-function 'ignore) ;; отключить звуковой сигнал
;; Disable backup/autosave files
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq auto-save-list-file-name nil) ;; я так привык... хотите включить - замените nil на t
;; Coding-system settings
(set-language-environment 'UTF-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq-default coding-system-for-read 'utf-8)
(setq file-name-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8-unix)
(set-terminal-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; Line wrapping
(setq word-wrap t) ;; переносить по словам
(global-visual-line-mode t)
;; Buffer Selection and ibuffer settings
(require 'bs)
(require 'ibuffer)
(defalias 'list-buffers 'ibuffer) ;; отдельный список буферов при нажатии C-x C-b
(global-set-key (kbd "<f2>") 'bs-show) ;; запуск buffer selection кнопкой F2
;; Syntax highlighting
(require 'font-lock)
(global-font-lock-mode t) ;; включено с версии Emacs-22. На всякий...
(setq font-lock-maximum-decoration t)
;; Indent settings
(setq-default indent-tabs-mode nil) ;; отключить возможность ставить отступы TAB'ом
(setq-default tab-width 4) ;; ширина табуляции - 4 пробельных символа
(setq-default c-basic-offset 4)
(setq-default standart-indent 4) ;; стандартная ширина отступа - 4 пробельных символа
(setq-default lisp-body-indent 4) ;; сдвигать Lisp-выражения на 4 пробельных символа
(global-set-key (kbd "RET") 'newline-and-indent) ;; при нажатии Enter перевести каретку и сделать отступ
(setq lisp-indent-function 'common-lisp-indent-function)
;; Scrolling settings
(setq scroll-step 1) ;; вверх-вниз по 1 строке
(setq scroll-margin 10) ;; сдвигать буфер верх/вниз когда курсор в 10 шагах от верхней/нижней границы
(setq scroll-conservatively 10000)
;; Short messages
(defalias 'yes-or-no-p 'y-or-n-p)
;; End of file newlines
(setq require-final-newline t) ;; добавить новую пустую строку в конец файла при сохранении
(setq next-line-add-newlines nil) ;; не добавлять новую строку в конец при смещении курсора стрелками
;; Highlight search resaults
(setq search-highlight t)
(setq query-replace-highlight t)
(add-to-list 'load-path "~/.emacs.d/lisp/")
;; must come before loading xah-fly-keys
(setq xah-fly-use-control-key nil)
(setq xah-fly-use-meta-key nil) ; must come before loading xah-fly-keys
(setq xah-fly-M-x-command 'execute-extended-command)
(setq xah-fly-M-x-command 'smex)
(setq xah-fly-M-x-command 'helm-M-x)
(setq xah-fly-M-x-command 'counsel-M-x)
(require 'xah-fly-keys)
;; specify a layout
(xah-fly-keys-set-layout "qwerty")
;; make F4 activate command mode
(global-set-key (kbd "<f4>") 'xah-fly-command-mode-activate)
(xah-fly-keys 1)
(add-to-list 'load-path "lisp/which-key.el")
(require 'which-key)
(which-key-mode)
; make typing delete/overwrites selected text
(delete-selection-mode 1)
;; disable shift select
(setq shift-select-mode nil)
(define-key key-translation-map (kbd "ESC") (kbd "C-g"))
(global-set-key (kbd "<f9>") xah-fly-leader-key-map)
; must come after loading xah-fly-keys