/lsif-cpp

Language Server Index Format (LSIF) generator for C++

Primary LanguageC++

C/C++ LSIF indexer

Visit https://lsif.dev/ to learn about LSIF.

Installation

Required tools:

  • Node.js
  • Yarn
  • make
  • A C++ compiler with LLVM dev headers (versions 3 through 9 are supported)

macOS

brew install git node llvm@8
npm i -g yarn

Ubuntu 18.04

apt-get update && apt-get install -y git nodejs npm clang libclang-dev llvm
npm i -g yarn

Build the C++ compiler plugin and the LSIF conversion tool:

git clone https://github.com/sourcegraph/lsif-cpp
cd lsif-cpp
./build

Indexing your repository

Compile a C/C++ project with the instrumented compiler to generate intermediate CSV output:

env \
  CLEAN=true \
  ABSROOTDIR=$PWD/examples/cross-app/root \
  ABSOUTDIR=$PWD/examples/cross-app/output \
  <path to lsif-cpp>/generate-csv "\$CXX -c *.cpp"
  • ABSROOTDIR: the absolute path to your project directory (the script will cd here before running the compilation command)
  • ABSOUTDIR: the absolute path to the directory where the generated CSV files will be written

Convert those CSV files into LSIF:

node \
  <path to lsif-cpp>/out/main.js \
  --csvFileGlob="examples/cross-app/output/*.csv" \
  --root=examples/cross-app/root \
  --out examples/cross-app/root/dump.lsif
  • --csvFileGlob: the wildcard pattern that matches all CSV files written to ABSOUTDIR by the generate-csv command
  • --root: the path to ABSROOTDIR
  • --out: the path where the LSIF dump will be written