Emacs-Kotlin-Mode-Maintainers/kotlin-mode@876cc27dc1 -> Emacs-Kotlin-Mode-Maintainers/kotlin-mode@3e0c34087b FStarLang/fstar-mode.el@3afbf04e4e -> FStarLang/fstar-mode.el@c95c2a61a6 Fanael/edit-indirect@7fffd87ac3 -> Fanael/edit-indirect@e3d86416bc Fuco1/sphinx-mode@b5ac514e21 -> Fuco1/sphinx-mode@9d4075c106 Groovy-Emacs-Modes/groovy-emacs-modes@84f89b68ec -> Groovy-Emacs-Modes/groovy-emacs-modes@bf732d367b NixOS/nix-mode@8e20de5ba7 -> NixOS/nix-mode@20ee8d8890 OCamlPro/ocp-indent@9e26c0a269 -> OCamlPro/ocp-indent@7c4d434132 ProofGeneral/PG@df19c7ba0e -> ProofGeneral/PG@e1e29acb04 Raku/raku-mode@eaac071f17 -> Raku/raku-mode@977b14a7c1 Sarcasm/irony-mode@5063d6b16d -> Sarcasm/irony-mode@870d1576fb agda/agda@2816605bfd -> agda/agda@2816605bfd amake/flutter.el@81c524a43c -> amake/flutter.el@08138f8c95 ananthakumaran/exunit.el@5bb115f327 -> ananthakumaran/exunit.el@0715c2dc2d ananthakumaran/tide@28137ed904 -> ananthakumaran/tide@b93e555858 asok/projectile-rails@30828afbfa -> asok/projectile-rails@772f4766b5 asok/rake@9c204334b0 -> asok/rake@452ea0caca brotzeit/rustic@f4b5c288af -> brotzeit/rustic@6eec971387 cdominik/cdlatex@f215b70c5c -> cdominik/cdlatex@8e963c6853 clojure-emacs/cider@36277802a4 -> clojure-emacs/cider@86dd3fee9d codesuki/add-node-modules-path@7d9be65b3b -> codesuki/add-node-modules-path@63f047fd84 crystal-lang-tools/emacs-crystal-mode@15998140b0 -> crystal-lang-tools/emacs-crystal-mode@96a8058205 cython/cython@5b325c9860 -> cython/cython@fdea2d6bed diml/utop@c87b8b2817 -> diml/utop@5d72a0ab34 dominikh/go-mode.el@32cbd78c0a -> dominikh/go-mode.el@3273fcece5 elixir-editors/emacs-elixir@6bbc1e5ac4 -> elixir-editors/emacs-elixir@e0d0466d83 emacs-csharp/csharp-mode@9917e1b97d -> emacs-csharp/csharp-mode@856ecbc0a7 emacs-ess/ESS@a7ce81bb76 -> emacs-ess/ESS@39eba28300 emacs-geiser/geiser@c1cc4da1ed -> emacs-geiser/geiser@9507e81a07 emacs-geiser/guile@cfd9116dcb -> emacs-geiser/guile@c641fcc50b emacs-lsp/lsp-dart@813d3c92db -> emacs-lsp/lsp-dart@fda433671f emacs-lsp/lsp-haskell@4e62cf897d -> emacs-lsp/lsp-haskell@7cf64944ab emacs-lsp/lsp-java@ce03cb6574 -> emacs-lsp/lsp-java@0968038b9a emacs-lsp/lsp-metals@695291761b -> emacs-lsp/lsp-metals@b7f77de694 emacs-lsp/lsp-pyright@d428dbcf18 -> emacs-lsp/lsp-pyright@3598bc7c47 emacs-php/php-mode@535aec8173 -> emacs-php/php-mode@5f26bec865 emacs-php/phpactor.el@272217fbb6 -> emacs-php/phpactor.el@34195f1533 emacs-straight/auctex@3b0a080ae5 -> emacs-straight/auctex@830e40a063 emacs-straight/csv-mode@8da54e8b4e -> emacs-straight/csv-mode@43f6106f0d emacs-typescript/typescript.el@e824162051 -> emacs-typescript/typescript.el@88f317f0b6 erlang/otp@c1ab4b5424 -> erlang/otp@9ba9f6e60d ethereum/emacs-solidity@6f7bd1641e -> ethereum/emacs-solidity@20fb77e089 factor/factor@7b451bb813 -> factor/factor@1aeafdb87b fsharp/emacs-fsharp-mode@c90d762c06 -> fsharp/emacs-fsharp-mode@b3aa4c53fc fxbois/web-mode@61f057a6ba -> fxbois/web-mode@efa853e5cf godotengine/emacs-gdscript-mode@b7bfa6a3b2 -> godotengine/emacs-gdscript-mode@4badcf6a0c greghendershott/racket-mode@a879a8d67b -> greghendershott/racket-mode@af9b760e7b hakimel/reveal.js@918ee5610a -> hakimel/reveal.js@e281b3234e haskell/haskell-mode@8402caa341 -> haskell/haskell-mode@cb573c8db5 hhvm/hack-mode@4c1c2b0939 -> hhvm/hack-mode@a522f61c08 technomancy/fennel-mode@47152970a9 -> https://git.sr.ht/~technomancy/fennel-mode@50ef3c6246f3 hvesalai/emacs-sbt-mode@e29464a82b -> hvesalai/emacs-sbt-mode@9fe1e8807c hylang/hy-mode@5253533ddb -> hylang/hy-mode@df814865a1 idris-hackers/idris-mode@3cc9361b4c -> idris-hackers/idris-mode@65d6db1b75 iyefrat/evil-tex@aa0ddf8e76 -> iyefrat/evil-tex@0fa85c3fc8 jcollard/elm-mode@f2e2d0053f -> jcollard/elm-mode@d4e434fa18 joaotavora/sly@2e00c3bd4b -> joaotavora/sly@4513c382f0 jorgenschaefer/emacs-buttercup@1de6be465c -> jorgenschaefer/emacs-buttercup@f5cbf97e10 joshwnj/json-mode@0e819e519a -> joshwnj/json-mode@eedb456003 jrblevin/markdown-mode@541bd7b48a -> jrblevin/markdown-mode@521658eb32 jschaf/powershell.el@d1b3f95669 -> jschaf/powershell.el@ce1f0ae0b2 jwiegley/emacs-async@5d365ffc6a -> jwiegley/emacs-async@c78bab7506 leanprover/lean-mode@bf32bb9793 -> leanprover/lean-mode@c1c68cc946 ledger/ledger-mode@19b84dc766 -> ledger/ledger-mode@b55384d9cd necaris/conda.el@7a34e06931 -> necaris/conda.el@9c28d7a853 nonsequitur/inf-ruby@03dd9c9d4e -> nonsequitur/inf-ruby@dbf4386bac ocaml-ppx/ocamlformat@22a3707da3 -> ocaml-ppx/ocamlformat@9324ea439a ocaml/dune@4d0a47edd5 -> ocaml/dune@4bc7629a5e ocaml/merlin@e4791e2298 -> ocaml/merlin@5d59c70659 ocaml/tuareg@00faf47a7c -> ocaml/tuareg@04f5ab6be9 osv/company-web@f0cc9187c9 -> osv/company-web@863fb84b81 pashky/restclient.el@176d9cb655 -> pashky/restclient.el@9e2cfa8652 pezra/rspec-mode@92ef785010 -> pezra/rspec-mode@4215ff1f2d polymode/polymode@54888d6c15 -> polymode/polymode@2094c92403 seagle0128/grip-mode@9220a560b4 -> seagle0128/grip-mode@6b427143a8 sebasmonia/sharper@08277b6c30 -> sebasmonia/sharper@96edd4a1db stan-dev/stan-mode@9bb858b9f1 -> stan-dev/stan-mode@150bbbe5fd swift-emacs/swift-mode@800efe2910 -> swift-emacs/swift-mode@0d1ef0ef18 tpapp/julia-repl@e90b1ed2cc -> tpapp/julia-repl@6c1d63511f wbolster/emacs-python-pytest@b603c5c7f2 -> wbolster/emacs-python-pytest@ea53891a21 yoshiki/yaml-mode@63b637f846 -> yoshiki/yaml-mode@535273d5a1 ziglang/zig-mode@aba01b6199 -> ziglang/zig-mode@aa20d630b8 - Refactors the :lang rust module to reflect changes upstream, in rustic (thanks to #6154). Close: #6154 Fix: #6070
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.-
Linux:
-
Debian 11 & Ubuntu 20.10:
# apt-get install clangd-11
- 20.04 LTS: clangd-10
- Fedora & CentOS/RHEL 8+:
# dnf install clang-tools-extra
- openSUSE:
# zypper install clang
- Arch:
# pacman -S clang
-
-
BSDs:
- NetBSD & OpenBSD:
# pkg_add clang-tools-extra
- NetBSD & OpenBSD:
- macOS:
$ brew install llvm
// 1GB+ installation! May take a while! - Windows: use the win64 installer from LLVM's GitHub release page.
-
- ccls
- Available in many OS' package managers as
ccls
. Otherwise, there are alternative install methods listed in the project's wiki. - cmake-language-server
- available through
pip
on most distributions
irony-server
Irony powers the code completion, eldoc and syntax checking systems.
After installing its dependencies (Clang and CMake), 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
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
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:
Configure LSP servers
Search for your combination of (LSP client package, LSP server)
. You are using
LSP-mode
by default, eglot
if you have :tools (lsp +eglot)
active in your
init.el
file.
LSP-mode with clangd
(setq lsp-clients-clangd-args '("-j=3"
"--background-index"
"--clang-tidy"
"--completion-style=detailed"
"--header-insertion=never"
"--header-insertion-decorators=0"))
(after! lsp-clangd (set-lsp-priority! 'clangd 2))
This will both set your clangd flags and choose clangd
as the default LSP server everywhere clangd can be used.
LSP-mode with ccls
(after! ccls
(setq ccls-initialization-options '(:index (:comments 2) :completion (:detailedLabel t)))
(set-lsp-priority! 'ccls 2)) ; optional as ccls is the default in Doom
This will both set your ccls flags and choose ccls as the default server. CCLS
documentation lists available options, use t
for true
, :json-false
for
false
, and :json-null
for null
.
Eglot with clangd
(set-eglot-client! 'cc-mode '("clangd" "-j=3" "--clang-tidy"))
This will both set your clangd flags and choose clangd as the default server (if
it is the last set-eglot-client! 'cc-mode
in your config).
Eglot with ccls
(set-eglot-client! 'cc-mode '("ccls" "--init={\"index\": {\"threads\": 3}}"))
This will both set your ccls flags and choose ccls as the default server (if it
is the last set-eglot-client! 'cc-mode
in your config). CCLS documentation
lists available options
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) |