-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit-c.el
66 lines (55 loc) · 3.44 KB
/
init-c.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
;; completion and navigation using gtags
;; to use, run gtags in root dir of the project (or use any ggtags cmd in emacs to be prompted)
;; most important:
;; - start typing for completion, M-n and M-p to choose next/prev candidate, RET to confirm
;; while completing, C-s to search or M-o for helm fuzzy search
;; - jump to definition using C-c C-t C-j
;; if multiple matches, navigate to next/prev with C-x n and C-x p
;; - jump back to where you came from with C-c C-t C-m
;; - same goes for finding references with C-c C-t C-r
(add-hook 'c++-mode-hook (lambda () (ggtags-mode)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-j") 'ggtags-find-definition)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-r") 'ggtags-find-reference)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-s") 'ggtags-grep)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-m") 'ggtags-prev-mark)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-n") 'ggtags-next-mark)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-p") 'ggtags-prev-mark)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-d") 'ggtags-show-definition)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-o") 'ggtags-find-other-symbol)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-u") 'ggtags-update-tags)))
(add-hook 'c++-mode-hook (lambda () (company-mode)))
(add-hook 'c++-mode-hook (lambda () (local-set-key (kbd "M-o") 'company-gtags)))
(add-hook 'c-mode-hook (lambda () (ggtags-mode)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-j") 'ggtags-find-definition)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-r") 'ggtags-find-reference)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-s") 'ggtags-grep)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-m") 'ggtags-prev-mark)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-n") 'ggtags-next-mark)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-p") 'ggtags-prev-mark)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-d") 'ggtags-show-definition)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-o") 'ggtags-find-other-symbol)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "C-c C-t C-u") 'ggtags-update-tags)))
(add-hook 'c-mode-hook (lambda () (company-mode)))
(add-hook 'c-mode-hook (lambda () (local-set-key (kbd "M-o") 'company-gtags)))
;; (remove-hook 'c-mode-hook (lambda () (c-toggle-comment-style -1)))
; testing out company completion...
;; (add-hook 'c-mode-hook (lambda () (local-set-key (kbd "M-o") 'ac-complete-with-helm)))
;; (add-hook 'c-mode-hook (lambda () (auto-complete-mode)))
;; (add-hook 'c-mode-hook (lambda () (setq ac-use-menu-map t)))
;; (ac-config-default)
;; testing out eldoc mode - not yet added to init-packages
(add-hook 'c-mode-hook 'c-turn-on-eldoc-mode)
;; do indent after newline
(add-hook 'c-mode-common-hook (lambda () (electric-indent-mode -1)))
;; gomspace c style
(load "~/.emacs.d/lib/google-c-style.el")
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook (lambda () (setq fill-column 120)))
(defun gs-old-indent-mode ()
"Switch to old GomSpace indent mode: 8-space tabs"
(interactive)
(setq c-basic-offset 8)
(setq indent-tabs-mode t)
(setq tab-width 8)
(c-set-offset 'case-label nil)
)