Skip to content
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

LSP Activates On Workspace Files, LSP Document Open/Close #1879

Merged
merged 10 commits into from
Sep 18, 2024

Conversation

thecoolwinter
Copy link
Collaborator

@thecoolwinter thecoolwinter commented Sep 12, 2024

Description

Main changes:

  • Reworks the LanguageServer type to use the existing workspace file management system.
  • Initializes servers when code files are opened in a workspace where there's no server running.
  • Shuts down servers when a workspace is closed.

Misc details:

  • Updates some LanguageServer methods to read more like sentences. Eg: instead of server.requestDocumentHighlight(document: document) an API consumer would read server. requestHighlight(for: document)
  • Updates the language server methods to have consistent error logging and catching. This was discussed on Discord.
  • Raises the language detection from the editor UI to the CodeFileDocument class. A new method getLanguage() guesses the language for the document unless it has been overriden.
  • Adds a LazyService dep injection property wrapper that is the same as Service but evaluates the service lazily. See usage.
  • Consolidates URL extensions to one folder.
  • Changes the LanguageServer struct to a class. It's a long-living value that we'll need to reference in things like a text coordinator so a class makes more sense here. @FastestMolasses and I have had a bit of a back and forth on this. Originally it was made a struct to make async/await easier. So I investigated making it Sendable to fulfill that goal. However it needs to manage state like opened files, which breaks the immutability of sendable values.

Related Issues

N/A

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

austincondiff
austincondiff previously approved these changes Sep 14, 2024
Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real solid work @thecoolwinter! 👍

Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR! 🎉 Just a few updates needed in the docs 👍

austincondiff
austincondiff previously approved these changes Sep 16, 2024
@thecoolwinter
Copy link
Collaborator Author

Sorry @austincondiff need another approval, fixed a failing test related to a subtle bug in #1840.

@thecoolwinter thecoolwinter mentioned this pull request Sep 17, 2024
6 tasks
Copy link
Contributor

@matthijseikelenboom matthijseikelenboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress! Left some a small amount of comments

0xWDG
0xWDG previously approved these changes Sep 18, 2024
Copy link
Collaborator

@0xWDG 0xWDG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i agree with the points of @matthijseikelenboom

@thecoolwinter
Copy link
Collaborator Author

Tracking issue for the commented-out event and notification handlers: #1888

@thecoolwinter thecoolwinter added the language server Issues or Pull Requests related to language servers. label Sep 18, 2024
@thecoolwinter thecoolwinter merged commit b140b5c into CodeEditApp:main Sep 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language server Issues or Pull Requests related to language servers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants