Propose decoupling LanguageServerProtocol from SwiftPM dependency

I propose removing the implicit dependency on SwiftPM from the LanguageServerProtocol model in the project setup.

Even though LanguageServerProtocol is separated as a module today, it's still in the same package with other modules, like SourceKitLSP, meaning that when linking a LanguageServerProtocol module (which is nothing more than the LSP model ), SwiftPM tool fetches all the package dependencies (including those not used). That SwiftPM package dependency is fetched and included when solving dependencies, even tho unused, makes impossible to use a different version of SwiftPM package by the consumer package.

Example: Package A uses the module LanguageServerProtocol, but also depend on SwiftPM package from specific branch release/5.9 (or any other version). Because sourcekit-lsp package depends on SwiftPM on main branch, it is impossible to resolve the dependencies due to a conflict on the SwiftPM package versions (with an error message "... is required using two different revision-based requirements (release/5.9 and main), which is not supported").

I propose separate LanguageServerProtocol and LanguageServerProtocolJSONRPC to a separate package, apple/language-server-protocol and use it as a dependency for apple/sourcekit-lsp package. This way other packages can use LanguageServerProtocol without SwiftPM dependency (that itself bring many more dependencies to the plate).

thoughts? is it possible?

20 Likes

I just wanted to jump in here to say I'm pretty excited about the prospect of this happening. I currently maintain four language server protocol-related libraries, along with a protocol-agnostic JSONRPC library. If there is any interest, I would be very open to working together to unify these. For this to happen, I assume Apple would have to be owner for all SourceKit-LSP dependencies. I'm 100% into this.

I think it would be a huge win for the community if there could be one source of Swift LSP infrastructure.

9 Likes

cc @ahoppen

(FWIW as someone experimenting with the LSP protocol outside of SourceKit-LSP, I'd like to add a +1 to the request. Vendoring that module by users of the LSP protocol feels suboptimal, especially as it's occasionally updated after new versions of the protocol come out).

1 Like

I've made POC repository with extracted LanguageServerProtocol to separate package: GitHub - krzyzanowskim/language-server-protocol: Language Server Protocol

3 Likes

A unified infrastructure would indeed be fantastic.

+1, this would be really exciting for building other language servers in Swift.

For the repository name, I would probably go with swift-lsp or swift-language-server-protocol though, to follow the convention adopted by most other Swift packages.