1# Clangd remote index
2
3Clangd uses a global index for project-wide code completion, navigation and
4other features.  For large projects, building this can take many hours and
5keeping it loaded uses a lot of memory.
6
7To relieve that burden, we're building remote index — a global index
8served on a different machine and shared between developers. This directory
9contains code that is used as Proof of Concept for the upcoming remote index
10feature.
11
12## Building
13
14This feature uses gRPC and Protobuf libraries, so you will need to install them.
15There are two ways of doing that.
16
17However you install dependencies, to enable this feature and build remote index
18tools you will need to set this CMake flag — `-DCLANGD_ENABLE_REMOTE=On`.
19
20### System-installed libraries
21
22On Debian-like systems gRPC and Protobuf can be installed from apt:
23
24```bash
25apt install libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc
26```
27
28### Building from sources
29
30Another way of installing gRPC and Protobuf is building from sources using
31CMake (we need CMake config files to find necessary libraries in LLVM). The
32easiest way of doing that would be to choose a directory where you want to
33install so that the installation files are not copied to system root and you
34can easily uninstall gRPC or use different versions.
35
36```bash
37# Get source code.
38$ git clone -b v1.36.3 https://github.com/grpc/grpc
39$ cd grpc
40$ git submodule update --init
41# Choose directory where you want gRPC installation to live.
42$ export GRPC_INSTALL_PATH=/where/you/want/grpc/to/be/installed
43# Build and install gRPC to ${GRPC_INSTALL_PATH}
44$ mkdir build; cd build
45$ cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release ..
46$ make install
47```
48
49This [guide](https://github.com/grpc/grpc/blob/master/BUILDING.md) goes into
50more detail on how to build gRPC from sources.
51
52By default, CMake will look for system-installed libraries when building remote
53index tools so you will have to adjust LLVM's CMake invocation. The following
54flag will inform build system that you chose this option —
55`-DGRPC_INSTALL_PATH=${GRPC_INSTALL_PATH}`.
56
57## Running
58
59You can run `clangd-index-server` and connect `clangd` instance to it using
60`--remote-index-address` and `--project-root` flags.
61