From b1f9683d27bcb046859605fe11cfe5d34644c4a1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 9 Oct 2014 18:35:44 -0400 Subject: [PATCH] Improve C++11 support --- init/init-cpp.el | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/init/init-cpp.el b/init/init-cpp.el index 888fab169..96d9288b4 100644 --- a/init/init-cpp.el +++ b/init/init-cpp.el @@ -4,14 +4,36 @@ c-default-style "linux" c-tab-always-indent nil) +;; Setting proper includes on OSX +(when is-mac + (setq my/clang-includes + '("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1" + "/usr/local/include" + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include" + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include" + "/usr/include" + "/System/Library/Frameworks" + "/Library/Frameworks")) + + (after flycheck (setq flycheck-clang-include-path my/clang-includes)) + (after auto-complete + (setq ac-clang-flags (mapcar (lambda (item)(concat "-I" item)) my/clang-includes))) + ) + (add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode)) (add-hook! 'c-mode-common-hook (use-package auto-complete-clang) (use-package auto-complete-c-headers) + (setq ac-sources + '(ac-source-clang + ac-source-c-headers + ac-source-yasnippet + ac-source-words-in-same-mode-buffers)) (c-toggle-electric-state -1) (c-toggle-auto-newline -1) + ;; DEL mapping interferes with smartparens and my.deflate-maybe (defmap c-mode-map (kbd "DEL") nil) (c-set-offset 'substatement-open '0) ; brackets should be at same indentation level as the statements they open @@ -20,14 +42,13 @@ (c-set-offset 'brace-list-open '+) ; all "opens" should be indented by the c-indent-level (c-set-offset 'case-label '+) ; indent case labels by c-indent-level, too - (setq ac-sources - '(ac-source-clang - ac-source-c-headers - ac-source-yasnippet - ac-source-words-in-same-mode-buffers - ))) + ;; C++11 support on mac + (when (and is-mac (eq major-mode 'c++-mode)) + (setq flycheck-clang-language-standard "c++11" + flycheck-clang-standard-library "libc++" + flycheck-c/c++-clang-executable "clang++"))) -;; Implement some C++11 Support until cc-mode is updated +;; C++11 syntax support (until cc-mode is updated) (require 'font-lock) (defun --copy-face (new-face face) "Define NEW-FACE from existing FACE." @@ -41,7 +62,6 @@ 'font-lock-doc-face) (--copy-face 'font-lock-doc-string-face ; comment markups 'font-lock-comment-face) - (global-font-lock-mode t) (setq font-lock-maximum-decoration t) @@ -102,11 +122,3 @@ ("\\.vert\\'" . glsl-mode) ("\\.frag\\'" . glsl-mode) ("\\.geom\\'" . glsl-mode))) - -(define-minor-mode cocos2d-mode - "Buffer local minor mode for Cocos2D-x" - :init-value nil - :lighter " C2D" - :keymap (make-sparse-keymap)) - -(associate-minor-mode "[.-]c2d/" cocoa2d-mode)