jdorfman / lsif-clang

Language Server Indexing Format (LSIF) generator for C, C++ and Objective C

Home Page:https://lsif.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lsif-clang indexer Status: Development

GIF displaying usage on the linux kernel.

This project is a fork of clangd with patches to add support for outputting LSIF indexes. Specifically, a fork of the llvm-project repo with a new tool lsif-clang under the clang-tools-extra subdirectory and patches to files under clang-tools-extra/clangd. There's more info about the repo structure and its history in the Forking Strategy doc.

This project has only been tested extensively on C++ projects and C projects, but Objective C projects should both be supported as well following the same instructions. See the compatibility page for more detailed information about which kinds of projects are supported.

Alternatives for C++ Projects

If you can't get lsif-clang working with your project, first file an issue! We want this to work everywhere. But the C++ ecosystem is fragmented, and it's possible that your project simply won't play nice with the clang toolchain. lsif-cpp is also available, which acts as a plugin for arbitrary C++ compilers and might therefore be compatible. Unfortunately, it has several major defects compared to lsif-clang (it is much slower and does not provide hovers), and is not the recommended option.

Usage

Follow the installation instructions to get the tool set up, then the compilation database instructions to generate a compilation database. Then run

lsif-clang compile_commands.json

If you get missing header warnings (common on MacOS), you can try

lsif-clang --extra-arg="-resource-dir=$(clang -print-resource-dir)" compile_commands.json

If you are still missing headers, there's likely an error in the way the compilation database was set up, or some generated code that's necessary for C++ compilation hasn't been output yet.

See the examples of producing LSIF indexes for a variety of OSS repositories to help troubleshoot.

Testing the output

You can use the lsif-validate tool for basic sanity checking, or upload the index to a Sourcegraph instance to see the hovers, definitions, and references in action.

About

Language Server Indexing Format (LSIF) generator for C, C++ and Objective C

https://lsif.dev/


Languages

Language:C++ 45.3%Language:LLVM 29.5%Language:C 10.9%Language:Assembly 10.3%Language:Python 1.3%Language:Objective-C 0.7%Language:MLIR 0.5%Language:CMake 0.4%Language:HTML 0.3%Language:Objective-C++ 0.2%Language:Fortran 0.1%Language:Cuda 0.1%Language:OCaml 0.1%Language:Perl 0.1%Language:Shell 0.0%Language:Scilab 0.0%Language:Go 0.0%Language:Awk 0.0%Language:JavaScript 0.0%Language:Makefile 0.0%Language:CSS 0.0%Language:Roff 0.0%Language:Emacs Lisp 0.0%Language:Julia 0.0%Language:Pawn 0.0%Language:Batchfile 0.0%Language:Cool 0.0%Language:C# 0.0%Language:Vim Script 0.0%Language:Dockerfile 0.0%Language:M 0.0%Language:NASL 0.0%Language:SWIG 0.0%Language:GDB 0.0%Language:TypeScript 0.0%Language:Common Lisp 0.0%Language:TeX 0.0%Language:AppleScript 0.0%Language:SourcePawn 0.0%Language:Pascal 0.0%Language:RenderScript 0.0%Language:Starlark 0.0%Language:DTrace 0.0%Language:PHP 0.0%Language:Swift 0.0%Language:Rust 0.0%Language:Lua 0.0%Language:POV-Ray SDL 0.0%