grumpypants
grumpypants6mo ago

Any way for VS Code to auto-complete library subdirectory in import?

Is there any way for VS Code to suggest subdirectory in a package (especially for npm package) when importing? I find it a bit tricky to need to look up the package documentation every time I need to import from a different subdirectory. Thank you!
No description
1 Reply
Deno AI Helper
Deno AI Helper6mo ago
Yes, the Deno extension for Visual Studio Code provides IntelliSense, which includes auto-completion for module names and their subdirectories. This feature is particularly useful for deno.land/x imports, where it can suggest module names, their versions, and their full directory listing without actually downloading the module source code. This is powered by the recent updates to deno.land/x. For npm packages, when you import a module, the extension will offer suggestions to complete the import, including local relative files and any cached remote files. Additionally, there have been improvements in the language server that integrate documentation information into the display text and hover-over information for imports. This means that third-party module authors can provide documentation that will be available directly in the editor. To ensure that you get these completions, make sure that the deno.suggest.imports.hosts setting in your editor is configured to enable https://deno.land for completions. The Deno language server will also attempt to auto-discover if a server supports completion suggestions and prompt you to enable it if it's not already configured. Here's a snippet from the documentation regarding the configuration for module registry completions:
{
"deno.suggest.imports.hosts": {
"https://deno.land": true
}
}
{
"deno.suggest.imports.hosts": {
"https://deno.land": true
}
}
By enabling this setting, you should be able to get auto-completion suggestions for subdirectories within a package. 🦕