lang/cc: rewrite README
This commit is contained in:
parent
634238782b
commit
9916025d5c
1 changed files with 52 additions and 30 deletions
|
@ -1,5 +1,21 @@
|
||||||
#+TITLE: :lang cc
|
#+TITLE: lang/cc
|
||||||
|
#+DATE: January 16, 2017
|
||||||
|
#+SINCE: v2.0
|
||||||
|
#+STARTUP: inlineimages
|
||||||
|
|
||||||
|
* Table of Contents :TOC_3:noexport:
|
||||||
|
- [[Description][Description]]
|
||||||
|
- [[Module Flags][Module Flags]]
|
||||||
|
- [[Plugins][Plugins]]
|
||||||
|
- [[Prerequisites][Prerequisites]]
|
||||||
|
- [[irony-server][irony-server]]
|
||||||
|
- [[MacOS][MacOS]]
|
||||||
|
- [[Arch Linux][Arch Linux]]
|
||||||
|
- [[rtags][rtags]]
|
||||||
|
- [[Configure][Configure]]
|
||||||
|
- [[Project compile settings][Project compile settings]]
|
||||||
|
|
||||||
|
* Description
|
||||||
This module adds support for the C-family of languages: C, C++, and Objective-C.
|
This module adds support for the C-family of languages: C, C++, and Objective-C.
|
||||||
|
|
||||||
+ Code completion (~company-irony~)
|
+ Code completion (~company-irony~)
|
||||||
|
@ -10,34 +26,44 @@ This module adds support for the C-family of languages: C, C++, and Objective-C.
|
||||||
+ Snippets ([[https://github.com/hlissner/emacs-snippets/tree/master/cc-mode][cc-mode]], [[https://github.com/hlissner/emacs-snippets/tree/master/c-mode][c-mode]], [[https://github.com/hlissner/emacs-snippets/tree/master/c++-mode][c++-mode]])
|
+ Snippets ([[https://github.com/hlissner/emacs-snippets/tree/master/cc-mode][cc-mode]], [[https://github.com/hlissner/emacs-snippets/tree/master/c-mode][c-mode]], [[https://github.com/hlissner/emacs-snippets/tree/master/c++-mode][c++-mode]])
|
||||||
+ Several improvements to C++11 indentation and syntax highlighting.
|
+ Several improvements to C++11 indentation and syntax highlighting.
|
||||||
|
|
||||||
#+begin_quote
|
** Module Flags
|
||||||
C contends with Haskell and Ruby for my favorite language. That said, it's more
|
+ ~+irony~ Enable Irony as a backend for code completion, syntax checking, and
|
||||||
accurate to say I write C, but a C++ feature or three.
|
eldoc support. This must be disabled to use LSP or another backend.
|
||||||
|
+ ~+rtags~ Enable rtags integration. A daemon will be spawned the first time you
|
||||||
|
open a C/C++/ObjC buffer, if one hasn't already.
|
||||||
|
|
||||||
The module provides nominal support for Objective-C, which I really only use to
|
** Plugins
|
||||||
inspect generated glue code for iOS mobile apps. Otherwise, I prefer Swift.
|
+ [[https://github.com/Kitware/CMake][cmake-mode]]
|
||||||
#+end_quote
|
+ [[https://github.com/chachi/cuda-mode][cuda-mode]]
|
||||||
|
+ [[https://github.com/liblit/demangle-mode][demangle-mode]]
|
||||||
|
+ [[https://github.com/jart/disaster][disaster]]
|
||||||
|
+ [[https://github.com/ludwigpacifici/modern-cpp-font-lock][modern-cpp-font-lock]]
|
||||||
|
+ [[https://github.com/salmanebah/opencl-mode][opencl-mode]]
|
||||||
|
+ [[https://github.com/jimhourihan/glsl-mode][glsl-mode]]*
|
||||||
|
+ [[https://github.com/guidoschmidt/company-glsl][gompany-glsl]]*
|
||||||
|
+ [[https://github.com/Sarcasm/irony-mode][irony]]*
|
||||||
|
+ [[https://github.com/ikirill/irony-eldoc][irony-eldoc]]*
|
||||||
|
+ [[https://github.com/Sarcasm/flycheck-irony][flycheck-irony]]*
|
||||||
|
+ [[https://github.com/Sarcasm/company-irony][company-irony]]*
|
||||||
|
+ [[https://github.com/hotpxl/company-irony-c-headers][company-irony-c-headers]]*
|
||||||
|
+ [[https://github.com/Andersbakken/rtags][rtags]]*
|
||||||
|
+ [[https://github.com/Andersbakken/rtags][ivy-rtags]] or [[https://github.com/Andersbakken/rtags][helm-rtags]]*
|
||||||
|
|
||||||
* Table of Contents :TOC:
|
* Prerequisites
|
||||||
- [[#install][Install]]
|
This module requires
|
||||||
- [[#irony-server][irony-server]]
|
|
||||||
- [[#rtags][rtags]]
|
|
||||||
- [[#configure][Configure]]
|
|
||||||
- [[#compile-settings][Compile settings]]
|
|
||||||
|
|
||||||
* Install
|
+ irony-server (if ~+irony~ is enabled)
|
||||||
This module requires:
|
+ rtags (if ~+rtags~ is enabled)
|
||||||
|
|
||||||
+ irony-server
|
|
||||||
+ rtags
|
|
||||||
|
|
||||||
** irony-server
|
** irony-server
|
||||||
Irony powers the code completion, eldoc and syntax checking systems.
|
Irony powers the code completion, eldoc and syntax checking systems.
|
||||||
|
|
||||||
|
After installing its dependencies, run ~M-x irony-install-server~ in Emacs.
|
||||||
|
|
||||||
*** MacOS
|
*** MacOS
|
||||||
Due to linking issues, MacOS users must compile irony-server manually:
|
Due to linking issues, MacOS users must compile irony-server manually:
|
||||||
|
|
||||||
#+BEGIN_SRC sh :tangle (if (doom-system-os 'macos) "yes")
|
#+BEGIN_SRC sh
|
||||||
brew install cmake
|
brew install cmake
|
||||||
brew install llvm # 1gb+ installation! May take a while!
|
brew install llvm # 1gb+ installation! May take a while!
|
||||||
|
|
||||||
|
@ -60,18 +86,16 @@ rm -rf irony-mode
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** Arch Linux
|
*** Arch Linux
|
||||||
#+BEGIN_SRC sh :tangle (if (doom-system-os 'arch) "yes")
|
#+BEGIN_SRC sh
|
||||||
sudo pacman --needed --noconfirm -S clang cmake
|
pacman -S clang cmake
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
Then run ~M-x irony-install-server~ in Emacs.
|
|
||||||
|
|
||||||
** rtags
|
** rtags
|
||||||
Code navigation requires an [[https://github.com/Andersbakken/rtags][rtags]] server (~rdm~) installed and running. This
|
Code navigation requires an [[https://github.com/Andersbakken/rtags][rtags]] server (~rdm~) installed. This should be
|
||||||
should be available through your OS's package manager.
|
available through your OS's package manager.
|
||||||
|
|
||||||
This module will auto-start ~rdm~ when you open C/C++ buffers (so long as one
|
This module will auto-start ~rdm~ when you open C/C++ buffers (so long as one
|
||||||
isn't already). If you prefer to run it yourself, outside of Emacs:
|
isn't already running). If you prefer to run it yourself:
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
rdm &
|
rdm &
|
||||||
|
@ -79,7 +103,7 @@ rc -J $PROJECT_ROOT # loads PROJECT_ROOT's compile_commands.json
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Configure
|
* Configure
|
||||||
** Compile settings
|
** Project compile settings
|
||||||
By default, a set of default compile settings are defined in
|
By default, a set of default compile settings are defined in
|
||||||
~+cc-default-compiler-options~ for C, C++ and Objective C. Irony, rtags and
|
~+cc-default-compiler-options~ for C, C++ and Objective C. Irony, rtags and
|
||||||
flycheck will fall back to these.
|
flycheck will fall back to these.
|
||||||
|
@ -87,7 +111,7 @@ flycheck will fall back to these.
|
||||||
To make these tools aware of project specific build settings, you need a JSON
|
To make these tools aware of project specific build settings, you need a JSON
|
||||||
[[https://sarcasm.github.io/notes/dev/compilation-database.html#ninja][compilation database]] present (i.e. a ~compile_commands.json~ file).
|
[[https://sarcasm.github.io/notes/dev/compilation-database.html#ninja][compilation database]] present (i.e. a ~compile_commands.json~ file).
|
||||||
|
|
||||||
There are [[https://sarcasm.github.io/notes/dev/compilation-database.html][many ways to generate one]]. I use [[http://www.cmake.org/][CMake]] and [[https://github.com/rizsotto/Bear][bear]]:
|
There are [[https://sarcasm.github.io/notes/dev/compilation-database.html][many ways to generate one]]. I use [[http://www.cmake.org/][CMake]] or [[https://github.com/rizsotto/Bear][bear]]:
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
# For CMake projects
|
# For CMake projects
|
||||||
|
@ -98,7 +122,5 @@ make clean
|
||||||
bear make
|
bear make
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
#+begin_quote
|
|
||||||
Use ~M-x +cc/reload-compile-db~ to reload your compile db in an already-open
|
Use ~M-x +cc/reload-compile-db~ to reload your compile db in an already-open
|
||||||
C/C++/ObjC buffer.
|
C/C++/ObjC buffer.
|
||||||
#+end_quote
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue