vscode_deno icon indicating copy to clipboard operation
vscode_deno copied to clipboard

feat: Support IntelliSense autocomplete for valid registries when using import map specifiers

Open jsejcksn opened this issue 1 year ago • 4 comments

I would like to see IntelliSense autocompletion for imports from valid registries when those registries have been mapped to arbitrary specifiers using an import map.

I'm aware that this issue is being tracked in the CLI repo in regard to LSP support at this issue. I'm creating an issue here in this repo specifically for tracking behavior about the extension in VS Code, and to document the current behavior (below).

I have an example directory structure like this:

% ls -AF
.vscode/		import_map.json
deno.jsonc		main.ts

% cat .vscode/settings.json 
{
  "deno.enable": true
}

% cat deno.jsonc 
{
  "importMap": "./import_map.json"
}

% cat import_map.json 
{
  "imports": {
    "std/": "https://deno.land/[email protected]/"
  }
}

% cat main.ts 

% deno --version
deno 1.28.2 (release, x86_64-apple-darwin)
v8 10.9.194.1
typescript 4.8.3

If I open the directory as a workspace in VS Code, and then open the file main.ts in an editor tab, and begin to type an import statement which uses the full URL for the standard library specifier in the import map, I get IntelliSense autocompletions. Here's a screenshot example to illustrate:

Screen Shot 2022-11-29 at 03 29 48

However, If I try to use the import map specifier for the same registry, the IntelliSense does not provide autocompletions beyond the specifier itself. It is aware that the mapped specifier exists:

Screen Shot 2022-11-29 at 03 31 16

But doesn't provide any further suggestions:

Screen Shot 2022-11-29 at 03 31 47

Further observations:

If I type out the complete path for a valid module in the registry using the literal URL, the module is cached as soon as I stop typing, without even needing to save the file:

Screen Shot 2022-11-29 at 03 37 04

But when using the import map specifier path to a module, I get a diagnostic signal (red wavy underlines) with conflicting information in the quick info box — it states that the dependency is resolved, but also that it is uncached or missing:

Screen Shot 2022-11-29 at 03 39 15

I must manually save the file and invoke the palette command "Deno: Cache Dependencies" in order to resolve the diagnostic issue:

Screen Shot 2022-11-29 at 03 40 29

I would, of course, like to see this behavior for export statements as well.


Related:

  • https://github.com/denoland/vscode_deno/issues/348
  • https://github.com/denoland/deno/issues/10951
  • https://github.com/denoland/deno/issues/11168
  • https://github.com/denoland/deno/issues/16805

jsejcksn avatar Nov 29 '22 09:11 jsejcksn

@jsejcksn do you still experience this problem with Deno v1.35? I believe this has been fixed.

bartlomieju avatar Jul 11 '23 00:07 bartlomieju

@jsejcksn do you still experience this problem with Deno v1.35? I believe this has been fixed.

@bartlomieju Sure: I'll budget some time today to test and report back here.

jsejcksn avatar Jul 11 '23 13:07 jsejcksn

@bartlomieju It now appears that autocompletion doesn't work at all with import map specifiers (except for modules that have been resolved in the same language server session?)

I recorded a screen capture of a basic test (attached to the bottom of this message), and here's text output of the files and software versions:

% ls -AF
.vscode/		import_map.json
deno.jsonc		main.ts

% cat .vscode/settings.json
{
  "deno.enable": true
}

% cat deno.jsonc
{
  "importMap": "./import_map.json"
}

% cat import_map.json
{
  "imports": {
    "std/": "https://deno.land/[email protected]/"
  }
}

% cat main.ts

% code --version
1.80.0
660393deaaa6d1996740ff4880f1bad43768c814
arm64

% code --list-extensions --show-versions | grep "deno"
[email protected]

% deno --version
deno 1.35.0 (release, aarch64-apple-darwin)
v8 11.6.189.7
typescript 5.1.6

https://github.com/denoland/vscode_deno/assets/868251/abfe12ff-a60b-4ea9-802b-81d462608f43

jsejcksn avatar Jul 11 '23 18:07 jsejcksn

@dsherret could you take a look here?

bartlomieju avatar Jul 11 '23 20:07 bartlomieju