<commit_before>#+TITLE: C/C++ contribution layer for Spacemacs

[[file:img/ccpp.jpg]]
[[file:img/cmake.png]]

* Table of Contents                                                   :TOC@4:
 - [[#description][Description]]
 - [[#features][Features]]
 - [[#install][Install]]
     - [[#layer][Layer]]
     - [[#default-mode-for-header-files][Default mode for header files]]
     - [[#enable-clang-support][Enable Clang support]]
         - [[#clang-format][clang-format]]
         - [[#company-clang-and-flycheck][Company-clang and flycheck]]
 - [[#key-bindings][Key Bindings]]

* Description

This layer adds configuration for C/C++ language as well support for [[http://www.cmake.org/][CMake]]
scripts.

* Features

- Support syntax checking via flycheck with Clang.
- Support code reformatting with [[http://clang.llvm.org/docs/ClangFormat.html][clang-format]].
- Display function or variable definition at the bottom. (when =semantic= layer is included)
- Display current function cursor is in at the top. See [[https://github.com/tuhdo/semantic-stickyfunc-enhance][stickyfunc-demos]] for
  demos in some programming languages. (when =semantic= layer is included)
- Support common refactoring with [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] . See [[https://github.com/tuhdo/semantic-refactor/blob/master/srefactor-demos/demos.org][srefactor-demos]] for
  demonstration of refactoring features. (when =semantic= layer is included)

* Install

** Layer

To use this contribution add it to your =~/.spacemacs=

#+BEGIN_SRC emacs-lisp
  (setq-default dotspacemacs-configuration-layers '(c-c++))
#+END_SRC

*Note:* [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] is only available for Emacs 24.4+

** Default mode for header files

By default header files are opened in =c-mode=, you can open them in =c++-mode=
by setting the variable =c-c++-default-mode-for-headers= to =c++-mode=.

#+BEGIN_SRC emacs-lisp
  (setq-default dotspacemacs-configuration-layers
    '((c-c++ variables:
             c-c++-default-mode-for-headers 'c++-mode)))
#+END_SRC

*Note:* To set the variable for a given project, create a directory local
variable at the root of your project. More info on directory local variables<commit_msg>Fix typo in c-c++ README.<commit_after>#+TITLE: C/C++ contribution layer for Spacemacs

[[file:img/ccpp.jpg]]
[[file:img/cmake.png]]

* Table of Contents                                                   :TOC@4:
 - [[#description][Description]]
 - [[#features][Features]]
 - [[#install][Install]]
     - [[#layer][Layer]]
     - [[#default-mode-for-header-files][Default mode for header files]]
     - [[#enable-clang-support][Enable Clang support]]
         - [[#clang-format][clang-format]]
         - [[#company-clang-and-flycheck][Company-clang and flycheck]]
 - [[#key-bindings][Key Bindings]]

* Description

This layer adds configuration for C/C++ language as well support for [[http://www.cmake.org/][CMake]]
scripts.

* Features

- Support syntax checking via flycheck with Clang.
- Support code reformatting with [[http://clang.llvm.org/docs/ClangFormat.html][clang-format]].
- Display function or variable definition at the bottom. (when =semantic= layer is included)
- Display current function cursor is in at the top. See [[https://github.com/tuhdo/semantic-stickyfunc-enhance][stickyfunc-demos]] for
  demos in some programming languages. (when =semantic= layer is included)
- Support common refactoring with [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] . See [[https://github.com/tuhdo/semantic-refactor/blob/master/srefactor-demos/demos.org][srefactor-demos]] for
  demonstration of refactoring features. (when =semantic= layer is included)

* Install

** Layer

To use this contribution add it to your =~/.spacemacs=

#+BEGIN_SRC emacs-lisp
  (setq-default dotspacemacs-configuration-layers '(c-c++))
#+END_SRC

*Note:* [[https://github.com/tuhdo/semantic-refactor][semantic-refactor]] is only available for Emacs 24.4+

** Default mode for header files

By default header files are opened in =c-mode=, you can open them in =c++-mode=
by setting the variable =c-c++-default-mode-for-headers= to =c++-mode=.

#+BEGIN_SRC emacs-lisp
  (setq-default dotspacemacs-configuration-layers
    '((c-c++ :variables
             c-c++-default-mode-for-headers 'c++-mode)))
#+END_SRC

*Note:* To set the variable for a given project, create a directory local
variable at the root of your project. More info on directory local variables
{'fraction_non_alphanumeric': 0.14368070953436807, 'fraction_numerical': 0.0017738359201773836, 'mean_word_length': 3.866235167206041, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3196795', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1421, 'n_words': 393}