summaryrefslogtreecommitdiff
path: root/lisp/cpp.el
blob: 3565a16f439f32d9e0f63ebfbac85f11c79f3d90 (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

;;; Code:
(defun setup-c()
  "Set up c common mode."
  (setq c++-tab-always-indent 0)
  (setq c-basic-offset 4)                  ;; Default is 2
  (setq c-indent-level 4)                  ;; Default is 2
  (c-set-offset 'brace-list-open 0)

  (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
  (setq tab-width 4)
  ;; (electric-indent-mode 0)
  )

;; Irony mode.
(use-package irony
  :ensure t
  :defer t
  :init
  (add-hook 'c++-mode-hook 'irony-mode)
  (add-hook 'c-mode-hook 'irony-mode)
  (add-hook 'objc-mode-hook 'irony-mode)
  :config
  ;; 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)
  )

(require 'cmake-ide)
(cmake-ide-setup)

(add-hook 'c-mode-common-hook 'setup-c)

(provide 'cpp)
;;; cpp.el ends here