-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
120 lines (100 loc) · 3.6 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
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/")
t)
;;(require 'company-irony-c-headers)
;; =============
;; irony-mode
;; =============
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
;; =============
;; company mode
;; =============
(add-hook 'c++-mode-hook 'company-mode)
(add-hook 'c-mode-hook 'company-mode)
;; Replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
(define-key irony-mode-map [remap completion-at-point]
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(eval-after-load 'company
'(add-to-list 'company-backends 'company-irony 'company-c-headers))
;; (optional) adds CC special commands to `company-begin-commands' in order to
;; trigger completion at interesting places, such as after scope operator
;; std::|
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
;; =============
;; flycheck-mode
;; =============
(add-hook 'c++-mode-hook 'flycheck-mode)
(add-hook 'c-mode-hook 'flycheck-mode)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
;; =============
;; eldoc-mode
;; =============
(add-hook 'irony-mode-hook 'irony-eldoc)
;; ==========================================
;; (optional) bind TAB for indent-or-complete
;; ==========================================
(defun irony--check-expansion ()
(save-excursion
(if (looking-at "\\_>") t
(backward-char 1)
(if (looking-at "\\.") t
(backward-char 1)
(if (looking-at "->") t nil)))))
(defun irony--indent-or-complete ()
"Indent or Complete"
(interactive)
(cond ((and (not (use-region-p))
(irony--check-expansion))
(message "complete")
(company-complete-common))
(t
(message "indent")
(call-interactively 'c-indent-line-or-region))))
(defun irony-mode-keys ()
"Modify keymaps used by `irony-mode'."
(local-set-key (kbd "TAB") 'irony--indent-or-complete)
(local-set-key [tab] 'irony--indent-or-complete))
(add-hook 'c-mode-common-hook 'irony-mode-keys)
(setq irony-additional-clang-options '("-std=c++11"))
(load-theme 'wombat t)
;; Split window bindings
(global-set-key (kbd "C-)") 'delete-other-windows)
(global-set-key (kbd "C-(") 'delete-other-windows)
(global-set-key (kbd "C-*") 'delete-window)
(global-set-key (kbd "C-0") 'split-window-right)
(global-set-key (kbd "C-9") 'split-window-below)
(global-set-key (kbd "C-}") 'enlarge-window-horizontally)
(global-set-key (kbd "C-{") 'shrink-window-horizontally)
(global-set-key (kbd "C-&") 'enlarge-window)
(global-set-key (kbd "C-^") 'shrink-window)
(global-set-key (kbd "<f8>") 'execute-extended-command)
(global-set-key (kbd "C-'") 'other-window)
(global-set-key (kbd "C-c l") 'windmove-right)
(global-set-key (kbd "C-c k") 'windmove-down)
(global-set-key (kbd "C-c j") 'windmove-left)
(global-set-key (kbd "C-c i") 'windmove-up)
(defalias 'list-buffers 'ibuffer)
(electric-pair-mode 1)
(setq electric-pair-pairs '(
(?\" . ?\")
(?\{ . ?\})
))
;(shown-paren-mode 1) ;; parentheses are highlighted
(column-number-mode 1) ;; shows (row, col) for cursor
;(set make-backup-file nil) ;; don't make backup file
;; enable to open recent files. Good for projects
(recentf-mode 1) ;;
(global-set-key (kbd "C-c C-o") 'recentf-open-files)
;; must install tabbar for this
;;(tabbar-mode t)
;; highlight cursor line
;;(global-hl-line-mode nil)