-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
helix-lsp-types: Replace url::Url
type with String wrapper
#11889
base: master
Are you sure you want to change the base?
Conversation
fd24a19
to
57a18e2
Compare
Hi, correct me if I'm wrong, but RFC3986 defines URIs, why are we using a URL crate for lsp URIs? I think that contributes to issues such as #11334 . EDIT: maybe this is what this PR fixes? |
Exactly - this PR is working towards removing the url crate as a dependency and representing the URIs from language servers with a regular |
This is a cosmetic change to replace all direct `use`s of the `url::Url` type in the `helix-lsp-types` crate with `use crate::Url;`. The types are the same type currently: this refactor will make a future replacement of the Url type less noisy. Connects #11889
Internally the LSP client should hold workspace folders as paths. Using URLs for this type is inconvenient (since we compare it to paths) and might cause mismatches because of URLs not being normalized. The URLs must be paths anyways so we can convert these types lazily when we need to send them to a server.
57a18e2
to
61491af
Compare
This is a cosmetic change to replace all direct `use`s of the `url::Url` type in the `helix-lsp-types` crate with `use crate::Url;`. The types are the same type currently: this refactor will make a future replacement of the Url type less noisy. Connects helix-editor#11889
This is a cosmetic change to replace all direct `use`s of the `url::Url` type in the `helix-lsp-types` crate with `use crate::Url;`. The types are the same type currently: this refactor will make a future replacement of the Url type less noisy. Connects helix-editor#11889
Something I did notice in other work was the conversion of a url to a uri, Not sure if the changes here will help the need for a conversion, mainly the need to normalize, or if this is entirely unavoidable, but thought I'd share at least. If there is a way to check beforehand that it is normalized, like some kind of fast bloom filter-like check, or modeling a just-in-time conversion for when paths are actually used, rather than an ahead-of-time conversion, this could be a big area of improvement. This seems to happen most in the publish diagnostics hot path: helix/helix-term/src/application.rs Lines 746 to 753 in 3531760
|
I'm not 100% sure we can avoid normalizing paths with this change. I imagine that a language server wouldn't send the same file as two different paths (for example |
This is a cosmetic change to replace all direct `use`s of the `url::Url` type in the `helix-lsp-types` crate with `use crate::Url;`. The types are the same type currently: this refactor will make a future replacement of the Url type less noisy. Connects helix-editor#11889
This replaces the use of the
url::Url
type with a newtype wrapper around aString
. Changing URL type was the original motivation of vendoring/forking thelsp_types
crate in #11355. Theurl
crate is based on the WHATWG spec for URLs which conflicts with the spec that LSP requires - RFC3986. This change uses the RFC3986 reserved characters for encoding paths which should fix some issues like #11888. The parsing and interpretation of the URL as a path is then covered byUrl::try_from
which we use ubiquitously since #11486.Fixes #11888