From e50b1966719bf6b16cbabdc337a8d8f8b7094a0b Mon Sep 17 00:00:00 2001 From: Mikael Lund Date: Tue, 23 Jul 2024 10:32:09 +0200 Subject: [PATCH] Add zed and clangd config --- .clangd | 3 +++ .zed/settings.json | 18 ++++++++++++++++++ docs/_docs/install.md | 11 ++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .clangd create mode 100644 .zed/settings.json diff --git a/.clangd b/.clangd new file mode 100644 index 000000000..5deb0ab2a --- /dev/null +++ b/.clangd @@ -0,0 +1,3 @@ +CompileFlags: + CompilationDatabase: "build/" + diff --git a/.zed/settings.json b/.zed/settings.json new file mode 100644 index 000000000..23d65eaa8 --- /dev/null +++ b/.zed/settings.json @@ -0,0 +1,18 @@ +// Folder-specific settings +// +// For a full list of overridable settings, and general information on folder-specific settings, +// see the documentation: https://zed.dev/docs/configuring-zed#folder-specific-settings +{ + "languages": { + "C++": { + "tab_size": 4, + "formatter": { + "external": { + "command": "clang-format", + "arguments": ["{buffer_path}"] + } + }, + "format_on_save": "off" + } + } +} diff --git a/docs/_docs/install.md b/docs/_docs/install.md index c4b6f200f..73ef03c95 100644 --- a/docs/_docs/install.md +++ b/docs/_docs/install.md @@ -176,7 +176,7 @@ To force a specific location, use `-DZLIB_ROOT=...` in a clean build directory. We recommend to use an IDE or text editor that respect the provided `.clang-format` which will ease merging changes into the codebase, see below. -For Visual Studio Code (VSC) users, it is very easy to setup a development environment using Docker and +For Visual Studio Code (VSC) users, it is easy to setup a development environment using Docker and [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers): ~~~ bash @@ -186,6 +186,15 @@ code . (when asked, select "open in devcontainer", assuming you have Docker running) +## Clangd + +For editors with `clangd` support, we provide a `.clangd` configuration file. +This looks for a CMake generated `build` path that should contain +`compile_commands.json`. +If you use a custom build directory, simply create a symlink called `build` +in the project root. +If your build directory doesn't contain `compile_commands.json`, you can create +one with the CMake argument `-DCMAKE_EXPORT_COMPILE_COMMANDS=on`. ## Code Style