blob: a4d67fda8cca6621542e14921f487448aa9dd789 (
plain)
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
|
#+STARTUP: overview
* Packaging setup
** Melpa
#+begin_src emacs-lisp
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
#+end_src
** use-package
#+begin_src emacs-lisp
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
#+end_src
* Appearence
** Theme
#+begin_src emacs-lisp
(use-package afternoon-theme
:ensure t
:config
(load-theme 'afternoon t))
#+end_src
** Font and Cursor
#+begin_src emacs-lisp
(blink-cursor-mode 0)
(set-cursor-color "#ff9000")
(when (member "Hack Nerd Font Mono" (font-family-list))
(set-frame-font "Hack Nerd Font Mono-10" t t))
#+end_src
** Disable Oppacaty
#+begin_src emacs-lisp
(add-to-list 'default-frame-alist '(alpha 100))
#+end_src
** Dashboard
#+begin_src emacs-lisp
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-items '((recents . 3)
(bookmarks . 2)))
(setq dashboard-startup-banner "~/.config/emacs/avatar.png")
(setq dashboard-banner-logo-title "\"Pretty much everything on the web uses those two things: C and UNIX.\"")
(setq dashboard-center-content t)
(setq dashboard-set-init-info nil)
(setq dashboard-set-footer nil)
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))
#+end_src
** Modeline
*** Line Theme
#+begin_src emacs-lisp
(use-package doom-modeline
:ensure t
:init
(setq doom-modeline-unicode-fallback t)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-buffer-file-name-style 'relative-to-project)
;; truncate-nil to change buffer file name to full path
;;(setq doom-modeline-lsp t)
(doom-modeline-mode 1))
;; M-x all-the-icons-install-fonts - to manually install the icons necessary
(use-package all-the-icons
:ensure t)
#+end_src
*** Diminish
#+begin_src emacs-lisp
(use-package diminish
:ensure t
:init
(diminish 'which-key-mode)
(diminish 'subword-mode))
#+end_src
* Basic behaviour settings
#+begin_src emacs-lisp
(defalias 'yes-or-no-p 'y-or-n-p)
(setq ring-bell-function 'ignore)
(setq auto-save-default nil)
(setq create-lockfiles nil)
(setq make-backup-files nil)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq bookmark-set-fringe-mark nil)
(setq scroll-conservatively 10)
(setq scroll-margin 7)
(use-package transpose-frame
:ensure t)
#+end_src
* Text editing
** General
#+begin_src emacs-lisp
(electric-pair-mode 1)
(setq electric-pair-pairs
'(
(?\" . ?\")
(?\{ . ?\})))
(global-subword-mode 1)
;; Make sure tab-width is 4 and not 8
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-default 'truncate-lines t)
;;Line numbers
(global-display-line-numbers-mode)
#+end_src
** Hans VIMmer
#+begin_src emacs-lisp
(use-package evil
:ensure t
:config
(evil-set-undo-system 'undo-redo)
:init
(setq evil-want-keybinding nil)
(evil-mode 1))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init '(dashboard dired bookmark
org-present org magit company ggtags doc-view)))
(use-package key-chord
:ensure t
:config
;; Max time delay between two key presses to be considered a key chord
(setq key-chord-one-key-delay .5)
(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
:init
(key-chord-mode 1))
#+end_src
* Org mode
** Bullets
#+begin_src emacs-lisp
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
#+end_src
* LaTeX
** Basic conf
#+begin_src emacs-lisp
(use-package auctex
:ensure t
:defer t
:hook (LaTeX-mode .
(lambda ()
(push (list 'output-pdf "Zathura")
TeX-view-program-selection))))
#+end_src
** DocView autoRevert
#+begin_src emacs-lisp
(add-hook 'doc-view-mode-hook 'auto-revert-mode)
#+end_src
* IDE
** Overall
*** Projectile
#+begin_src emacs-lisp
(use-package projectile
:ensure t
:diminish projectile-mode
:bind-keymap
("C-c p" . projectile-command-map)
:init
(setq projectile-project-p "~/code")
(projectile-mode 1))
#+end_src
*** Company
#+begin_src emacs-lisp
(use-package company
:ensure t
:config
(setq company-idle-delay 0)
(setq company-minimum-prefix-lenght 3))
;; Global mode currently off
(use-package company-irony
:ensure t
:config
(add-to-list 'company-backends 'company-irony))
(use-package irony
:ensure t
:config
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options))
;; Because company-global is not true atm
(with-eval-after-load 'company
(add-hook 'c-mode-hook 'company-mode)
(add-hook 'c++-mode-hook 'company-mode))
#+end_src
#+RESULTS:
: t
*** Magit
#+begin_src emacs-lisp
(use-package magit
:ensure t
:config
(setq magit-push-always-verify nil)
(setq git-commit-summary-max-length 50)
:bind
("M-g" . magit-status))
#+end_src
*** FlyCheck
#+begin_src emacs-lisp
(use-package flycheck
:ensure t
:init
(global-flycheck-mode t))
#+end_src
*** YaSnippets
https://github.com/AndreaCrotti/yasnippet-snippets/tree/master/snippets
#+begin_src emacs-lisp
(use-package yasnippet-snippets
:ensure t
:hook ((prog-mode
conf-mode
snippet-mode) . yas-minor-mode-on))
#+end_src
*** Treemacs
#+begin_src emacs-lisp
(use-package treemacs
:ensure t)
#+end_src
*** AG
#+begin_src emacs-lisp
(use-package ag
:ensure t)
(setq ag-highlight-search t)
(setq ag-reuse-buffers 't)
#+end_src
** Lang Specific
*** HTML & CSS
#+begin_src emacs-lisp
(use-package emmet-mode
:ensure t
:init
(add-hook 'sgml-mode-hook 'emmet-mode)
(add-hook 'css-mode-hook 'emmet-mode))
#+end_src
*** C/C++
**** Tags
#+begin_src emacs-lisp
;; install package global on machine
(use-package ggtags
:ensure t
:config
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode)
(ggtags-mode 1)))))
#+end_src
**** Tabs
#+begin_src emacs-lisp
(setq-default c-basic-offset 4)
#+end_src
* Useful Functions
** Kill word
#+begin_src emacs-lisp
(defun killWholeWord ()
(interactive)
(backward-word)
(kill-word 1))
(global-set-key (kbd "C-c w") 'killWholeWord)
#+end_src
** Copy Line
#+begin_src emacs-lisp
;; (defun copyWholeLine ()
;; (interactive)
;; (save-excursion
;; (kill-new
;; (buffer-substring
;; (point-at-bol)
;; (point-at-eol)))))
;; (global-set-key (kbd "C-c l") 'copyWholeLine)
#+end_src
** Follow Buffer
#+begin_src emacs-lisp
(defun splitFollowHorizontal ()
(interactive)
(split-window-below)
(balance-windows)
(other-window 1))
(global-set-key (kbd "C-x 2") 'splitFollowHorizontal)
(defun splitFollowVertical ()
(interactive)
(split-window-right)
(balance-windows)
(other-window 1))
(global-set-key (kbd "C-x 3") 'splitFollowVertical)
#+end_src
** Refresh buffer
#+begin_src emacs-lisp
;; (defun revert-buffer-no-confirm ()
;; "Revert buffer without confirmation."
;; (interactive)
;; (revert-buffer :ignore-auto :noconfirm))
;; (global-set-key (kbd "<f5>") 'revert-buffer-no-confirm)
#+end_src
* Other
** WhichKey
#+begin_src emacs-lisp
(use-package which-key
:ensure t
:init
(which-key-mode))
#+end_src
** Default Kill Buffer
#+begin_src emacs-lisp
(defun killCurBuffer ()
(interactive)
(kill-buffer (current-buffer)))
(global-set-key (kbd "C-x k") 'killCurBuffer)
#+end_src
** Better BottomMenu
*** IDO
#+begin_src emacs-lisp
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(use-package ido-vertical-mode
:ensure t
:init
(ido-vertical-mode 1))
(setq ido-vertical-define-keys 'C-n-and-C-p-only)
#+end_src
*** Smex
#+begin_src emacs-lisp
(use-package smex
:ensure t
:init (smex-initialize)
:bind
("M-x" . smex))
#+end_src
** Swiper
#+begin_src emacs-lisp
(use-package swiper
:ensure t
:bind ("C-s" . 'swiper))
#+end_src
* Notes
** C-programming paths
For flycheck path add, do this in the /myproject/.dir-locals.el
# ((c-mode . ((eval . (setq flycheck-clang-include-path
# (list (expand-file-name "~/myproject/include/")))))))
And if needed path export for clan
# ((c-mode . ((company-clang-arguments . (list ("-I/your/absolute/paths/here/"))))))
|