Skip to content

kattouf/package-swift-lsp

Repository files navigation

Package.swift LSP

Latest Release codecov Build Status

A Language Server Protocol (LSP) implementation for Swift Package Manager's Package.swift manifest files.

demo

Overview

Language server for Package.swift files that provides:

  • Smart code completion for Package.swift manifest files:
    • In .package(...) function:
      • url: argument with GitHub repository suggestions
      • from: and exact: arguments with version suggestions
      • branch: argument with available branch names
    • In .product(...) function:
      • name: argument with available product suggestions from dependencies
      • package: 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

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

Installation & Editor Integration

The easiest way to get started is through editor extensions:

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"]
    }
  }
}

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.

Acknowledgements

Thanks to the people and projects that helped make this LSP possible:

Contributing

  • 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

License

Server is available under the MIT license. See the LICENSE file for more info.

About

Language Server Protocol (LSP) implementation for Swift Package Manager's Package.swift manifest files.

Resources

License

Stars

Watchers

Forks