-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
helix-lsp-types: Replace url::Url
type with String wrapper
#11889
Draft
the-mikedavis
wants to merge
6
commits into
master
Choose a base branch
from
string-lsp-url
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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;`. It's the same type currently but will diverge in the child commits and this refactor makes that change simpler.
This seems to be a historical artifact in `lsp_types` - we can use a regular `use` statement to pull in the `bitflags!` macro rather than an external crate definition. This fixes rust-analyzer's ability to find the macro at least on rust-analyzer 2024-02-26.
the-mikedavis
added
C-enhancement
Category: Improvements
A-language-server
Area: Language server client
S-waiting-on-review
Status: Awaiting review from a maintainer.
labels
Oct 14, 2024
the-mikedavis
force-pushed
the
string-lsp-url
branch
from
October 14, 2024 22:35
70eb8b4
to
fd24a19
Compare
These functions return `Result<Self, ()>` in the `url` crate but the result is unnecessary since the functions never return the error branch. We can eliminate the Result to remove some `expect`s in the calling code.
the-mikedavis
force-pushed
the
string-lsp-url
branch
from
October 14, 2024 23:25
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-language-server
Area: Language server client
C-enhancement
Category: Improvements
S-waiting-on-review
Status: Awaiting review from a maintainer.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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