A Language Server Protocol (LSP) implementation for Swift Package Manager's Package.swift manifest files.
Language server for Package.swift files that provides:
- Smart code completion for Package.swift manifest files:
- In
.package(...)
function:url:
argument with GitHub repository suggestionsfrom:
andexact:
arguments with version suggestionsbranch:
argument with available branch names
- In
.product(...)
function:name:
argument with available product suggestions from dependenciespackage:
argument with package name suggestions
- In
.target(...)
function:name:
argument with local target name suggestions from your package
- In target dependencies string literals:
- Product name completion that automatically expands to
.product(name: "ProductName", package: "PackageName")
format - Local target name completion for referencing targets within your package to
.target(name: "LocalTarget")
format
- Product name completion that automatically expands to
- In
Note
After editing package dependencies (.package(...)
), save the file for changes to be reflected in target completions.
- Contextual hover information:
- Package details including location and state when hovering over package names
- Available products in the package
The easiest way to get started is through editor extensions:
- Zed: Install the Package.swift LSP extension from the Zed extension marketplace
Note
For proper Swift language server functionality in non-Package.swift files, configure the language server order in your Zed settings:
{
"languages": {
"Swift": {
"language_servers": ["sourcekit-lsp", "package-swift-lsp"]
}
}
}
- Visual Studio Code: Install the Package.swift LSP extension from the VSCode marketplace
Support for additional editors (Vim, Emacs, etc.) is planned. If you'd like to see support for your preferred editor, please submit a feature request or consider contributing!
The LSP server binary can also be downloaded directly from the GitHub releases page.
Thanks to the people and projects that helped make this LSP possible:
- @mattmassicotte for ChimeHQ/LanguageServerProtocol - a solid foundation for this project
- Swift Package Index - for providing great package data for our URL completions
- Feel free to submit feature requests if you have ideas for improving Package.swift editing experience
- For substantial contributions (beyond small fixes), please open a discussion first to align on direction and implementation approach
Server is available under the MIT license. See the LICENSE file for more info.