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

Please add an option to disable auto-completion like any other plugins #588

Closed
lhmouse opened this issue Mar 3, 2024 · 10 comments · Fixed by #591
Closed

Please add an option to disable auto-completion like any other plugins #588

lhmouse opened this issue Mar 3, 2024 · 10 comments · Fixed by #591
Assignees
Labels
enhancement New feature or request

Comments

@lhmouse
Copy link

lhmouse commented Mar 3, 2024

This follows #390 (comment) by @HighCommander4, but details about the current behavior are #390 (comment) by @MK-Alias (and thanks for the screenshots!).

I have a habit of typing the immediate ( after the name of a function. Because vscode-clangd auto-completes it, I always have to remember to backspace my own parenthesis. This behavior is inconsistent with any other editor or IDE, and I am too stupid to get rid of my habit, so please provide an option to disable it. Thanks in advance.

@lhmouse lhmouse added the enhancement New feature or request label Mar 3, 2024
@HighCommander4
Copy link
Contributor

To clarify, are you looking for an option to disable code completion altogether, or an option to disable the insertion of ( when accepting a function completion specifically?

@lhmouse
Copy link
Author

lhmouse commented Mar 3, 2024

To clarify, are you looking for an option to disable code completion altogether, or an option to disable the insertion of ( when accepting a function completion specifically?

I am looking for the former.

Of course, the root of the issue is the latter, but it's bundled in clangd itself. I have seen the other issue at llvm/llvm-project#63565, and I believe it would take years to finally land into, for example, Debian stable APT repositories. On the other hand, vscode extensions can be much more actively updated.

@HighCommander4
Copy link
Contributor

Thanks for clarifying.

(Not sure if it's relevant in your use case, but LLVM does have a set of APT packages (including a clangd package) that are updated daily at https://apt.llvm.org.)


Since you wrote earlier:

Please add an option to disable auto-completion like any other plugins

could you give an example of another plugin (especially an LSP client plugin) which has this kind of option?

@lhmouse
Copy link
Author

lhmouse commented Mar 3, 2024

(Not sure if it's relevant in your use case, but LLVM does have a set of APT packages (including a clangd package) that are updated daily at https://apt.llvm.org.)

Thanks for the information. I can try it.

could you give an example of another plugin (especially an LSP client plugin) which has this kind of option?

The Microsfot C/C++ extension has an option to disable C/C++ auto-completion:
73452

The 'C/C++ Clang Command Adapter' extension also has such an option; however it parses clang output directly, instead of using a language server:
73453

@HighCommander4
Copy link
Contributor

Thanks. I checked the implementation of this option in vscode-cpptools (the server is proprietary but the client's source code is available). It looks like it's implemented on the server side; the value of the checkbox is just propagated to the server in the initialization options. (And I'm guessing it has the effect of the server sending an empty response to completion requests?)

So, if vscode-clangd used a simlar implementation, you would still need an updated server for the option to work.

I think it would be better to have a way of implementing the option entirely on the client side, but it's not clear to me how to accomplish this with the vscode-languageclient API.

(I looked at the vscode-clang plugin as well. There, the option is implemented entirely on the client side, but since this plugin does not use the LSP, it uses a different API surface than LSP plugins, so I don't think the way it does things is applicable to vscode-clangd.)

@lhmouse
Copy link
Author

lhmouse commented Mar 4, 2024

I know almost nothing about LSP; am I correct to say that auto-completion is fully controlled by the server (and not the client), and if the server sends a completion response, there is nothing we can do on the client side?

@HighCommander4
Copy link
Contributor

I think it would be better to have a way of implementing the option entirely on the client side, but it's not clear to me how to accomplish this with the vscode-languageclient API.

Actually, I realized this can be done relatively easily using middleware.

@lhmouse
Copy link
Author

lhmouse commented Mar 4, 2024

it seems this has annoyed me again. is this the case for you?

I created this file:

#include <new>
using namespace std;

void
test()
  {
    
  }

Now, in test(), I typed return<space> and got

#include <new>
using namespace std;

void
test()
  {
    return_temporary_buffer( )
  }

wat? please do not auto-complete that for me.

It looks like this was because I set clangd.serverCompletionRanking to false. Solved now.

This was referenced Mar 6, 2024
HighCommander4 added a commit to HighCommander4/vscode-clangd that referenced this issue Mar 15, 2024
@HighCommander4
Copy link
Contributor

Proposed patch: #591

HighCommander4 added a commit to HighCommander4/vscode-clangd that referenced this issue Mar 15, 2024
@HighCommander4 HighCommander4 self-assigned this Mar 15, 2024
@lhmouse
Copy link
Author

lhmouse commented Mar 15, 2024

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants