doomemacs/modules/lang/cc
Henrik Lissner 3ce5d96e0a
bump: :lang
ShuguangSun/ess-view-data@5ec1c7206f -> ShuguangSun/ess-view-data@7dcbd23d4c
agda/agda@0d52fa2217 -> agda/agda@bb9e13d970
ardumont/markdown-toc@d3324cb6bc -> ardumont/markdown-toc@29e5c0f33e
atomontage/xterm-color@ce82e87ea3 -> atomontage/xterm-color@86fab1d247
babashka/neil@0b7373dd1b -> babashka/neil@8d5ccdbd81
clojure-emacs/cider@fb7aa88812 -> clojure-emacs/cider@15bd3b0265
clojure-emacs/clojure-mode@28dc02114a -> clojure-emacs/clojure-mode@4679222109
crystal-lang-tools/emacs-crystal-mode@d913fea6f0 -> crystal-lang-tools/emacs-crystal-mode@559e1d8ff9
davazp/graphql-mode@ee49531935 -> davazp/graphql-mode@ef757c6ce2
emacs-ess/ESS@7b9123669c -> emacs-ess/ESS@f8c464dc1b
emacs-geiser/gauche@9eb8b35f0c -> emacs-geiser/gauche@b8197c6288
emacs-geiser/geiser@43b9a034aa -> emacs-geiser/geiser@8842104d15
emacs-lsp/lsp-treemacs@3e5550f278 -> emacs-lsp/lsp-treemacs@49df7292c5
emacs-php/composer.el@eba6b953a4 -> emacs-php/composer.el@8cb5704edd
emacs-straight/auctex@a6f4741c22 -> emacs-straight/auctex@077874d25a
emacsmirror/cmake-mode@b08b5d9045 -> emacsmirror/cmake-mode@25340a7d12
emacsorphanage/dart-mode@9fbf703e1f -> emacsorphanage/dart-mode@773e9ebc74
emacsorphanage/ox-pandoc@5766c70b6d -> emacsorphanage/ox-pandoc@1caeb56a4b
emacsorphanage/restclient@426507f8f7 -> emacsorphanage/restclient@1800a4e367
erlang/otp@e281016db9 -> erlang/otp@2b2b39797f
fxbois/web-mode@1eb0abb1a9 -> fxbois/web-mode@1e7694aee8
gcv/julia-snail@7b50882f5a -> gcv/julia-snail@5a7e2d479c
godotengine/emacs-gdscript-mode@79739fc80f -> godotengine/emacs-gdscript-mode@248b73b1bd
greghendershott/racket-mode@d98852ef6d -> greghendershott/racket-mode@150b057953
hhvm/hack-mode@0addbff8b6 -> hhvm/hack-mode@86a981bd7b
https://codeberg.org/pranshu/haskell-ts-mode@b7db74c7fe96 -> https://codeberg.org/pranshu/haskell-ts-mode@bf143ee8382f
joaotavora/sly@6a303bae74 -> joaotavora/sly@b01993cf1d
ledger/ledger-mode@1cee636788 -> ledger/ledger-mode@9ab399186f
magit/orgit-forge@15f8e91083 -> magit/orgit-forge@c2116b8701 (v1.1.1)
magit/orgit@e0b3fca9f3 -> magit/orgit@24c8fe48c4 (v2.1.1)
mekeor/nael@101726eb47 -> mekeor/nael@9711443449
minad/org-modern@55b5bbeb1e -> minad/org-modern@9bbc44cc7e
nonsequitur/inf-ruby@b8076aad10 -> nonsequitur/inf-ruby@274398a242
ocaml/dune@a40c461736 -> ocaml/dune@14df34d30d
ocaml/merlin@ecfbed3976 -> ocaml/merlin@a0b096c243
oer/org-re-reveal@72c2463782 -> oer/org-re-reveal@8245facfdc
org-noter/org-noter@aafa08a49c -> org-noter/org-noter@81765d267e
org-roam/org-roam@b2634a17f8 -> org-roam/org-roam@c72702cf27
polymode/polymode@25ba9463a4 -> polymode/polymode@14b1fd8d2a
rust-lang/rust-mode@2d31814676 -> rust-lang/rust-mode@ae161dca23
wbolster/emacs-python-pytest@ed2ecee09d -> wbolster/emacs-python-pytest@78b5ea1d19
weijiangan/flycheck-golangci-lint@38cc30eb8b -> weijiangan/flycheck-golangci-lint@f7e36e19d6

Close: #8624
2026-01-18 03:13:00 -05:00
..
.doommodule feat: add .doommodule files 2024-09-14 20:47:39 -04:00
autoload.el fix(cc): typo in +cc-lineup-arglist-close 2025-12-14 15:05:20 -05:00
config.el fix(cc): gate major-mode-remap-defaults hacks behind +tree-sitter 2025-12-01 00:43:36 -05:00
doctor.el refactor!(cc): remove irony and rtags 2024-09-09 16:10:19 -04:00
packages.el bump: :lang 2026-01-18 03:13:00 -05:00
README.org docs(cc): Specify -- with command for bear 2025-05-15 09:39:34 +00:00

:lang cc

Description   unfold

This module adds support for the C-family of languages: C, C++, and Objective-C.

Through LSP, this module offers:

  • Code completion
  • eldoc support
  • Syntax-checking
  • Code navigation
  • 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
Enable LSP support for c-mode, c++-mode, and objc-mode. Requires doom-module::tools lsp and a langserver (supports clangd, ccls, and cquery).
+tree-sitter
Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.

Hacks

No hacks documented for this module.

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module's requirements change depending on how you use it.

  • If doom-module:+lsp is enabled, you need one of clangd v9+ or ccls.
  • Other features in this module depend on:

    • (optional) glslangValidator, for GLSL completion in glsl-mode
    • (optional) cmake, for code completion in cmake-mode
  • You will need a C/C++ compiler, like gcc or clang.

LSP servers

lsp-mode and eglot support a few LSP servers, but clangd is recommend:

clangd (must be v9 or newer)

clangd is included with llvm which should be available through your OS' package manager.

  • Linux:

    • Debian & Ubuntu: $ apt-get install clangd
    • 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
  • 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

:editor format

The formatter used is doom-executable:clang-format which should be installed alongside clang.

For more info, see doom-module::editor format.

TODO Usage

󱌣 This module's usage documentation is incomplete. Complete it?

  1. Enable this module.
  2. Enable the +lsp flag for the appropriate modules you want LSP support for (e.g. :lang (python +lsp) or :lang (rust +lsp)),
  3. Install the prerequisite LSP servers through your package manager or other means. You can find a list of supported servers on the lsp-mode project page.
  4. Run $ doom sync on the command line and restart Emacs.

Eglot-specific bindings

When using doom-module:+lsp and doom-module::tools lsp +eglot, doom-package:lsp-mode is replaced with doom-package: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)

TODO Configure

󱌣 This module's configuration documentation is incomplete. Complete it?

Project compile settings

LSP servers and Flycheck 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

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 doom-package:lsp-mode by default, doom-package:eglot if you have doom-module::tools lsp +eglot active in $DOOMDIR/init.el file.

LSP-mode with clangd

;;; add to $DOOMDIR/config.el
(after! lsp-clangd
  (setq lsp-clients-clangd-args
        '("-j=3"
          "--background-index"
          "--clang-tidy"
          "--completion-style=detailed"
          "--header-insertion=never"
          "--header-insertion-decorators=0"))
  (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

;;; add to $DOOMDIR/config.el
(after! ccls
  (setq ccls-initialization-options '(:index (:comments 2) :completion (:detailedLabel t)))
  (set-lsp-priority! 'ccls 1))

This will prioritize ccls over clangd, if both are present on your system. Also feel free to tweak var:ccls-initialization-options to reconfigure it (CCLS documentation lists available options; use t for true, :json-false for false, and :json-null for null).

Eglot with clangd

clangd will work with Eglot out of the box, but to customize its startup command, use fn:set-eglot-client!:

;;; add to $DOOMDIR/config.el
(after! cc-mode
  (set-eglot-client! 'cc-mode '("clangd" "-j=3" "--clang-tidy")))

Eglot with ccls

ccls will work with Eglot out of the box, but to customize its startup command, use fn:set-eglot-client!:

;;; add to $DOOMDIR/config.el
(after! cc-mode
  (set-eglot-client! 'cc-mode '("ccls" "--init={\"index\": {\"threads\": 3}}")))

CCLS documentation lists available options

Troubleshooting

There are no known problems with this module. Report one?

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

󱌣 This module has no appendix yet. Write one?