forked from jerryhsieh/Emacs-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.el
More file actions
270 lines (217 loc) · 6.59 KB
/
Copy pathinit.el
File metadata and controls
270 lines (217 loc) · 6.59 KB
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
;;; package --- Summary
;;
;;; Commentary:
;;;
;;; Code:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/"))
(package-initialize)
(load-theme 'manoj-dark t)
;;
;; set autosave and backup directory
;;
(defconst emacs-tmp-dir (format "%s%s%s/" temporary-file-directory "emacs" (user-uid)))
(setq backup-directory-alist `((".*" . ,emacs-tmp-dir)))
(setq auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t)))
(setq auto-save-list-file-prefix emacs-tmp-dir)
;;
;; custome variable path
;;
(setq custom-file "~/.emacs.d/custom-variables.el")
(when (file-exists-p custom-file)
(load custom-file))
;;
;; use use-package
;;
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(use-package diminish :ensure t)
(use-package bind-key :ensure t)
(use-package auto-package-update
:ensure t
:config
(setq auto-package-update-delete-old-versions t)
(setq auto-package-update-hide-results t)
(auto-package-update-maybe))
;;
;; basic setup
;;
(menu-bar-mode -1)
(show-paren-mode t)
(electric-pair-mode t)
(setq electric-pair-pairs '(
(?\' . ?\')
))
(setq-default indent-tabs-mode nil)
(winner-mode t)
;;
;; hideshow
;;
(add-hook 'prog-mode-hook #'hs-minor-mode)
;;
;; multiple cursors
;;
(use-package multiple-cursors
:ensure t
:bind (
("M-3" . mc/mark-next-like-this)
("M-4" . mc/mark-previous-like-this)
:map ctl-x-map
("\C-m" . mc/mark-all-dwim)
("<return>" . mule-keymap)
))
;;
;; ivy mode
;;
(use-package ivy
:ensure t
:diminish (ivy-mode . "")
:config
(ivy-mode 1)
(setq ivy-use-virutal-buffers t)
(setq enable-recursive-minibuffers t)
(setq ivy-height 10)
(setq ivy-initial-inputs-alist nil)
(setq ivy-count-format "%d/%d")
(setq ivy-re-builders-alist
`((t . ivy--regex-ignore-order)))
)
;;
;; counsel
;;
(use-package counsel
:ensure t
:bind (("M-x" . counsel-M-x)
("\C-x \C-f" . counsel-find-file)))
;;
;; swiper
;;
(use-package swiper
:ensure t
:bind (("\C-s" . swiper))
)
;;
;; yasnippet
;;
(use-package yasnippet
:ensure t
:config
(yas-global-mode)
(use-package yasnippet-snippets :ensure t)
)
;;
;; company
;;
(use-package company
:ensure t
:config
(global-company-mode t)
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 3)
(setq company-backends
'((company-files
company-yasnippet
company-keywords
company-capf
)
(company-abbrev company-dabbrev))))
(add-hook 'emacs-lisp-mode-hook (lambda ()
(add-to-list (make-local-variable 'company-backends)
'(company-elisp))))
;;
;; change C-n C-p
;;
(with-eval-after-load 'company
(define-key company-active-map (kbd "\C-n") #'company-select-next)
(define-key company-active-map (kbd "\C-p") #'company-select-previous)
(define-key company-active-map (kbd "M-n") nil)
(define-key company-active-map (kbd "M-p") nil))
;;
;; change company complete common
;;
;; With this code, yasnippet will expand the snippet if company didn't complete the word
;; replace company-complete-common with company-complete if you're using it
;;
(advice-add 'company-complete-common :before (lambda () (setq my-company-point (point))))
(advice-add 'company-complete-common :after (lambda () (when (equal my-company-point (point))
(yas-expand))))
;;
;; flycheck
;;
(use-package flycheck
:ensure t
:config
(global-flycheck-mode t)
)
;;
;; magit
;;
(use-package magit
:ensure t
:bind (("\C-x g" . magit-status))
)
;;
;; projectile
;;
(use-package projectile
:ensure t
:bind-keymap
("\C-c p" . projectile-command-map)
:config
(projectile-mode t)
(setq projectile-completion-system 'ivy)
(use-package counsel-projectile
:ensure t)
)
(use-package ag
:ensure t)
;;
;; auto insert
;;
(defun my/autoinsert-yas-expand()
"replace text in yasnippet template"
(yas-expand-snippet (buffer-string) (point-min) (point-max)))
(use-package autoinsert
:ensure t
:config
(setq auto-insert-query nil)
(setq auto-insert-directory (locate-user-emacs-file "templates"))
(add-hook 'find-file-hook 'auto-insert)
(auto-insert-mode t)
(define-auto-insert "\\.org$" ["default-org.org" my/autoinsert-yas-expand])
(define-auto-insert "\\.js$" ["default-js.js" my/autoinsert-yas-expand])
(define-auto-insert "\\.ts$" ["default-ts.ts" my/autoinsert-yas-expand])
(define-auto-insert "\\.html?$" ["default-html.html" my/autoinsert-yas-expand])
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; c/c++ ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/c.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; python ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/python.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; web ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/web.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; go ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/go.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ruby ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/ruby.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; org ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/org.el")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; csharp ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "~/.emacs.d/custom/csharp.el")
(provide 'init)
;;; init.el ends here