-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
516 lines (447 loc) · 14.1 KB
/
init.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
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
;; Turn off mouse interface early in startup to avoid momentary display
;; You really don't need these; trust me.
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(setq use-package-verbose t)
;; Load path etc.
(add-to-list 'load-path "~/.emacs.d/lib")
(add-to-list 'load-path "~/.emacs.d/lib/use-package")
(add-to-list 'load-path "/usr/local/mu-git/share/emacs/site-lisp/mu4e")
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
'("elpy" . "https://jorgenschaefer.github.io/packages/"))
;; Init the package load path etc
(package-initialize)
(require 'use-package)
;; Always download packages if not present
(setq use-package-always-ensure t)
;; Save current place in file
(use-package saveplace
:defer t
:init
(setq save-place t)
(setq save-place-file "~/.emacs.d/saved-places")
)
;; Enable URLs in open file
(use-package ffap
:defer t)
;; Better unique names rather then file<1> file<2>
;;; FIXME not working ?
;;(use-package uniquify)
;; Support shell color codes
(use-package ansi-color
:defer t)
(use-package diff-mode
:mode "COMMIT_EDITMSG$"
:config
(set-face-foreground 'diff-added "green4")
(set-face-background 'diff-added "black")
(set-face-foreground 'diff-removed "red3")
(set-face-background 'diff-removed "black")
)
(use-package cc-mode
:defer t
:bind ("C-c o" . ff-find-other-file)
:bind (
(:map c-mode-map
("M-RET" . srefactor-refactor-at-point))
(:map c++-mode-map
("M-RET" . srefactor-refactor-at-point)))
:config
(add-hook 'c-mode-common-hook 'helm-gtags-mode)
(add-hook 'c-mode-common-hook 'company-mode)
(add-hook 'c-mode-common-hook
(function (lambda ()
(whitespace-mode t))))
;; For gdb style based on gnu ident case in switch statements
;; may not be really needed
;;(c-set-offset 'case-label '+)
;; long functions with (
;; arg);
; (c-set-offset 'arglist-intro '+)
)
(use-package semantic
:defer t
:config
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(global-semantic-stickyfunc-mode 1)
)
(use-package srefactor
:ensure t
:defer t
:config
(semantic-mode 1)
)
; apt-get install clang cppcheck
(use-package flycheck
:ensure t
:init (global-flycheck-mode)
:config
;; Disabling cppcheck as it can cause hudge memory usage if
;; not called with -UIN_PROCESS_AGENT
;; Prefer gcc to clang
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck))
(let ((default-directory "~/src/binutils-gdb"))
(setq flycheck-gcc-include-path (list
(expand-file-name ".")
(expand-file-name "gdb")
(expand-file-name "gdb/gdbserver")
(expand-file-name "build-x86/bfd")
(expand-file-name "build-x86/gdb")
(expand-file-name "build-x86/gdb/gdbserver/build-gnulib-gdbserver/import")
(expand-file-name "gdb/common")
(expand-file-name "gdb/config")
(expand-file-name "bfd")
(expand-file-name "include")
(expand-file-name "libdecnumber")
(expand-file-name "gdb/gnulib/import")
(expand-file-name "-I/usr/include/guile/2.0")
(expand-file-name "-I/usr/include/python/2.7")
)))
(setq-default flycheck-gcc-language-standard "gnu++11")
)
(use-package ecb
:defer t
:init
(semantic-mode 1)
(setq stack-trace-on-error t)
)
(use-package compile-dir
:ensure f
:bind ("<f7>" . gdb-compile)
)
(use-package bm
:bind (("<f8>" . bm-toggle)
("<f9>" . bm-previous)
("<f10>" . bm-next))
)
;;Save desktop mode auto save on idle
(use-package desktop
:defer t
:init
(desktop-save-mode 1)
:config
(defun my-desktop-save ()
(interactive)
;; Don't call desktop-save-in-desktop-dir, as it prints a message.
(if (eq (desktop-owner) (emacs-pid))
(desktop-save desktop-dirname)))
(add-hook 'auto-save-hook 'my-desktop-save))
(use-package helm-config
:ensure f
:defer t)
(use-package helm-gtags
:defer t
:init
(setq
helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t
helm-gtags-prefix-key "\C-cg"
helm-gtags-suggested-key-mapping t)
:config
(bind-key "C-c g a" 'helm-gtags-tags-in-this-function helm-gtags-mode-map)
(bind-key "C-j" 'helm-gtags-select helm-gtags-mode-map)
(bind-key "M-." 'helm-gtags-dwim helm-gtags-mode-map)
(bind-key "M-," 'helm-gtags-pop-stack helm-gtags-mode-map)
(bind-key "C-c <" 'helm-gtags-previous-history helm-gtags-mode-map)
(bind-key "C-c >" 'helm-gtags-next-history helm-gtags-mode-map)
)
(use-package helm-ack
:defer t
:init
(setq helm-semantic-fuzzy-match t
helm-imenu-fuzzy-match t
helm-ack-use-ack-grep t
helm-ack-version 1.92)
:bind (("C-x c C-o" . helm-occur)
("C-x c C-a" . helm-ack))
:config
(when (executable-find "ack-grep")
(setq helm-grep-default-command "ack-grep -Hn --no-group --no-color %e %p %f"
helm-grep-default-recurse-command "ack-grep -H --no-group --no-color %e %p %f")))
(use-package helm-descbinds
:defer t
:ensure t
:bind (("C-h b" . helm-descbinds)
("C-h w" . helm-descbinds)))
;; Set colors for company below
(use-package color)
;; Auto Completion
;; Fixme TAB not working properly
;; FIXME colors not working ?
(use-package company
:ensure t
:init
(defvar company-key-map (make-sparse-keymap))
:config
(defun complete-or-indent ()
(interactive)
(if (company-manual-begin)
(company-complete-common)
(indent-according-to-mode)))
; (bind-key "\t" 'complete-or-indent company-key-map)
)
(use-package whitespace
:defer t
:init
(setq-default whitespace-style '(face trailing lines empty))
(setq-default whitespace-line-column 80)
(defun switch-whitespace-max-line (max)
(progn
(whitespace-mode)
(setq-default whitespace-line-column max)
(whitespace-mode)))
(defun switch-whitespace-max-line-i (max)
(interactive "nMax column for lines: ")
(switch-whitespace-max-line max)
)
:bind (("C-c w" . whitespace-mode)
("C-c t" . whitespace-toggle-options)
("C-c m" . switch-whitespace-max-line-i))
)
;; Stacked git
(use-package stgit)
;; Git
(use-package magit
:defer t)
(use-package doremi-cmd
:defer t)
(use-package org-mode
:ensure f
:init
(setq org-directory "~/notes/org")
(setq org-default-notes-file (concat org-directory "/notes/notes.org"))
(setq org-refile-targets '(("notes.org" :maxlevel . 6)))
(setq org-completion-use-ido t)
;;https://lists.gnu.org/archive/html/emacs-orgmode/2008-05/msg00039.html
(defun my-link-to-line-number-in-c-mode ()
"When in c-mode, use line number as search item."
(when (eq major-mode 'c-mode)
(number-to-string (org-current-line))))
(add-hook 'org-create-file-search-functions
'my-link-to-line-number-in-c-mode)
(setq org-capture-templates
'(("c" "Code" entry (file+headline "~/notes/notes.org" "Scratch")
"** Snippet\n %i\n%a")))
(add-hook 'org-mode-hook 'flyspell-mode)
:bind ("C-c c" . org-capture)
)
(eval-after-load "ox-html"
;; Pretty print code blocks
'(defun org-html-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(if (org-export-read-attribute :attr_html src-block :textarea)
(org-html--textarea-block src-block)
(let ((lang (org-element-property :language src-block))
(caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info))
(label (let ((lbl (org-element-property :name src-block)))
(if (not lbl) ""
(format " id=\"%s\""
(org-export-solidify-link-text lbl))))))
(if (not lang) (format "<pre class=\"prettyprint\"%s>\n%s</pre>" label code)
(format
"<div class=\"org-src-container\">\n%s%s\n</div>"
(if (not caption) ""
(format "<label class=\"org-src-name\">%s</label>"
(org-export-data caption info)))
(format "\n<pre class=\"prettyprint lang-%s\"%s>%s</pre>" lang label code)))))))
(use-package smart-mode-line
:ensure t
:defer t)
(use-package w3m
:ensure t
:defer t)
(require 'mu4e)
(require 'org-mu4e)
(require 'mu4e-my-actions)
(require 'mu4e-contrib)
(use-package clojure-mode
:ensure t
:defer t
:config
(setq nrepl-popup-stacktraces nil)
(add-to-list 'same-window-buffer-names "<em>nrepl</em>")
(add-hook 'clojure-mode-hook 'auto-complete-mode)
(add-hook 'clojure-mode-hook 'paredit-mode)
(add-hook 'clojure-mode-hook 'rainbow-delimiters-mode)
)
(use-package ac-cider
:ensure t
:config
(add-hook 'cider-mode-hook 'ac-flyspell-workaround)
(add-hook 'cider-mode-hook 'ac-cider-setup)
(add-hook 'cider-repl-mode-hook 'ac-cider-setup)
)
(use-package auto-complete
:ensure t
:config
(setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(add-hook 'auto-complete-mode-hook 'ac-common-setup)
(setq ac-delay 0.2)
(setq ac-quick-help-delay 1)
(add-to-list 'ac-modes 'cider-mode)
(add-to-list 'ac-modes 'cider-repl-mode)
(setq global-auto-complete-mode nil)
(defun set-auto-complete-as-completion-at-point-function ()
(setq completion-at-point-functions '(auto-complete)))
(add-hook 'auto-complete-mode-hook 'set-auto-complete-as-completion-at-point-function)
)
(use-package paredit
:ensure t
:defer t)
(use-package rainbow-delimiters
:ensure t
:defer f
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
)
(use-package rainbow-mode
:ensure t
)
(use-package cider
:ensure t
:config
(add-hook 'cider-mode-hook 'set-auto-complete-as-completion-at-point-function)
(add-hook 'cider-mode-hook 'eldoc-mode)
(add-hook 'cider-repl-mode-hook 'eldoc-mode)
)
(use-package popup
:ensure t
:defer t)
(use-package org2blog
:ensure t
:defer t
:config
(setq org2blog/wp-blog-alist
'(("hexa-blog"
:url "https://www.kayaksoft.com/blog/xmlrpc.php"
:username "hexa"
:default-title "Title"
:tags-as-categories nil
)))
)
;;; Python dev
(use-package python-mode
:defer t
:config
(add-hook 'c-mode-common-hook 'helm-gtags-mode)
(setq jedi:complete-on-dot t) ; optional
;; For gdb style based on gnu ident case in switch statements
;; may not be really needed
;;(c-set-offset 'case-label '+)
)
(use-package jedi
:ensure t)
;(use-package elpy
; :ensure t
; :config
; (setq python-shell-interpreter "python3")
; (setq elpy-rpc-python-command "python3")
; (setq elpy-interactive-python-command "ipython3")
; (elpy-use-ipython "ipython3")
; (elpy-enable))
(use-package which-key
:ensure t
:config
(which-key-setup-side-window-right-bottom)
(which-key-mode)
)
(use-package flyspell
:ensure t)
;; apt-get install recordmydesktop mplayer imagemagick
;; Record an emacs screencast
(use-package camcorder
:ensure t)
;(require 'cool-mode)
;;https://github.com/politza/pdf-tools
;;apt-get install libpng-dev libz-dev libpoppler-glib-dev libpoppler-private-dev imagemagick
(use-package pdf-tools
:ensure t
:config
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))
(pdf-tools-install)
)
(use-package interleave)
(use-package jsx-mode
:ensure t)
;; https://github.com/ananthakumaran/tide
;; npm install -g typescript tslint
(use-package tide
:ensure t
:config
(defun setup-tide-mode ()
(interactive)
(tide-setup)
;; (setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))
(setq tide-format-options '(:insertSpaceAfterFunctionKeywordForAnonymousFunctions t))
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(flycheck-add-next-checker 'typescript-tide '(t . typescript-tslint) 'append)
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1)
;; indent on tab with tide-format
(local-set-key (kbd "TAB") 'tide-format)
(local-set-key (kbd "M-'") 'tide-jump-to-definition)
(local-set-key (kbd "M-]") 'tide-jump-to-implementation)
(local-set-key (kbd "M-;") 'tide-jump-back)
)
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(add-hook 'js2-mode-hook #'setup-tide-mode)
(add-hook 'typescript-mode-hook 'helm-gtags-mode)
)
;; npm install -g tsun
(use-package ts-comint
:ensure t
:config
(add-hook 'typescript-mode-hook
(lambda ()
(local-set-key (kbd "C-x C-e") 'ts-send-last-sexp)
(local-set-key (kbd "C-M-x") 'ts-send-last-sexp-and-go)
(local-set-key (kbd "C-c b") 'ts-send-buffer)
(local-set-key (kbd "C-c C-b") 'ts-send-buffer-and-go)
(local-set-key (kbd "C-c l") 'ts-load-file-and-go)))
)
;;apt-get install multimarkdown
(use-package markdown-mode
:ensure t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . gfm-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "marked"))
(require 'epa-file)
(epa-file-enable)
(use-package work
:ensure f)
(use-package custom-defs
:ensure f)
(use-package custom-lib
:ensure f)
(load-theme 'manoj-dark-mod t)
;; Company mode custom faces
;; FIXME
;; Somehow this can't go in :config
;; Warning : Error (use-package): company :config: Wrong number of arguments: (3 . 3), 0
(let ((bg (face-attribute 'default :background)))
(custom-set-faces
`(company-tooltip ((t (:inherit default :background ,(color-lighten-name bg 2)))))
`(company-scrollbar-bg ((t (:background ,(color-lighten-name bg 10)))))
`(company-scrollbar-fg ((t (:background ,(color-lighten-name bg 5)))))
`(company-tooltip-selection ((t (:inherit font-lock-function-name-face))))
`(company-tooltip-common ((t (:inherit font-lock-constant-face))))))