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

CCLS support / "complete_using_text_edit" #498

Closed
TheAifam5 opened this issue Jan 23, 2019 · 11 comments · Fixed by #524
Closed

CCLS support / "complete_using_text_edit" #498

TheAifam5 opened this issue Jan 23, 2019 · 11 comments · Fixed by #524

Comments

@TheAifam5
Copy link

TheAifam5 commented Jan 23, 2019

MaskRay/ccls#226

Currently

client->a

I get autocompletion like this: a : int tcp_client_s
After selecting that autocompletion the code looks like this:

client->a : int

OS and language server:

ArchLinux with ccls for C/C++/ObjC (git version installed a5f600a7)
https://github.com/MaskRay/ccls

How you installed LSP:

Package Control

Client configuration:

"ccls":
{
  "command":
  [
    "ccls"
  ],
  "initializationOptions":
  {
    "cacheDirectory": "/tmp/ccls"
  },
  "languages":
  [
    {
      "languageId": "c",
      "scopes":
      [
        "source.c"
      ],
      "syntaxes":
      [
        "Packages/C++/C.sublime-syntax"
      ]
    },
    {
      "languageId": "cpp",
      "scopes":
      [
        "source.c++"
      ],
      "syntaxes":
      [
        "Packages/C++/C++.sublime-syntax"
      ]
    },
    {
      "languageId": "objective-c",
      "scopes":
      [
        "source.objc"
      ],
      "syntaxes":
      [
        "Packages/Objective-C/Objective-C.sublime-syntax"
      ]
    },
    {
      "languageId": "objective-cpp",
      "scopes":
      [
        "source.objc++"
      ],
      "syntaxes":
      [
        "Packages/Objective-C/Objective-C++.sublime-syntax"
      ]
    }
  ]
}
@rwols
Copy link
Member

rwols commented Jan 24, 2019

So I tried the ccls server mentioned, and I get the same kind of completions. The ccls server sends textEdit in addition to a label for its completion items.

There is an easy fix for your problem. There's a "hidden" setting called complete_using_text_edit that will enable the functionality to prefer textEdit over label. Just put

	"complete_using_text_edit": true,

somewhere in your LSP preferences.

Some background reading: #368 #294

@TheAifam5
Copy link
Author

Definition, References, Rename functions does not work with CCLS.

@rwols
Copy link
Member

rwols commented Jan 24, 2019

Definition, References, Rename functions does not work with CCLS.

It does for me. Are you working with cmake? If so, you need to put a generated compile_commands.json file with cmake path/to/src -DCMAKE_EXPORT_COMPILE_COMMANDS=ON in the root of your source dir (something like ln -s compile_commands.json path/to/build/dir/compile_commands.json)

@TheAifam5
Copy link
Author

No. I’m working with meson and I softlinked the compile_commands.json to the root project too.

@TheAifam5
Copy link
Author

Oh, I needed to add the file to meson, build it (to generate new compile_commands.json) and then restart Sublime to get that working again.

@tomv564
Copy link
Contributor

tomv564 commented Jan 24, 2019

Ah right, so it sends label but no insertText. We should probably change complete_using_text_edit to be the default behaviour, ideally after adding some test coverage

@rwols
Copy link
Member

rwols commented Jan 24, 2019

Yeah. In fact, I think insertText is deprecated.

@CoolOppo
Copy link

Ah right, so it sends label but no insertText. We should probably change complete_using_text_edit to be the default behaviour, ideally after adding some test coverage

Has this happened yet? I just spent like a half hour trying to get ccls to work just to figure out that complete_using_text_edit breaks the LSP plugin now.

@rwols
Copy link
Member

rwols commented Feb 22, 2019

In what way does it break this plugin?

Has this happened yet?

No, but feel free to do so and make a pull request if it's urgent.

@rwols rwols changed the title CCLS support CCLS support / "complete_using_text_edit" Feb 22, 2019
@rwols
Copy link
Member

rwols commented Feb 23, 2019

@CoolOppo PR #524 makes the plugin prefer textEdit over insertText by default.

@CoolOppo
Copy link

Awesome, didn't see that. I deeply appreciate the hard work on this project, it literally is making my job (and life) so much better.

@rwols rwols closed this as completed in #524 Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants