Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate Cquery #208

Closed
tomv564 opened this issue Nov 17, 2017 · 4 comments
Closed

Evaluate Cquery #208

tomv564 opened this issue Nov 17, 2017 · 4 comments

Comments

@tomv564
Copy link
Contributor

tomv564 commented Nov 17, 2017

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?

@papadokolos
Copy link

papadokolos commented Jan 27, 2018

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,
        }
    },

@tomv564
Copy link
Contributor Author

tomv564 commented Feb 11, 2018

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

@tomv564
Copy link
Contributor Author

tomv564 commented Feb 11, 2018

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

@tomv564
Copy link
Contributor Author

tomv564 commented Feb 11, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants