SourceKitLSP

swift-5.10-RELEASE

Language Server Protocol implementation for Swift and C-based languages
apple/sourcekit-lsp

What's New

Swift 5.10 Release

2024-03-06T15:46:05Z

What's Changed

  • Update for SwiftSyntax regex changes by @hamishknight in #724
  • Package.swift: bump swift-tools-version and OS requirement by @MaxDesiatov in #729
  • Check the target triple to determine what build flags to apply when building sourcekit-lsp by @finagolfin in #717
  • ToolchainRegistryTests: avoid identity checks for localFileSystem by @MaxDesiatov in #733
  • Fix package manifest API .branch deprecation by @MaxDesiatov in #731
  • Send token with WorkDoneProgress by @JCWasmx86 in #732
  • Rename IDEUtils to SwiftIDEUtils by @ahoppen in #734
  • Change version dependency on swift-argument-parser to from upToNextMinor to upToNextMajor by @ahoppen in #735
  • Update tests to allow multiple -F options by @rauhul in #742
  • Add boilerplate for pull-model diagnostics by @tristanlabelle in #743
  • adjust to latest SwiftPM APIs by @tomerd in #741
  • Add VSCode launch configuration for attaching to executable. by @adam-fowler in #745
  • Fix use of deprecated AbsolutePath and RelativePath initializers by @MaxDesiatov in #738
  • Swiftinterface symbol lookup by @adam-fowler in #747
  • Fix tiny typo by @Sublimeful in #749
  • Package.swift: fix deprecated dependency initializers by @MaxDesiatov in #748
  • Implement pull-model documentDiagnostics by @tristanlabelle in #746
  • Fully decode InitializeRequest by @JCWasmx86 in #756
  • Highlight references to actors like references to classes by @ahoppen in #758
  • Don’t update Package.resolved from sourcekit-lsp by @ahoppen in #762
  • Disable 'testSystemModuleInterface' by @ahoppen in #766
  • Port incremental parse ability to sourcekit-lsp by @StevenWong12 in #761
  • Show a progress indicator in the editor if SourceKit-LSP is reloading packages by @ahoppen in #767
  • Re-enable SwiftInterfaceTests.testSystemModuleInterface by @ahoppen in #768
  • Revert "Show a progress indicator in the editor if SourceKit-LSP is reloading packages" by @bnbarham in #771
  • Add support for Musl libc with canImport(Musl) checks by @MaxDesiatov in #772
  • Don’t offer text edits from inlay hints if they are syntactically invalid by @ahoppen in #770
  • [SwiftSyntax] Remove Keyword suffix from Pound* by @kimdv in #764
  • [NFC] Use SwiftSDK instead of deprecated Destination by @MaxDesiatov in #773
  • Update client capabilities to LSP 3.17 by @ahoppen in #774
  • Register diagnostics in currentDiagnostics when performing a diagnostic pull request by @ahoppen in #777
  • Adding some documentation on setting up LSP for neovim 0.8+ by @scottfines in #783
  • Remove SyntaxClassification.objectLiteral by @StevenWong12 in #788
  • Fix deprecation warnings by @ahoppen in #790
  • Adjustment for rename SyntaxClassification.floatingLiteral -> floatLiteral in SwiftSyntax by @ahoppen in #787
  • Rename some SyntaxClassification by @StevenWong12 in #794
  • Add a message to some test assertions by @bnbarham in #800
  • Update diagnostic in PullDiagnosticsTests to be imperative by @nishithshah2211 in #799
  • Improve folding of line comments by @ahoppen in #804
  • Show a progress indicator in the editor if SourceKit-LSP is reloading packages by @ahoppen in #791
  • Fix a non-deterministic test failure by @ahoppen in #792
  • adjust to swiftpm api change by @tomerd in #808
  • [5.10] Update related dependencies branch to release/5.10 by @ahoppen in #815
  • [5.10] Use new SwiftPM flag to remove $ORIGIN from installed sourcekit-lsp ELF executable runpath by @finagolfin in #913
  • [5.10] Never return error for diagnostics request by @ahoppen in #1022
  • [5.10] Add logic to split command line arguments on Windows by @z2oh in #1043

New Contributors

Full Changelog: swift-5.9.2-RELEASE...swift-5.10-RELEASE

SourceKit-LSP

SourceKit-LSP is an implementation of the Language Server Protocol (LSP) for Swift and C-based languages. It provides features like code-completion and jump-to-definition to editors that support LSP. SourceKit-LSP is built on top of sourcekitd and clangd for high-fidelity language support, and provides a powerful source code index as well as cross-language support. SourceKit-LSP supports projects that use the Swift Package Manager.

Getting Started

The SourceKit-LSP server is included with the Swift toolchain. Depending on how you installed Swift, you may already have SourceKit-LSP. Make sure you build your package with the same toolchain as you use sourcekit-lsp from to ensure compatibility.

  1. Get SourceKit-LSP with a Swift toolchain

    1. If you have installed Xcode 11.4+ or the corresponding Command Line Tools package, the SourceKit-LSP server is included and can be run with xcrun sourcekit-lsp.

    2. If you are using a toolchain from Swift.org, the SourceKit-LSP server is included and can be run with xcrun --toolchain swift sourcekit-lsp on macOS, or using the full path to the sourcekit-lsp executable on Linux.

    3. If your toolchain did not come with SourceKit-LSP, see Development for how to build it from source.

  2. Configure your editor to use SourceKit-LSP. See Editors for more information about editor integration.

  3. Build the project you are working on with swift build using the same toolchain as the SourceKit-LSP server. The language server depends on the build to provide module dependencies and to update the global index.

Development

For more information about developing SourceKit-LSP itself, see Development. For information about developing SourceKit-LSP clients (like editors or their language plugins), see Client Development.

Indexing While Building

SourceKit-LSP uses a global index called IndexStoreDB to provide features that cross file or module boundaries, such as jump-to-definition or find-references. To efficiently create an index of your source code we use a technique called "indexing while building". When the project is compiled for debugging using swift build, the compiler (swiftc or clang) automatically produces additional raw index data that is read by our indexer. Producing this information during compilation saves work and ensures that any time the project is built the index is updated and fully accurate.

In the future we intend to also provide automatic background indexing so that we can update the index in between builds or to include code that's not always built like unit tests. In the meantime, building your project should bring our index up to date.

Status

SourceKit-LSP is still in early development, so you may run into rough edges with any of the features. The following table shows the status of various features when using the latest development toolchain snapshot. See Caveats for important known issues you may run into.

Feature Status Notes
Swift
C/C++/ObjC Uses clangd
Code completion
Quick Help (Hover)
Diagnostics
Fix-its
Jump to Definition
Find References
Background Indexing Build project to update the index using Indexing While Building
Workspace Symbols
Rename
Local Refactoring
Formatting
Folding
Syntax Highlighting Both syntactic and semantic tokens
Document Symbols
Call Hierarchy
Type Hierarchy

Caveats

  • SourceKit-LSP does not update its global index in the background, but instead relies on indexing-while-building to provide data. This only affects global queries like find-references and jump-to-definition.
    • Workaround: build the project to update the index

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Fri Apr 26 2024 03:30:32 GMT-0900 (Hawaii-Aleutian Daylight Time)