200ok-ch/counsel-jq@b14dfc5 -> 200ok-ch/counsel-jq@104c77b Andersbakken/rtags@b57b360 -> Andersbakken/rtags@e6c7005 Emacs-Kotlin-Mode-Maintainers/kotlin-mode@8e6dd57 -> Emacs-Kotlin-Mode-Maintainers/kotlin-mode@0e4bafb FStarLang/fstar-mode.el@bd28cb8 -> FStarLang/fstar-mode.el@5670fc0 GDQuest/emacs-gdscript-mode@7aea87b -> GDQuest/emacs-gdscript-mode@55a6637 JuliaEditorSupport/julia-emacs@b5f5983 -> JuliaEditorSupport/julia-emacs@8ea90c7 NixOS/nix-mode@0cf1ea1 -> NixOS/nix-mode@bb0b49e OmniSharp/omnisharp-emacs@e658a18 -> OmniSharp/omnisharp-emacs@e26ff8b ProofGeneral/PG@03e427a -> ProofGeneral/PG@4f6b602 Raku/raku-mode@e0639c8 -> Raku/raku-mode@8a6e17f Sterlingg/json-snatcher@c4cecc0 -> Sterlingg/json-snatcher@b28d1c0 agda/agda@36738c1 -> agda/agda@08191e6 asok/projectile-rails@11980b2 -> asok/projectile-rails@7a256b1 borkdude/flycheck-clj-kondo@5472c26 -> borkdude/flycheck-clj-kondo@152df7f brotzeit/rustic@75b9920 -> brotzeit/rustic@7c9d55b clojure-emacs/cider@a89b694 -> clojure-emacs/cider@f1c2a79 clojure-emacs/clj-refactor.el@9709568 -> clojure-emacs/clj-refactor.el@6db85b3 clojure-emacs/clojure-mode@84ed16c -> clojure-emacs/clojure-mode@75c2889 cython/cython@fcfd16c -> cython/cython@ba6cbed dominikh/go-mode.el@734d523 -> dominikh/go-mode.el@d17d210 emacs-ess/ESS@1baf8bf -> emacs-ess/ESS@a694b26 emacs-lsp/lsp-haskell@a56667b -> emacs-lsp/lsp-haskell@4d85cb3 emacs-lsp/lsp-java@2600162 -> emacs-lsp/lsp-java@3f1ed17 emacs-lsp/lsp-metals@039aa72 -> emacs-lsp/lsp-metals@8f8471c emacs-lsp/lsp-pyright@9603dda -> emacs-lsp/lsp-pyright@ccd0007 emacs-lsp/lsp-python-ms@a884a9a -> emacs-lsp/lsp-python-ms@a0c56f4 emacs-lsp/lsp-sourcekit@130f7a8 -> emacs-lsp/lsp-sourcekit@948c3a3 emacs-straight/rainbow-mode@f780ddb -> emacs-straight/rainbow-mode@fdff98b emacs-typescript/typescript.el@42a60e5 -> emacs-typescript/typescript.el@e6f68ab ericdallo/hover.el@e213f2b -> ericdallo/hover.el@3f07a18 erlang/otp@d9bc785 -> erlang/otp@36b4ba4 factor/factor@3fdb032 -> factor/factor@c6e15bd flycheck/flycheck-cask@3457ae5 -> flycheck/flycheck-cask@4b2ede6 fsharp/emacs-fsharp-mode@3e41fe1 -> fsharp/emacs-fsharp-mode@68dfc22 fxbois/web-mode@60ffd87 -> fxbois/web-mode@b4b0a85 galaunay/poetry.el@22a76cd -> galaunay/poetry.el@eb238d9 greghendershott/racket-mode@c55fd70 -> greghendershott/racket-mode@0ca8b26 hhvm/hack-mode@572c3b4 -> hhvm/hack-mode@9079bc3 hylang/hy-mode@55e84ca -> hylang/hy-mode@7256844 immerrr/lua-mode@35b6e4c -> immerrr/lua-mode@345ebfc jaor/geiser@adc5c4a -> jaor/geiser@2accab7 joaotavora/sly@34239bc -> joaotavora/sly@fce4f9b jorgenschaefer/emacs-buttercup@0e5eae0 -> jorgenschaefer/emacs-buttercup@cccdedf jorgenschaefer/emacs-buttercup@0e5eae0 -> jorgenschaefer/emacs-buttercup@cccdedf josteink/csharp-mode@4885177 -> josteink/csharp-mode@f46d656 jrblevin/markdown-mode@ef2cb4d -> jrblevin/markdown-mode@152eae2 jschaf/powershell.el@8782677 -> jschaf/powershell.el@d1b3f95 jwiegley/emacs-async@36a1015 -> jwiegley/emacs-async@14f48de leanprover/lean-mode@6b43776 -> leanprover/lean-mode@cc1f5fa liblit/demangle-mode@697c1db -> liblit/demangle-mode@aaef0bd mooz/js2-mode@40aab27 -> mooz/js2-mode@ffb7099 nonsequitur/inf-ruby@9f0f79f -> nonsequitur/inf-ruby@b012457 pashky/restclient.el@ac8aad6 -> pashky/restclient.el@abc307b pythonic-emacs/anaconda-mode@73266a4 -> pythonic-emacs/anaconda-mode@39b1cf8 pythonic-emacs/pyenv-mode@d191037 -> pythonic-emacs/pyenv-mode@b818901 seagle0128/grip-mode@281ada2 -> seagle0128/grip-mode@91da46f senny/rvm.el@081d517 -> senny/rvm.el@6897576 swift-emacs/swift-mode@d266fbd -> swift-emacs/swift-mode@e65a80a wbolster/emacs-python-pytest@fc056fa -> wbolster/emacs-python-pytest@a2f88b1 xuchunyang/elisp-demos@8c97481 -> xuchunyang/elisp-demos@3cca496
lang/cc
Description
This module adds support for the C-family of languages: C, C++, and Objective-C.
- Code completion (
company-irony
) - eldoc support (
irony-eldoc
) - Syntax-checking (
flycheck-irony
) - Code navigation (
rtags
) - File Templates (c-mode, c++-mode)
- Snippets (cc-mode, c-mode, c++-mode)
- Several improvements to C++11 indentation and syntax highlighting.
Module Flags
+lsp
Disables irony+rtags and replaces them with LSP (ccls by default). This requires the:tools lsp
module.
Plugins
- cmake-mode
- cuda-mode
- demangle-mode
- disaster
- modern-cpp-font-lock
- opencl-mode
- glsl-mode*
- company-glsl*
-
+lsp
- ccls if
:tools lsp
has no+eglot
flag
- ccls if
-
-lsp
Prerequisites
This module's requirements change depending on how you use it.
- If
+lsp
is enabled, you need one of clangd v9+ or ccls. - If
+lsp
is not enabled, you need irony-server and rtags. -
Other features in this module depend on:
- (optional) glslangValidator, for GLSL completion in
glsl-mode
- (optional) cmake, for code completion in
cmake-mode
- (optional) glslangValidator, for GLSL completion in
- You will need a C/C++ compiler, like
gcc
orclang
.
LSP servers
lsp-mode
and eglot
support a few LSP servers, but clangd
and ccls
are
recommended.
- clangd (must be v9 or newer)
-
Clangd is included with
llvm
which should be available through your OS' package manager.- Debian/Ubuntu:
sudo apt-get install clangd-9
- macOS:
brew install llvm
- Windows: install from LLVM download page
- clangd is available on some Linux distros from a
clang-tools
package, if you'd like to avoid the fullllvm
.
- Debian/Ubuntu:
- ccls
- Available in many OS' package managers as
ccls
. Otherwise, there are alternative install methods listed in the project's wiki.
irony-server
Irony powers the code completion, eldoc and syntax checking systems.
After installing its dependencies, run M-x irony-install-server
in Emacs.
macOS
Due to linking issues, macOS users must compile irony-server manually:
brew install cmake
brew install llvm # 1gb+ installation! May take a while!
git clone https://github.com/Sarcasm/irony-mode irony-mode
mkdir irony-mode/server/build
pushd irony-mode/server/build
DEST="$HOME/.emacs.d/.local/etc/irony-server/"
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
-DCMAKE_INSTALL_PREFIX="$DEST" ../
cmake --build . --use-stderr --config Release --target install
install_name_tool -change @rpath/libclang.dylib \
/usr/local/opt/llvm/lib/libclang.dylib \
"$DEST/bin/irony-server"
# cleanup
popd
rm -rf irony-mode
Arch Linux
pacman -S clang cmake
openSUSE
sudo zypper install clang cmake
rtags
Code navigation requires an rtags server (rdm
) installed. This should be
available through your OS's package manager.
This module will auto-start rdm
when you open C/C++ buffers (so long as one
isn't already running). If you prefer to run it yourself:
rdm &
rc -J $PROJECT_ROOT # loads PROJECT_ROOT's compile_commands.json
Configure
Project compile settings
By default, a set of default compile settings are defined in
+cc-default-compiler-options
for C, C++ and Objective C. Irony, rtags and
flycheck will fall back to these. This variable does nothing for LSP users.
For a more universal solution: both LSP servers and irony will recognize a
compilation database (a compile_commands.json
file). There are many ways to
generate one. Here is an example using CMake and bear:
# For CMake projects
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
# For non-CMake projects
make clean
bear make
Use M-x +cc/reload-compile-db
to reload your compile db in an already-open
C/C++/ObjC buffer.
Known issues with bear on macOS
MacOS' System Integrity Protection (SIP) might interfere with bear if make
is
under /usr/bin/
which results in an empty compilation database.
From the bear readme:
Security extension/modes on different operating systems might disable library preloads. This case Bear behaves normally, but the result compilation database will be empty. (Please make sure it's not the case when reporting bugs.) Notable examples for enabled security modes are: OS X 10.11 (check with csrutil status | grep 'System Integrity Protection'), and Fedora, CentOS, RHEL (check with sestatus | grep 'SELinux status').
Workaround could be to disable the security feature while running Bear. (This might involve reboot of your computer, so might be heavy workaround.) Another option if the build tool is not installed under certain directories. Or use tools which are using compiler wrappers. (It injects a fake compiler which does record the compiler invocation and calls the real compiler too.) An example for such tool might be scan-build. The build system shall respect CC and CXX environment variables.
A workaround might be to install make
via Homebrew which puts gmake
under /usr/local/
.
brew install make
make clean
bear gmake
Additional info:
Appendix
Eglot specific bindings
When using +lsp
and :tools (lsp +eglot)
, lsp-mode is replaced with eglot,
and an additional function to get inheritance type hierarchy is added
Binding | Description |
---|---|
<localleader> c t |
Display inheritance type hierarchy (upwards) |
<prefix> <localleader> c t |
Display inheritance type hierarchy (downwards) |