-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo_emacs.conf
438 lines (369 loc) · 15 KB
/
go_emacs.conf
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
;;--------------窗口界面设置------------------
(set-foreground-color "grey")
(set-background-color "black")
(set-cursor-color "gold1")
(set-mouse-color "gold1")
;;取消滚动栏
(set-scroll-bar-mode nil)
;;取消工具栏
(tool-bar-mode nil)
;;启动设置
(setq default-frame-alist
'((vertical-scroll-bars)
(top . 0)
(left . 0)
(width . 80)
(height . 40)
(background-color . "black")
(foreground-color . "grey")
(cursor-color . "gold1")
(mouse-color . "gold1")
(tool-bar-lines . 0)
(menu-bar-lines . 0)
(right-fringe)
(left-fringe)))
;;启动自动最大化(数据自己调整,注意格式,如(top . 0),圆点前后都要留有空格)
(setq initial-frame-alist '((top . 10) (left . 0) (width . 148) (height . 39)))
;; 设置另外一些颜色:语法高亮显示的背景和主题,区域选择的背景和主题,二次选择的>背景和选择
(set-face-foreground 'highlight "white")
(set-face-background 'highlight "blue")
(set-face-foreground 'region "cyan")
(set-face-background 'region "blue")
(set-face-foreground 'secondary-selection "skyblue")
(set-face-background 'secondary-selection "darkblue")
;;ido的配置,这个可以使你在用C-x C-f打开文件的时候在后面有提示;
;;这里是直接打开了ido的支持,在emacs23中这个是自带的.
(ido-mode t)
;;ido模式中不保存目录列表,解决退出Emacs时ido要询问编码的问题。
(setq ido-save-directory-list-file nil)
;;关闭烦人的出错时的提示声
(setq visible-bell t)
;;关闭emacs启动时的画面
(setq inhibit-startup-message t)
;;关闭gnus启动时的画面
(setq gnus-inhibit-startup-message t)
;; 改变 Emacs 固执的要你回答 yes 的行为。按 y 或空格键表示 yes,n 表示 no。
(fset 'yes-or-no-p 'y-or-n-p)
;;显示行列号
(setq column-number-mode t)
(setq line-number-mode t)
;; 语法高亮。除 shell-mode 和 text-mode 之外的模式中使用语法高亮。
(setq font-lock-maximum-decoration t)
(setq font-lock-global-modes '(not shell-mode text-mode))
(setq font-lock-verbose t)
(setq font-lock-maximum-size '((t . 1048576) (vm-mode . 5250000)))
;;close current window
(global-set-key [f5] 'kill-this-buffer)
(global-set-key [f4] 'goto-line)
;; comment and uncomment
(global-set-key [?\C-c ?\C-/] 'comment-or-uncomment-region)
;;不要在鼠标点击的那个地方插入剪贴板内容。我不喜欢那样,经常把我的文档搞的一团糟。我觉得先用光标定位,然后鼠标中键点击要好的多。不管你的光标在文档的那个位置,或是在 minibuffer,鼠标中键一点击,X selection 的内容就被插入到那个位置。
(global-linum-mode t)
(setq mouse-yank-at-point t)
;;设置粘贴缓冲条目数量.用一个很大的kill ring(最多的记录个数). 这样防止我不小心删掉重要的东西
(setq kill-ring-max 200)
;; Autofill in all modes;;
(setq-default auto-fill-function 'do-auto-fill)
;;把 fill-column 设为 60. 这样的文字更好读
(setq default-fill-column 120)
;;防止页面滚动时跳动, scroll-margin 3 可以在靠近屏幕边沿3行时就开始滚动,可以很好的看到上下文。
(setq scroll-margin 3 scroll-conservatively 10000)
;;打开括号匹配显示模式
(show-paren-mode t)
;;tab键为4个字符宽度
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-stop-list ())
;;括号匹配时可以高亮显示另外一边的括号,但光标不会烦人的跳到另一个括号处。
(setq show-paren-style 'parenthesis)
;;光标靠近鼠标指针时,让鼠标指针自动让开,别挡住视线。
(mouse-avoidance-mode 'animate)
;;在标题栏显示buffer的名字,而不是 [email protected] 这样没用的提示。
(setq frame-title-format "emacs@%b")
;;进行语法加亮。
(setq global-font-lock-mode t)
;; 在行首 C-k 时,同时删除该行。
(setq-default kill-whole-line t)
;; 设定不产生备份文件
(setq make-backup-files nil)
;; 不生成临时文件
(setq-default make-backup-files nil)
;;允许emacs和外部其他程序的粘贴
(setq x-select-enable-clipboard t)
;;设置有用的个人信息,这在很多地方有用。
(setq user-full-name "songli")
;; 自动的在文件末增加一新行
(setq require-final-newline t)
;; auto save
(setq auto-save-default t)
;;设置F10为撤销
(global-set-key [f10] 'undo)
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
'("melpa" . "http://melpa.org/packages/")
t)
(package-initialize))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ecb
(require 'ecb)
(require 'ecb-autogen)
(setq ecb-version-check nil)
(setq stack-trace-on-error nil)
;;ecb启动的时候会弹出一个提示窗口,如果不想看到它,可以在emacs配置文件(~/.emacs)里加这一句:
(setq ecb-auto-activate t
ecb-tip-of-the-day nil)
;(setq ecb-tip-of-the-day nil)
(ecb-activate)
(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.
'(column-number-mode t)
'(ecb-layout-window-sizes nil)
'(ecb-options-version "2.50")
'(ecb-primary-secondary-mouse-buttons (quote mouse-1--mouse-2))
'(ecb-windows-width 0.3)
'(show-paren-mode t))
(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.
'(default ((t (:family "Courier 10 Pitch" :foundry "bitstream" :slant normal :weight normal :height 113 :width normal)))))
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;;ecb的导航窗口里的东西默认不能用鼠标点选/打开,用键盘回车可以。如果想用鼠标,配置文件里加这一句:
;;(ecb-primary-secondary-mouse-buttons (quote mouse-1--C-mouse-1)
;;;; 各窗口间切换
(global-set-key [M-left] 'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up] 'windmove-up)
(global-set-key [M-down] 'windmove-down)
;;;; 隐藏和显示ecb窗口
;(local-set-key (kbd "<C-x h>") 'ecb-hide-ecb-windows)
;(define-key global-map [(control-f2)] 'ecb-show-ecb-windows)
;(global-set-key [F3] 'ecb-active-or-deactive)
;;;; 使某一ecb窗口最大化
(define-key global-map "\C-c1" 'ecb-maximize-window-directories)
(define-key global-map "\C-c2" 'ecb-maximize-window-sources)
(define-key global-map "\C-c3" 'ecb-maximize-window-methods)
(define-key global-map "\C-c4" 'ecb-maximize-window-history)
;;;; 恢复原始窗口布局
(define-key global-map "\C-c0" 'ecb-restore-default-window-sizes)
;; Disable buckets so that history buffer can display more entries
;(setq ecb-history-make-buckets 'never)
;;;;;;;;;;;;;;;;;; program language related ;;;;;;;;;;;;;;;;;;;
;; auto complete
(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(setq-default ac-sources '(ac-source-words-in-same-mode-buffers))
(add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols)))
(add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename)))
(set-face-background 'ac-candidate-face "lightgray")
(set-face-underline 'ac-candidate-face "darkgray")
(set-face-background 'ac-selection-face "steelblue") ;;; 设置比上面截图中更好看的背景颜色
(define-key ac-completing-map "\M-n" 'ac-next) ;;; 列表中通过按M-n来向下移动
(define-key ac-completing-map "\M-p" 'ac-previous)
(setq ac-auto-start 2)
(setq ac-dwim t)
(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(when (load "flymake" t)
;(defun flymake-pyflakes-init ()
;(let* ((temp-file (flymake-init-create-temp-buffer-copy
;'flymake-create-temp-inplace))
;(local-file (file-relative-name
;temp-file
;(file-name-directory buffer-file-name))))
;(list "pyflakes" (list local-file))))
;(add-to-list 'flymake-allowed-file-name-masks
;'("\\.py\\'" flymake-pyflakes-init)))
;(add-hook 'find-file-hook 'flymake-find-file-hook)
;;; flymake for html
;(defun flymake-html-init ()
;(let* ((temp-file (flymake-init-create-temp-buffer-copy
;'flymake-create-temp-inplace))
;(local-file (file-relative-name
;temp-file
;(file-name-directory buffer-file-name))))
;(list "tidy" (list local-file))))
;(add-to-list 'flymake-allowed-file-name-masks
;'("\\.html$\\|\\.ctp" flymake-html-init))
;(add-to-list 'flymake-err-line-patterns
;'("line \\([0-9]+\\) column \\([0-9]+\\) - \\(Warning\\|Error\\): \\(.*\\)"
;nil 1 2 4))
;; Auto Syntax Error Hightlight
;(when (load "flymake" t)
;(defun flymake-pyflakes-init ()
;(let* ((temp-file (flymake-init-create-temp-buffer-copy
;'flymake-create-temp-inplace))
;(local-file (file-relative-name
;temp-file
;(file-name-directory buffer-file-name))))
;(list "pyflakes" (list local-file))))
;(add-to-list 'flymake-allowed-file-name-masks
;'("\\.py\\'" flymake-pyflakes-init))
;(add-hook 'find-file-hook 'flymake-find-file-hook)
;(provide 'init_python)
;(defun flymake-html-init ()
;(let* ((temp-file (flymake-init-create-temp-buffer-copy
;'flymake-create-temp-inplace))
;(local-file (file-relative-name
;temp-file
;(file-name-directory buffer-file-name))))
;(list "tidy" (list local-file))))
;(add-to-list 'flymake-allowed-file-name-masks
;'("\\.html$\\|\\.ctp" flymake-html-init))
;(add-to-list 'flymake-err-line-patterns
;'("line \\([0-9]+\\) column \\([0-9]+\\) - \\(Warning\\|Error\\): \\(.*\\)"
;nil 1 2 4)))
;(add-hook 'find-file-hook 'flymake-find-file-hook)
;(provide 'init_python)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;cedet
;(add-to-list 'load-path "~/.emacs.d/plugins/cedet-1.1/common")
;(load-file "~/.emacs.d/plugins/cedet-1.1/common/cedet.el")
;(global-ede-mode 1) ; Enable the Project management system
;(semantic-load-enable-code-helpers) ; Enable prototype help and smart completion
;(global-srecode-minor-mode 1) ; Enable template insertion menu
;(autoload 'js2-mode "js2" nil t)
;(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
;(autoload 'pymacs-apply "pymacs")
;(autoload 'pymacs-call "pymacs")
;(autoload 'pymacs-eval "pymacs" nil t)
;(autoload 'pymacs-exec "pymacs" nil t)
;(autoload 'pymacs-load "pymacs" nil t)
;(pymacs-load "ropemacs" "rope-")
;(setq ropemacs-enable-autoimport t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(autoload 'python-mode "python-mode" "Python Mode." t)
;(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;(add-to-list 'interpreter-mode-alist '("python" . python-mode))
;(require 'python-mode)
;(add-hook 'python-mode-hook
;(lambda ()
;(set-variable 'py-indent-offset 4)
;(set-variable 'indent-tabs-mode nil)
;(define-key py-mode-map (kbd "RET") 'newline-and-indent)
;(smart-operator-mode-on)
;))
;; pymacs
;(autoload 'pymacs-apply "pymacs")
;(autoload 'pymacs-call "pymacs")
;(autoload 'pymacs-eval "pymacs" nil t)
;(autoload 'pymacs-exec "pymacs" nil t)
;(autoload 'pymacs-load "pymacs" nil t)
;(pymacs-load "ropemacs" "rope-")
;(setq ropemacs-enable-autoimport t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Auto-completion
;;; Integrates:
;;; 1) Rope
;;; 2) Yasnippet
;;; all with AutoComplete.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(defun prefix-list-elements (list prefix)
;(let (value)
;(nreverse
;(dolist (element list value)
;(setq value (cons (format "%s%s" prefix element) value))))))
;(defvar ac-source-rope
;'((candidates
;. (lambda ()
;(prefix-list-elements (rope-completions) ac-target))))
;"Source for Rope")
;(defun ac-python-find ()
;"Python `ac-find-function'."
;(require 'thingatpt)
;(let ((symbol (car-safe (bounds-of-thing-at-point 'symbol))))
;(if (null symbol)
;(if (string= "." (buffer-substring (- (point) 1) (point)))
;(point)
;nil)
;symbol)))
;(defun ac-python-candidate ()
;"Python `ac-candidates-function'"
;(let (candidates)
;(dolist (source ac-sources)
;(if (symbolp source)
;(setq source (symbol-value source)))
;(let* ((ac-limit (or (cdr-safe (assq 'limit source)) ac-limit))
;(requires (cdr-safe (assq 'requires source)))
;cand)
;(if (or (null requires)
;(>= (length ac-target) requires))
;(setq cand
;(delq nil
;(mapcar (lambda (candidate)
;(propertize candidate 'source source))
;(funcall (cdr (assq 'candidates source)))))))
;(if (and (> ac-limit 1)
;(> (length cand) ac-limit))
;(setcdr (nthcdr (1- ac-limit) cand) nil))
;(setq candidates (append candidates cand))))
;(delete-dups candidates)))
;(add-hook 'python-mode-hook
;(lambda ()
;(auto-complete-mode 1)
;(set (make-local-variable 'ac-sources)
;(append ac-sources '(ac-source-rope) '(ac-source-yasnippet)))
;(set (make-local-variable 'ac-find-function) 'ac-python-find)
;(set (make-local-variable 'ac-candidate-function) 'ac-python-candidate)
;(set (make-local-variable 'ac-auto-start) nil)))
;;Ryan's python specific tab completion
;(defun ryan-python-tab ()
; Try the following:
; 1) Do a yasnippet expansion
; 2) Do a Rope code completion
; 3) Do an indent
;(interactive)
;(if (eql (ac-start) 0)
;(indent-for-tab-command)))
;(defadvice ac-start (before advice-turn-on-auto-start activate)
;(set (make-local-variable 'ac-auto-start) t))
;(defadvice ac-cleanup (after advice-turn-off-auto-start activate)
;(set (make-local-variable 'ac-auto-start) nil))
;(define-key py-mode-map "\t" 'ryan-python-tab)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;config golang
(add-to-list 'load-path "~/.emacs.d/go-mode.el/")
;(require 'go-mode-autoloads)
(require 'go-mode)
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-g") 'go-goto-imports)))
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-f") 'gofmt)))
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook '(lambda ()
(local-set-key (kbd "C-c C-k") 'godoc)))
(add-to-list 'load-path "/home/song/projects/gopath/src/github.com/dougm/goflymake")
(require 'go-flymake)
;(require 'go-flycheck)
(add-hook 'flymake-mode-hook
(lambda()
(local-set-key (kbd "C-c C-e n") 'flymake-goto-next-error)))
(add-hook 'flymake-mode-hook
(lambda()
(local-set-key (kbd "C-c C-e p") 'flymake-goto-prev-error)))
(add-hook 'flymake-mode-hook
(lambda()
(local-set-key (kbd "C-c C-e m") 'flymake-popup-current-error-menu)))
(add-to-list 'load-path "~/.emacs.d/gocode/emacs")
(require 'go-autocomplete)
(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'load-path "~/.emacs.d/emacs-go-eldoc")
(require 'go-eldoc) ;; Don't need to require, if you install by package.el
(add-hook 'go-mode-hook 'go-eldoc-setup)
(set-face-attribute 'eldoc-highlight-function-argument nil
:underline t :foreground "green"
:weight 'bold)
;; scala mode
(require 'scala-mode)