-
Notifications
You must be signed in to change notification settings - Fork 0
/
myinit.el
263 lines (223 loc) · 7.29 KB
/
myinit.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
(setq inhibit-starup-message t)
(setq package-enable-at-startup nil)
(setq inhibit-startup-message t) ;; 关闭启动画面
(setq make-backup-files nil) ;; 关闭自动备份
(setq auto-save-default nil) ;; 关闭自动保存
(set-face-attribute 'default nil :height 160) ;; 设置默认字体
(global-linum-mode 1) ;; 打开行数
(tool-bar-mode -1) ;; 关闭工具栏
(global-hl-line-mode t) ;; 高亮显示当前行
(setq initial-frame-alist (quote ((fullscreen . maximized)))) ;; 默认全屏
(add-hook 'emacs-lisp-mode-hook 'show-paren-mode)
(setq truncate-lines nil)
(define-coding-system-alias 'UTF-8 'utf-8)
(use-package which-key
:ensure t
:config (which-key-mode))
(use-package org-bullets
:ensure t
:config (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
(use-package org-pomodoro
:ensure t)
(setq org-todo-keywords
'((sequence "TODO" "DOING" "DONE")))
(setq org-agenda-files '("~/gtd/inbox.org"
"~/gtd/gtd.org"
"~/gtd/tickler.org"))
(setq org-capture-templates '(("t" "Todo [inbox]" entry
(file+headline "~/gtd/inbox.org" "Tasks")
"* TODO %i%?")
("T" "Tickler" entry
(file+headline "~/gtd/tickler.org" "Tickler")
"* %i%? \n %U")))
(setq org-refile-targets '(("~/gtd/gtd.org" :maxlevel . 3)
("~/gtd/someday.org" :level . 1)
("~/gtd/tickler.org" :maxlevel . 2)))
(setq org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELLED(c)")))
(global-set-key "\C-cc" 'org-capture)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(use-package ace-window
:ensure t
:init
(progn
(global-set-key [remap other-window] 'ace-window)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0)))))
))
(use-package counsel
:ensure t)
(use-package swiper
:ensure t
:bind (("C-s" . swiper)
("C-r" . swiper)
("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file))
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
))
;; avy has many splash features
(use-package avy
:ensure t
:bind ("M-s" . avy-goto-char))
(use-package company
:ensure t
:config
(progn
(add-hook 'after-init-hook 'global-company-mode)))
(use-package company-tern
:ensure t
:config
(progn
(add-to-list 'company-backends 'company-tern)
(add-hook 'js2-mode-hook (lambda ()
(tern-mode)))
(define-key tern-mode-keymap (kbd "M-.") nil)
(define-key tern-mode-keymap (kbd "M-,") nil)))
(use-package zenburn-theme
:ensure t
:config (load-theme 'zenburn t))
(use-package atom-one-dark-theme
:ensure t
:config (load-theme 'atom-one-dark t))
;; 安装flycheck
(use-package flycheck
:ensure t
:init
(global-flycheck-mode t))
;; 安装flycheck-less支持
(use-package flymake-less
:ensure t
:config
(add-hook 'less-css-mode-hook 'flymake-less-load))
(use-package company-jedi
:ensure t
:init
(defun my/python-mode-hook ()
(add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'my/python-mode-hook))
(use-package elpy
:ensure t
:config
(elpy-enable))
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1))
(use-package undo-tree
:ensure t
:init
(global-undo-tree-mode))
;; org-mode 相关
(require 'org)
(setq org-src-fontify-natively t) ;; 设置orgmode 代码高亮
(setq org-latex-pdf-process '("xelatex -shell-escape -interaction nonstopmode %f"
"xelatex -shell-escape -interaction nonstopmode %f")) ;; 默认使用latex导出pdf,但是不支持中文,这里使导出时使用xelatex
(setq org-html-doctype "html5") ;; 下面设置导出默认为HTML5
(setq org-html-xml-declaration nil) ;; 不生成XML头信息
(setq org-html-postamble nil) ;; 默认情况下HTML末尾会有几行信息,这行用来取消
(use-package popwin
:ensure t
:config
(popwin-mode 1))
(use-package smartparens
:ensure t
:config
(smartparens-global-mode t)
;; 在emacs-lisp中,单引号不成双出现
(sp-local-pair 'emacs-lisp-mode "'" nil :actions nil))
(use-package js2-mode
:ensure t
:config
(progn
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(setq-default js2-basic-offset 2)
(add-to-list 'interpreter-mode-alist '("node" . js2-mode))
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)))
(defun my-web-mode-indent-setup ()
(setq web-mode-markup-indent-offset 2) ; web-mode, html tag in html file
(setq web-mode-css-indent-offset 2) ; web-mode, css in html file
(setq web-mode-code-indent-offset 2) ; web-mode, js code in html file
)
(use-package web-mode
:ensure t
:config
(progn
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode))
(add-hook 'web-mode-hook 'my-web-mode-indent-setup)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)))
(use-package js2-refactor
:ensure t
:config
(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c RET"))
(use-package vue-mode
:ensure t
:config
(progn
(add-to-list 'auto-mode-alist '("\\.wpy\\'" . vue-mode))))
(use-package less-css-mode
:ensure t
:config
(progn
(add-to-list 'auto-mode-alist '("\\.less\\'" . less-css-mode))
;; 这边没生效,需要调整
(add-hook 'less-css-mode-hook (lambda () (set (make-local-variable 'css-indent-offset) 2)))))
(use-package xref-js2
:ensure t
:config
(progn
(define-key js-mode-map (kbd "M-.") nil)
(add-hook 'js2-mode-hook (lambda ()
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))))
(use-package exec-path-from-shell
:ensure t
:config
(progn
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))))
(use-package expand-region
:ensure t
:config
(global-set-key (kbd "C-=") 'er/expand-region))
(use-package iedit
:ensure t)
(use-package org-page
:ensure t
:config
(progn
(setq op/repository-directory "~/Documents/myblog/") ;; the repository location
(setq op/site-domain "http://your.personal.site.com/") ;; your domain
;;; the configuration below you should choose one, not both
(setq op/personal-disqus-shortname "your_disqus_shortname") ;; your disqus commenting system
(setq op/hashover-comments t) ;; activate hashover self-hosted comment system
(setq op/site-main-title "zhuruliang")
(setq op/site-sub-title "I'm a noob, I need to learn! 菜鸟,学特么的!")
(setq op/personal-github-link "https://www.github.com/zhuruliang/")
(setq op/theme 'org-page-theme-kactus)
))
(use-package nginx-mode
:ensure t)
;; 当光标在两个括号中间时,显示当前所在括号
(define-advice show-paren-function (:around (fn) fix-show-paren-function)
"highlight enclosing parens."
(cond ((looking-at-p "\\s(") (funcall fn))
(t (save-excursion
(ignore-errors (backward-up-list))
(funcall fn)))))
;; 用于删除win中的换行符^M
(defun remove-dos-eol ()
"Replace DOS eolns CR LF with Unix eolns CR"
(interactive)
(goto-char (point-min))
(while (search-forward "\r" nil t) (replace-match "")))