Andersbakken/rtags@ee1ab7b9a6 -> Andersbakken/rtags@05117a9a29 FStarLang/fstar-mode.el@ab0697b947 -> FStarLang/fstar-mode.el@7d353de892 Fanael/edit-indirect@f80f63822f -> Fanael/edit-indirect@82a28d8a85 ProofGeneral/PG@8416875696 -> ProofGeneral/PG@a38857a6a0 Sarcasm/irony-mode@870d1576fb -> Sarcasm/irony-mode@40e0ce19eb aaronjensen/flycheck-credo@e88f11ead5 -> aaronjensen/flycheck-credo@e285bd042a agda/agda@bb7603d197 -> agda/agda@fbf9d159c3 amake/flutter.el@edd3f5eb3f -> amake/flutter.el@004c91e070 ananthakumaran/exunit.el@e0a8c2b81f -> ananthakumaran/exunit.el@e008c89e01 ananthakumaran/tide@29475d9eee -> ananthakumaran/tide@b38dfc3f8f arthurnn/minitest-emacs@ddd152c990 -> arthurnn/minitest-emacs@5999c45c04 babashka/neil@40993873bb -> babashka/neil@a1db63d420 beancount/beancount-mode@0f1e33067e -> beancount/beancount-mode@546163fd2c borkdude/flycheck-clj-kondo@ff7bed2315 -> borkdude/flycheck-clj-kondo@9089ade9e0 cdominik/cdlatex@ac024ce293 -> cdominik/cdlatex@33770dec73 clojure-emacs/cider@120fd885d3 -> clojure-emacs/cider@aa26d62ac5 clojure-emacs/clj-refactor.el@0a2a6cbc2e -> clojure-emacs/clj-refactor.el@fa3efe18e7 clojure-emacs/clojure-mode@25d713a67d -> clojure-emacs/clojure-mode@222fdafa2a clojure-emacs/parseclj@74ff7d63fe -> clojure-emacs/parseclj@6af22372e0 clojure-emacs/parseedn@c8f07926a6 -> clojure-emacs/parseedn@3407e4530a crystal-lang-tools/emacs-crystal-mode@9bfb9f0f56 -> crystal-lang-tools/emacs-crystal-mode@ea89b108fa davazp/graphql-mode@1437b79006 -> davazp/graphql-mode@49a391b529 dgutov/robe@912ae2ba1f -> dgutov/robe@4ecd868da9 dominikh/go-mode.el@166dfb1e09 -> dominikh/go-mode.el@8dce1e3ba1 elixir-editors/emacs-elixir@7641373f05 -> elixir-editors/emacs-elixir@00d6580a04 emacs-geiser/geiser@49d12a1448 -> emacs-geiser/geiser@bb77719c25 emacs-geiser/guile@ee33af6b4e -> emacs-geiser/guile@6e0811c75d emacs-lsp/emacs-ccls@dd33da8ed7 -> emacs-lsp/emacs-ccls@9b4a47e041 emacs-lsp/lsp-dart@3db9f93c83 -> emacs-lsp/lsp-dart@e7ee6afc2e emacs-lsp/lsp-java@449673da72 -> emacs-lsp/lsp-java@c962a3b3ac emacs-php/composer.el@5af1707fef -> emacs-php/composer.el@91945f1bdb emacs-php/php-mode@fb11df8268 -> emacs-php/php-mode@a0bcafbe30 emacs-php/phpactor.el@9440005814 -> emacs-php/phpactor.el@8733fef84b emacs-php/psysh.el@796b26a5cd -> emacs-php/psysh.el@c7dde979d9 emacs-straight/adaptive-wrap@0d5b4a07de -> emacs-straight/adaptive-wrap@70005d2012 emacs-straight/auctex@3929d5408b -> emacs-straight/auctex@86b2397abd emacs-straight/csv-mode@d190a479b4 -> emacs-straight/csv-mode@81c1a9febd emacs-straight/rainbow-mode@8e96388fb4 -> emacs-straight/rainbow-mode@70ed10d410 emacs-straight/sml-mode@5426ff4738 -> emacs-straight/sml-mode@e5354371f3 emacsmirror/cmake-mode@f9c7a21254 -> emacsmirror/cmake-mode@b08b5d9045 emacsorphanage/dart-mode@9c846769ab -> emacsorphanage/dart-mode@dffc0209a1 erlang/otp@be7109f43b -> erlang/otp@0ca7e064f5 factor/factor@76ac65649d -> factor/factor@23fcfc7075 flycheck/flycheck-cask@4b2ede6362 -> flycheck/flycheck-cask@0eeec5197e fxbois/web-mode@57856ba64b -> fxbois/web-mode@82847071ce gcv/julia-snail@18b891b456 -> gcv/julia-snail@d36653bb93 gdkrmr/lsp-julia@c584f79c7f -> gdkrmr/lsp-julia@c869b2f6c0 godotengine/emacs-gdscript-mode@d392e8aa7e -> godotengine/emacs-gdscript-mode@8a28276daa greghendershott/racket-mode@947d9806ee -> greghendershott/racket-mode@d3ab936af1 haskell/haskell-mode@79eaf444a7 -> haskell/haskell-mode@43b4036bf0 hhvm/hack-mode@26f06ffe82 -> hhvm/hack-mode@278e4cc403 hvesalai/emacs-scala-mode@5d7cf21c37 -> hvesalai/emacs-scala-mode@4c6d636b86 idris-hackers/idris-mode@c96f45d1b8 -> idris-hackers/idris-mode@37c6b81990 immerrr/lua-mode@7eb8eaa420 -> immerrr/lua-mode@d074e4134b iyefrat/evil-tex@3e0a26b91a -> iyefrat/evil-tex@2a3177c818 jrblevin/markdown-mode@b1a862f016 -> jrblevin/markdown-mode@e096bb97a9 json-emacs/json-mode@eedb456003 -> json-emacs/json-mode@bfd1557aaa jwiegley/emacs-async@71cc50f27f -> jwiegley/emacs-async@d040f72cb0 ledger/ledger-mode@4b32f70173 -> ledger/ledger-mode@11e748d483 ljos/jq-mode@071c1c29ba -> ljos/jq-mode@37028e1200 nex3/haml-mode@fe83c65c1f -> nex3/haml-mode@a64d58df8f nlamirault/phpunit.el@4a36906344 -> nlamirault/phpunit.el@650a50898d nonsequitur/inf-ruby@03475ac1cc -> nonsequitur/inf-ruby@dac615c7fd ocaml-ppx/ocamlformat@7db948a894 -> ocaml-ppx/ocamlformat@b8b0956690 ocaml/dune@360b000271 -> ocaml/dune@64d19876ad pashky/restclient.el@0ba72816f9 -> pashky/restclient.el@e2a2b13482 psibi/dhall-mode@c77f1c1e75 -> psibi/dhall-mode@87ab69fe76 purescript-emacs/emacs-psci@9bb6a32532 -> purescript-emacs/emacs-psci@ef31045295 purescript-emacs/psc-ide-emacs@ce97d71945 -> purescript-emacs/psc-ide-emacs@4e614df553 s-kostyaev/go-gen-test@f84f4177af -> s-kostyaev/go-gen-test@af00a9abba seagle0128/grip-mode@5809fb62f6 -> seagle0128/grip-mode@e145adb225 senny/rbenv.el@2ea1a5bdc1 -> senny/rbenv.el@588b817d51 technomancy/fennel-mode@8f721285e1 -> technomancy/fennel-mode@5965c8fc69 tpapp/julia-repl@9503ef7110 -> tpapp/julia-repl@4947319bc9 weijiangan/flycheck-golangci-lint@8e446c6831 -> weijiangan/flycheck-golangci-lint@9def093e41 wwwjfy/emacs-fish@6869efbc05 -> wwwjfy/emacs-fish@2526b1803b yoshiki/yaml-mode@3fcb36d603 -> yoshiki/yaml-mode@5b58248ab2 Close: #7648
:lang cc
Description unfold
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.
Maintainers
Module flags
- +lsp
-
Enable LSP support for
c-mode
,c++-mode
, andobjc-mode
. Requires [[doom-module::tools lsp]] and a langserver (supports ccls, clangd, and cquery). Replaces irony & rtags. - +tree-sitter
- Leverages tree-sitter for better syntax highlighting and structural text editing. Requires doom-module::tools tree-sitter.
Packages
- doom-package:cmake-mode
- doom-package:company-glsl
- doom-package:cuda-mode
- doom-package:demangle-mode
- doom-package:disaster
- doom-package:glsl-mode
- doom-package:modern-cpp-font-lock
- doom-package:opencl-mode
-
- doom-package:ccls if doom-module::tools lsp -eglot
-
else
- doom-package:company-irony
- doom-package:company-irony-c-headers
- doom-package:flycheck-irony
- doom-package:helm-rtags if doom-module::completion helm
- doom-package:irony
- doom-package:irony-eldoc
- doom-package:ivy-rtags if doom-module::completion ivy
- doom-package:rtags
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.
- If doom-module:+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
: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?
- Enable this module.
- Enable the
+lsp
flag for the appropriate modules you want LSP support for (e.g.:lang (python +lsp)
or:lang (rust +lsp)
), - 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.
- 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
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
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
(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
(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
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?