vscode-clangd
vscode-clangd copied to clipboard
Suggestion for improved allCommitCharacters workaround
See this code:
https://github.com/clangd/vscode-clangd/blob/cee0726d4616d500a5989c28cbcb6a8ab08bef9f/src/clangd-context.ts#L118-L123
However, that codepath is skipped if serverCompletionRanking is disabled:
https://github.com/clangd/vscode-clangd/blob/cee0726d4616d500a5989c28cbcb6a8ab08bef9f/src/clangd-context.ts#L110-L111
and it prevents setting commitCharacters on individual responses if you do have a valid use case in the future.
an alternative is to remove allCommitCharacters from the server capabilities with something like this:
class AllCommitCharactersFixFeature implements StaticFeature {
preInitialize(capabilities: ServerCapabilities<unknown>): void {
const completionProvider = capabilities?.completionProvider;
if (completionProvider?.allCommitCharacters != null) {
delete completionProvider.allCommitCharacters;
}
}
getState(): FeatureState {
return {kind: 'static'};
}
fillClientCapabilities(): void {
// nothing to do
}
initialize(): void {
// nothing to do
}
dispose(): void {
// nothing to do
}
}
...
client.registerFeature(new AllCommitCharactersFixFeature());
you could even look for the specific list set by older versions, so future versions could still use allCommitCharacters.
Just to make sure I understand: is there a motivation for the proposed change beyond enabling potential future changes?
I think it's broken (skipped) if you disable serverCompletionRanking, but otherwise no, not really necessary. Just a suggestion