-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(lsp): add registry import auto-complete #9934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken it for a spin locally. Some feedback:
- The sorting of modules is not great. When searching for
https://deno.land/x/s3
these are the results:
. The module that is exactly nameds3
is 5th place. - Completing on the final
/
inhttps://deno.land/x/s3@0.4.0/src/
will complete remote imports, not registry imports. - Completing on the final
d
inhttps://deno.land/x/s3@0.4.0/src/d
will complete all paths, not just ones starting with/src/d
- Accepting the
deps.ts
completion onhttps://deno.land/x/s3@0.4.0/src/d
will inserthttps://deno.land/x/s3@0.4.0/src/ddeps.ts
. - Completing in the middle of a specifier will set the cursor all the way to the end of the specifier.
Regarding the deno.suggest.imports.reloadCache
option: The v2 branch had http caching, and had a deno.resetRegistryCache
command. Maybe we could introduce that command instead of deno.suggest.imports.reloadCache
until #9931 lands?
Another remark: the autoDiscovery option seems to work differently in this version than it did in v2. In v2 when autoDiscovery was enabled, we would try fetch the manifest when we see it for the first time. We would do that at max every 24 hours. If we found a manifest we would prompt the user if they wanted completions from this registry or not. We would persist their response in the hosts
setting. In this version it seems autoDiscovery is not yet present. Maybe we should just disable that option for now?
Anyway, the core works and that is fantastic. It feels nice and snappy. Great feature to have :-)
use std::collections::HashSet; | ||
use std::path::Path; | ||
|
||
const CONFIG_PATH: &str = "/.well-known/deno-import-intellisense.json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const CONFIG_PATH: &str = "/.well-known/deno-import-intellisense.json"; | |
const CONFIG_PATH: &str = "/.well-known/deno-import-completions.json"; |
We should consider renaming this. IntelliSense is specifically a Microsoft term I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to land it without requiring existing registry providers to change anything. It is a Microsoft specific term, but it is a non-user facing bit of information, so... 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know it is just deno.land/x and x.lcas.dev that have it set up right now. I would rather fix it now than keeping the cruft around forever.
That is entirely a vscode thing. We can provide alternative sort text, but it is vscode that does it. There is a little interaction with what text you have typed during the completions that vscode is matching on, I will see if we can "clear" that before a commit char.
That is a bug, will look into that. I am having to restructure some of the path_to_regex stuff anyways that would allow us to complete each part of a path, part by part as well.
Ok, another bug... I think breaking the parts into components will help with that too...
I thought about that, the problem is that it isn't a "command" in the sense that we don't clear the cache, we change the cache setting in the file fetcher from
Yeah, I didn't understand that, let's get rid of it for now. |
56a3e29
to
0dc1702
Compare
Ok, I think I fixed most of the filtering/sorting issues and other stuff... |
0c9f4a7
to
505a624
Compare
Just tried it out again, and feels pretty damn great now. Just some minor comments:
I still think we should switch to a |
vscode is sorting them based on the label... I think I can fix that though.
Yeah, I am not sure any good way around that because we are using text edits in the return value to make sure the specifier is proper proper. |
Ok, I can fix that, but it is an all or nothing... either initially listed in the order it is returned from the server or it is "alphabetical"... the protocol doesn't have (yet) a way to indicate what sort of sorting to apply. So when I change it to server order, some of the other fields look "odd"... I am fine with use saying "it is up to the server" but some of return values of |
I would say for now the server should be authoritative regarding sorting, and later we can extend the registry manifest to decide what sorting to apply for each field. |
Actually most of the oddness was related to me converting the index of item into a string without padding it, so |
f3166dd
to
7a683b6
Compare
cf5f10b
to
c9da5d2
Compare
Ready for a proper review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks great. Tried it out again and found a few more things:
- completing at the end of specifier
https://deno.land/x
brings up "remote" completions, not "registry" completions - completing in an empty specifier does not bring up
https://deno.land
as completion. completing in a specifier with justh
does.
Once those are fixed this is good to land. In a follow up we should address the following:
- auto discovery of registries like in v2, with user popup
- respecting HTTP cache headers for completions and manifest
44b3202
to
a52d134
Compare
Ok, I think I have fixed both the issues you mentioned. Another thing for follow up is handling auto-completions with import maps, though that is more import completions, versus registry completions. |
I think that last round of fixes introduced a new error: completing at the end of |
a52d134
to
eaec5a9
Compare
@lucacasonato ok, that is fixed... added a regression test for it too... strange, it should have been broken all along, but I have made that all a bit more robust now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L. G. T. M. 💪
Thanks for enduring this long review processes. Fantastic feature, and incredibly well implemented. Such a pleasure to use. Let's level up this LSP 🚀
Still have a few things to do, but it is in enough of a shape to share.
This add the feature where by LSP clients can specify hosts where the LSP will attempt to retrieve a meta data file which describes how to create remote module specifier URLs for modules located on the server, and allows fetching of the completion items.