-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·288 lines (251 loc) · 8.64 KB
/
setup.sh
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
sudo apt install emacs
sudo apt install clang-format
cat > ~/.clang-format <<EOF
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 90
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.hp?p?>'
Priority: 2
- Regex: '^<.*\.hp?p?>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: Never
EOF
# create .emacs and add initial
cat > ~/.emacs <<EOF
;;; package --- Summary
;;; Commentary:
;;; Code:
(package-initialize)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) ; Org-mode's repository
(package-initialize)
(package-refresh-contents)
EOF
# all package you need
cat > package-list <<EOF
(package-install 'clang-format)
(package-install 'company-c-headers)
(package-install 'company-rtags)
(package-install 'company)
(package-install 'flycheck-clang-analyzer)
(package-install 'flycheck-clang-tidy)
(package-install 'flycheck-popup-tip)
(package-install 'ggtags)
(package-install 'popup-kill-ring)
EOF
# install package
echo "y" | emacs --batch -u `whoami` --script package-list
rm package-list
# modify .emacs
cat > ~/.emacs <<EOF
;;; package --- Summary
;;; Commentary:
;;; Code:
(package-initialize)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) ; Org-mode's repository
;; Uncomment this next line if you want line numbers on the left side
(global-linum-mode 1)
;; Sets our compilation key binding to C-c C-v
(global-set-key "\C-c\C-v" 'compile)
(setq line-number-mode t)
(setq column-number-mode t)
(display-time)
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
;;Want electric pair mode? Uncomment the next line
;(electric-pair-mode)
;;Want to turn off show paren mode? Comment out the below line.
(show-paren-mode)
(global-set-key "\C-x\C-g" 'goto-line)
;; Automatically set compilation mode to
;; move to an error when you move the point over it
;; Dont want this behavior? commend out the next 4 lines.
(add-hook 'compilation-mode-hook
(lambda ()
(progn
(next-error-follow-minor-mode))))
;;Automatically go to the first error
;;Dont want this behavior? comment out next line
(setq compilation-auto-jump-to-first-error t)
;;This prevents gdb from getting a dedicated window,
;;which is generally super annoying
(defun set-window-undedicated-p (window flag)
"Never set window dedicated."
flag)
(advice-add 'set-window-dedicated-p :override #'set-window-undedicated-p)
;;Autocompletion from company
(require 'company)
(require 'company-rtags)
;; This turns on autocomplete globally. Want to turn it off (why???) comment out next line.
(global-company-mode)
(add-to-list 'company-backends 'company-c-headers)
;;clang-format to format file reasonably. Do NOT turn off!
(require 'clang-format)
(global-set-key [C-M-tab] 'clang-format-region)
(add-hook 'c-mode-common-hook
(function (lambda ()
(add-hook 'write-contents-functions
(lambda() (progn (clang-format-buffer) nil))))))
(add-hook 'cpp-mode-common-hook
(function (lambda ()
(add-hook 'write-contents-functions
(lambda() (progn (clang-format-buffer) nil))))))
;; Flycheck: show you whats wrong while you write
;; Dont want? comment out next 3 lines.
;; Dont want popups with whats wrong? comment out third line only
(require 'flycheck)
(global-flycheck-mode)
(flycheck-popup-tip-mode)
;; This does the popup menu for M-y.
;; if you dont want it, you can comment out the next 12 lines.
(require 'popup-kill-ring)
(defun drew-popup-kill-ring(&optional arg)
(interactive "*p")
(if (eq last-command 'yank)
(let ((inhibit-read-only t)
(before (< (point) (mark t))))
(if before
(funcall (or yank-undo-function 'delete-region) (point) (mark t))
(funcall (or yank-undo-function 'delete-region) (mark t) (point)))))
(popup-kill-ring))
(global-set-key "\M-y" 'drew-popup-kill-ring)
(setq popup-kill-ring-interactive-insert t)
;;This just shows your grade.txt files in color and read only.
(defun colorize-grade-txt ()
"Make a grade.txt file show colors, then set read only."
(interactive)
(if (or (string= (buffer-name) "grade.txt")
(string-prefix-p (buffer-name) "grade.txt<"))
(progn (let ((inhibit-read-only t))
(ansi-color-apply-on-region (point-min) (point-max)))
(set-buffer-modified-p nil)
(read-only-mode t))))
(add-hook 'find-file-hook 'colorize-grade-txt)
;;company mode doesnt play well with gdb mode. Leave this here
(add-hook 'gud-mode-hook (lambda() (company-mode 0)))
(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.
'(package-selected-packages
(quote
(ac-html py-yapf elpy s pyvenv highlight-indentation find-file-in-project verilog-mode popup-kill-ring ggtags flycheck-popup-tip flycheck-clang-tidy flycheck-clang-analyzer company-rtags company-c-headers clang-format))))
(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.
)
(provide '.emacs)
;;; .emacs ends here
EOF