Lsp: Evaluate Cquery

Created on 17 Nov 2017  路  4Comments  路  Source: sublimelsp/LSP

https://github.com/jacobdufault/cquery/#cquery

Easier to compile than doing the full clang checkout + build to get clangd
Maybe have some nice solutions for extra compiler flags etc?

Most helpful comment

I was able to make it work by adding this to LSP.sublime-settings:

__Note:__ It required a few restarts until it actually worked, and it is very unstable. It seems like the communication between the client and the server is not fully right.

"clients":
{
    "cquery":
    {
        "command": ["cquery", "--language-server"],
        "scopes": ["source.c", "source.c++", "source.objc", "source.objc++"],
        "syntaxes": ["Packages/C++/C.sublime-syntax", "Packages/C++/C++.sublime-syntax", "Packages/Objective-C/Objective-C.sublime-syntax", "Packages/Objective-C/Objective-C++.sublime-syntax"],
        "languageId": "c++",
        "initializationOptions":
        {
            "cacheDirectory": "/tmp/cquery",
            "cacheFormat": "msgpack",
            "completion":
            {
                "filterAndSort": false
            },
            "indexerCount": 0,
            "index":
            {
                "comments": 2,
            },
            "progressReportFrequencyMs": -1,
        }
    },

All 4 comments

I was able to make it work by adding this to LSP.sublime-settings:

__Note:__ It required a few restarts until it actually worked, and it is very unstable. It seems like the communication between the client and the server is not fully right.

"clients":
{
    "cquery":
    {
        "command": ["cquery", "--language-server"],
        "scopes": ["source.c", "source.c++", "source.objc", "source.objc++"],
        "syntaxes": ["Packages/C++/C.sublime-syntax", "Packages/C++/C++.sublime-syntax", "Packages/Objective-C/Objective-C.sublime-syntax", "Packages/Objective-C/Objective-C++.sublime-syntax"],
        "languageId": "c++",
        "initializationOptions":
        {
            "cacheDirectory": "/tmp/cquery",
            "cacheFormat": "msgpack",
            "completion":
            {
                "filterAndSort": false
            },
            "indexerCount": 0,
            "index":
            {
                "comments": 2,
            },
            "progressReportFrequencyMs": -1,
        }
    },

Found a homebrew formula here which installed at first try: https://github.com/twlz0ne/homebrew-cquery

Wow, this worked really well!

I believe the --language-server option has been default for a few days now, but your config example was a perfect guide to solving the only snag:

The initializationOptions must specify a cacheDirectory or the server will exit at initialisation.

I tried these options together with log_stderr set to true in LSP's settings.

    "cquery": {
      "command": ["cquery", "--log-all-to-stderr"],
      "scopes": ["source.c", "source.c++", "source.objc", "source.objc++"],
      "syntaxes": ["Packages/C++/C.sublime-syntax", "Packages/C++/C++.sublime-syntax", "Packages/Objective-C/Objective-C.sublime-syntax", "Packages/Objective-C/Objective-C++.sublime-syntax"],
      "languageId": "objc++",
      "initializationOptions":
      {
          "cacheDirectory": "/tmp/cquery",
      }
    },

@papadokolos, regarding the issue you created to integrate cquery - I can help you set up a package that implements the extra LSP extensions (like $cquery/progress).

An example of how to plug in extra functionality exist for the Rust language server here: https://github.com/tomv564/LSP-rust

Closing as cquery appears to be working with LSP with the above configuration.

Was this page helpful?
0 / 5 - 0 ratings