-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Generate server methods based on lsprotocol
type definitions
#489
Conversation
368fbb3
to
5ad2d52
Compare
Added an initial draft of the migration guide, there are a few more changes we can make (e.g. removing deprecated methods) so I expect it will take a few more revisions to get right. So this should be ready for a review now. That said, the lint job has started failing and I'm not entirely sure why...
|
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.
Such great work again ❤️ So many improvements, detailed docs and fixing old issues 💪
Do the new docs get automatically published on merge to main? I can't remember now. It might be good to have an update in our main README about how we're looking for beta testers for the breaking changes and a link to the migration docs?
scripts/check_client_is_uptodate.py
Outdated
"2. Commit" | ||
( | ||
"🔴 Pygls client or server not up to date\n" | ||
"1. Re-generate with: `poetry run poe generate_client`\n" |
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.
It's generate_client_server
now right?
pyproject.toml
Outdated
@@ -58,7 +58,7 @@ ruff = "ruff check ." | |||
mypy = "mypy -p pygls" | |||
check_generated_client = "python scripts/check_client_is_uptodate.py" | |||
check_commit_style = "npx commitlint --from origin/main --to HEAD --verbose --config commitlintrc.yaml" | |||
generate_client = "python scripts/generate_client.py --output pygls/lsp/client.py" | |||
generate_client = "python scripts/generate_client_server.py pygls/lsp" |
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.
Should we rename the command to generate_client_server
?
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've renamed it and the script to generate_code
- seems to complement the check_generated_code_is_uptodate.py
script?
scripts/check_client_is_uptodate.py
Outdated
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.
Should we rename this to check_generated_code_is_uptodate.py
?
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.
Done
I have a PR for the failing CI issue: #491 |
Similarly to the `BaseLanguageClient` this commit now introduces a `BaseLanguageServer` with methods automatically generated from type definitions provided by `lsprotocol`
This commit refactors the `LanguageServer` class to be based on the new `BaseLanguageServer`. The server has also been moved into the `pygls.lsp` module in an attempt to be more consistent with the client side code. It also takes the opportunity to tidy a few things up - Pushing generic server features such as error reporting and feature registration down into the base `Server` class - Removing LSP specific quirks from the base class e.g. `TextDocumentSyncKind` - Renames `server.lsp` to `server.protocol` to align better with the client code
5ad2d52
to
68eb120
Compare
Yes, https://pygls.readthedocs.io/en/latest/ points to
I've added a note to the README, though there are a few more changes we should make before shouting too loudly about it :) |
68eb120
to
f043d9a
Compare
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.
Nice! LGTM 🚀
#487 introduced some breaking changes, so this PR is taking the opportunity to make a few more that were going to be part of #418.
Similar to the
BaseLanguageClient
, this PR updates the code generation script to now also produce aBaseLanguageServer
with all the server side methods generated based on the type definitions provided bylsprotocol
Not only does this improve consistency and remove the need for the duplicated methods on the
LanguageServerProtocol
class (Closes #306), we also get all the server side methods we were missing!Aside from the obvious naming/argument changes, this also introduces the following changes (which we will need to document in a migration guide)
server.progress
now sends a$/progress
notification, rather than giving access to pygls'Progress
helper. The helper is now accessed viaserver.work_done_progress
server.protocol
rather thanserver.lsp
.Finally, the base
Server
class has been tidied up a littlesync_kind
)report_server_error
code has been pushed down into the basefeature
,thread
andcommand
registration code has been pushed down into the baseTODO
lsprotocol
v2024.0.0a2 #487Code review checklist (for code reviewer to complete)
Automated linters
You can run the lints that are run on CI locally with: