vscode-docs
vscode-docs copied to clipboard
Missing documentation for getDisposable
I want to build a VSCode extension for showing IntelliSense for design tokens for a UI library. More context on the use-case here.
I'm trying to understand how to do this with the Direct Implementation of "Show Code Completion Proposals" but the code example only mentions that we're supposed to use a getDisposable() function without any explanation of where to import this function from or what it's supposed to do if we've to write this on our own.
ctx.subscriptions.push(getDisposable());
https://code.visualstudio.com/api/language-extensions/programmatic-language-features#show-code-completion-proposals
Update: After a trip around multiple Google searches, I ended up reading this blog which mentioned the vscode-extension-samples repository is the right place to look for examples: https://tomassetti.me/integrating-code-completion-in-visual-studio-code/
Manually going through the list of samples, I found the completions-sample which finally helped me understand how to implement code completion.
Suggestions
- Add a link to the completions-sample in the Direct Implementation section of Show Code Completion Proposals. The relevant example for this shouldn't have been so difficult to find.
- Remove the
getDisposable()line from the code example shown in the docs. That line makes sense to me now after building an extension and I understand the intention is to show that devs are supposed to add something there that returns a disposable. However, that line is absolutely not necessary and creates more confusion than help. The very next line is completely sufficient to achieve code completion. - I'd also recommend replacing GO_MODE in the docs example with a string that mentions the actual language identifier. Without context, someone reading the docs would only assume GO_MODE is something that's available as an import in the VSCode api.