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

Default value of option completion.detailedLabel makes ccls unusable in lsp compliant implementations #318

Closed
agorgl opened this issue Mar 11, 2019 · 1 comment

Comments

@agorgl
Copy link

agorgl commented Mar 11, 2019

Using ccls with vim/vim-lsp by default we get non sensible autocompletion behavior compared to clangd.

Here is an example of ccls completion with a minimal setup:
image

As you can see the type of the member is also inserted into the buffer along with the name.
After lots of digging around I found out this is a side effect of the completion.detailedLabel
option, that as stated by the wiki does this:

When this option is enabled, label and detailed are re-purposed:

label: detailed function signature, e.g. foo(int a, int b) -> bool
detailed: the name of the parent context, e.g. in S s; s.<complete>, the parent context is S.

That though, is not compliant to the lsp specification as we can see on the official page and protocol interface snippets:
https://microsoft.github.io/language-server-protocol/specification

interface CompletionItem {
	/**
	 * The label of this completion item. By default
	 * also the text that is inserted when selecting
	 * this completion.
	 */
	label: string;
        ...
        /**
	 * A human-readable string with additional information
	 * about this item, like type or symbol information.
	 */
	detail?: string;

So this option, despite having some useful usage somewhere, I think that it should be disabled by default to avoid confusion with perfectly compliant lsp configurations.

After disabling this option I noticed another minor (cosmetic) issue bellow:

The default pattern in the detail value seems kinda verbose for no reason, for example:
image
The completion field is shown both in the label value (as it should) and in the detail value (excessive).

The same output from clangd for reference:
image

Link to the code that is relevant for the above:

out[i].label += (out[i].label == out[i].filterText ? " : " : " -> ");

@MaskRay
Copy link
Owner

MaskRay commented Mar 12, 2019

As you can see the type of the member is also inserted into the buffer along with the name.

The root cause is that the language client doesn't support CompletionItem.textEdit. ccls really requires it, otherwise the experience may be really bad. And I don't bother add compatibility code as insertText should really be deprecated.

So this option, despite having some useful usage somewhere, I think that it should be disabled by default to avoid confusion with perfectly compliant lsp configurations.

It may confuse some users but others actually think the alternative view is appealing and makes better use of the space. See jacobdufault/cquery#391 for the rationale.

The default pattern in the detail value seems kinda verbose for no reason, for example:

That is true, but the result doesn't look bad if detail is not always available, but instead shown as a tooltip when you select the completion item.

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