/ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting

Primary LanguageC++Apache License 2.0Apache-2.0

Ccls, which originates from cquery, is a C/C++/Objective-C language server.

It has a global view of the code base and support a lot of cross reference features It starts indexing the whole project (including subprojects if exist) concurrently when you open the first file, while the main thread can serve requests before the indexing is complete. Saving files will incrementally update the index.

improvement

  • {hoverProvider completionProvider,codeActionProvider} option in initializationOptions
{
    "initializationOptions": {
        "client": {
            "snippetSupport": true,
            "hoverProvider": false,
            "completionProvider": false,
            "referencesProvider": false,
            "definationProvider": false,
            "codeActionProvider": false
        },
        "clang": {
            "extraArgs": [
                "-std=c++20",
                "-Wall"
            ]
        }
    }
}

fix

  • type of code from int to std::string
struct Diagnostic {
    lsRange range;
    int severity = 0;
    int code = 0;              -> std::string code= "";
    std::string source = "ccls";
    std::string message;
    std::vector<DiagnosticRelatedInformation> relatedInformation;
    std::vector<TextEdit> fixits_;
};
  • cause clangd use code as type string , if you use ccls with clangd both as your language server, the codeaction will not work for ccls

  • but ccls standalone could be ok !!! so different with #395

  • below is the message sent by coc.nvim ( a vim language client )

{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "textDocument/codeAction",
    "params": {
        "textDocument": {
            ...
        },
        "range": {
            ...
        },
        "context": {
            "diagnostics": [
                {
                    "severity": 1,
                    "code": 2,
                    "source": "ccls",
                },
                {
                    "code": "no_member_suggest",
                    "severity": 1,
                    "source": "clang"
                }
            ],
        }
    }
}

ccls can index itself (~180MiB RSS when idle, noted on 2018-09-01), FreeBSD, glibc, Linux, LLVM (~1800MiB RSS), musl (~60MiB RSS), ... with decent memory footprint.