blob: eb7660e9302a769415b1bfb33fca87c23207b55d (
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
|
;;; 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
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
(setq tab-width 4)
(c-set-offset 'brace-list-open 0)
(c-set-offset 'substatement-open 0)
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-cont-non-empty '+)
(c-set-offset 'argslist-close '+)
(c-set-offset 'statement-cont 0)
)
(add-hook 'c-mode-common-hook 'setup-c)
(defun mk/cpp/generate-compile-commands-cmake()
"Regenerates a compile_commands.json database"
(interactive)
(shell-command (format "cd %s && cmake -S . -B build -D CMAKE_EXPORT_COMPILE_COMMANDS=1" (projectile-project-root)))
)
(defun maybe-regenerate-compile-commands()
(if (string= (buffer-file-name) "CMakeLists.txt")
(mk/cpp/generate-compile-commands-cmake)))
(add-hook 'after-save-hook 'maybe-regenerate-compile-commands)
(provide 'cpp)
;;; cpp.el ends here
|