forked from mzlogin/config-files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.emacs
246 lines (216 loc) · 8.14 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
(server-start)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
;; set up package repository
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
;; generic settings
(setq default-directory "~/")
(set-language-environment "utf-8")
(prefer-coding-system 'chinese-gbk)
(prefer-coding-system 'utf-8)
(set-file-name-coding-system 'chinese-gbk)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq backup-directory-alist (quote (("." . "~/.backups"))))
(setq frame-title-format "%f")
(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-lisp-symbol-partially
try-complete-lisp-symbol
try-complete-file-name-partially
try-complete-file-name
try-expand-all-abbrevs
try-expand-list
try-expand-line))
;; indent
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(setq tab-stop-list (number-sequence 4 120 4))
(global-set-key (kbd "RET") 'comment-indent-new-line)
(defconst my-c-style
'((c-tab-always-indent . t)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 0)
(block-open . 4)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t)
)
"my c programming style")
;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))
;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; other customizations
(setq tab-width 4
indent-tabs-mode nil)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
;; markdown
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(add-hook 'markdown-mode-hook '(lambda ()
(local-set-key (kbd "RET") 'comment-indent-new-line)))
;; ggtags
(require 'ggtags)
;; helm-gtags
(setq
helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t
helm-gtags-prefix-key "\C-cg"
helm-gtags-suggested-key-mapping t)
(require 'helm-gtags)
;; Enable helm-gtags-mode
(add-hook 'dired-mode-hook 'helm-gtags-mode)
(add-hook 'eshell-mode-hook 'helm-gtags-mode)
(add-hook 'c-mode-hook 'helm-gtags-mode)
(add-hook 'c++-mode-hook 'helm-gtags-mode)
(add-hook 'java-mode-hook 'helm-gtags-mode)
(add-hook 'asm-mode-hook 'helm-gtags-mode)
(define-key helm-gtags-mode-map (kbd "C-c g a") 'helm-gtags-tags-in-this-function)
(define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select)
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
;; code auto completion
(require 'cc-mode)
(require 'semantic)
(require 'company)
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(semantic-mode 1)
(add-hook 'after-init-hook 'global-company-mode)
(setq company-idle-delay 0)
(setq semanticdb-default-save-directory "~/.emacs.d/semanticdb")
(add-hook 'markdown-mode-hook
'(lambda()
(company-mode 0)))
(add-hook 'eshell-mode-hook
'(lambda()
(company-mode 0)))
(semantic-add-system-include "~/.emacs.d/cpp-headers" 'c++-mode)
(require 'function-args)
(fa-config-default)
(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.
;; '(custom-enabled-themes (quote (tango-dark)))
'(global-linum-mode t)
'(inhibit-startup-screen t)
'(tool-bar-mode nil))
(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.
'(fa-face-hint ((t (:background "gold" :foreground "black"))))
'(fa-face-hint-bold ((t (:background "gold" :bold t :foreground "black"))))
'(fa-face-semi ((t (:foreground "#2a00ff" :background "gold" :bold t))))
'(fa-face-type ((t (:foreground "black" :background "gold"))))
'(fa-face-type-bold ((t (:foreground "black" :background "gold" :bold t))))
'(fa-face-type-definition ((t (:foreground "black" :background "gold")))))
(defun windows-nt-spec-settings()
;; Setting English Font
(set-face-attribute
'default nil :font "Consolas 11")
;; Setting Chinese Font
(dolist (charset '(kana han symbol cjk-misc bopomofo))
(set-fontset-font (frame-parameter nil 'font)
charset
(font-spec :family "Microsoft Yahei" :size 16)))
;; Maximize after startup
(run-with-idle-timer 1 nil 'w32-send-sys-command 61488)
;; Set theme
(load-theme 'tango-dark)
)
(defun mac-spec-settings()
;; Setting Font
(set-default-font "-*-Menlo-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1")
(toggle-frame-fullscreen)
)
(cond
((eq system-type 'windows-nt) (windows-nt-spec-settings))
((eq system-type 'darwin) (mac-spec-settings))
)
;; ido-mode for open file tips
(ido-mode t)
;; smex for M-x tips
(global-set-key [(meta x)] (lambda ()
(interactive)
(or (boundp 'smex-cache)
(smex-initialize))
(global-set-key [(meta x)] 'smex)
(smex)))
(global-set-key [(shift meta x)] (lambda ()
(interactive)
(or (boundp 'smex-cache)
(smex-initialize))
(global-set-key [(shift meta x)] 'smex-major-mode-commands)
(smex-major-mode-commands)))
;; projectile
(require 'projectile)
(projectile-global-mode)
(setq projectile-require-project-root nil)
;; org-mode
(add-hook 'org-mode-hook (lambda() (setq truncate-lines nil)))
;; evil-mode
(require 'evil)
(evil-mode t)
;; sr-speedbar
(require 'sr-speedbar)
(setq speedbar-show-unknown-files t)
(global-set-key (kbd "<f5>") 'sr-speedbar-toggle)
;; jedi
(require 'jedi)
(autoload 'jedi:setup "jedi" nil t)
(setq jedi:setup-keys t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)
;; evil-nerd-commenter
(require 'evil-nerd-commenter)
(evilnc-default-hotkeys)
;; autopair
(when (fboundp 'electric-pair-mode)
(electric-pair-mode))
(when (eval-when-compile (version< "24.4" emacs-version))
(electric-indent-mode 1))
;; ielm
(add-hook 'ielm-mode-hook '(lambda() (electric-pair-mode 0)))
;; slime
(setq inferior-lisp-program "sbcl")
(require 'slime-autoloads)
(slime-setup '(slime-fancy))
(add-hook 'slime-repl-mode-hook '(lambda() (electric-pair-mode 0)))
(slime-setup '(slime-company))
;; smooth-scrolling
(require 'smooth-scrolling)
(setq smooth-scroll-margin 3)