Skip to content

Toward a Shared Swift-Native LSP Infrastructure Layer for Editor Integration #1

@furbytm

Description

@furbytm

Summary

Following discussion in coteditor#1524, I wanted to open a broader architectural exploration around whether Language Server Protocol support in CotEditor could potentially benefit from being built on top of a reusable Swift-native LSP client infrastructure layer, rather than a tightly editor-coupled implementation, (reference here).

Over the past few years, I’ve intermittently explored what improving Swift LSP support outside of Xcode could look like - including experiments around editors such as Zed and other lightweight Swift-native tooling environments.

One recurring observation is that the majority of implementation complexity does not appear to come from Swift-specific language functionality itself, but from the shared LSP runtime/client responsibilities that every editor ends up needing to solve independently.

These commonly include:

  • JSON-RPC transport
  • stdio/socket process management
  • async request/response routing
  • cancellation semantics
  • text document synchronization
  • diagnostics pipelines
  • completion and hover plumbing
  • semantic token decoding
  • workspace coordination
  • capability negotiation
  • indexing lifecycle management

This raises an architectural question:

Would it be more beneficial long-term for editors like CotEditor to integrate with a shared Swift-native LSP infrastructure layer, rather than each editor independently implementing and maintaining its own protocol/runtime stack?

Goals

The intent here would not be to create a heavyweight IDE framework or editor abstraction layer.

Instead, the focus would be a lightweight, modular, editor-agnostic runtime layer responsible for:

let client = LSPClient(
    server: .process("/usr/bin/sourcekit-lsp")
)

with editors providing their own UI/document adapters on top.

Potential areas of responsibility could include:

  • LSP transport/runtime management
  • Codable-backed protocol models
  • Swift concurrency-based request handling
  • diagnostics/event streams
  • workspace/session lifecycle
  • semantic token parsing
  • server capability negotiation

while remaining:

  • AppKit-neutral
  • SwiftUI-neutral
  • UIKit-neutral
  • language-server agnostic

Potential Benefits

Shared ecosystem infrastructure

A reusable layer could potentially benefit:

  • CotEditor
  • lightweight Swift-native editors
  • internal tooling
  • educational IDEs

instead of each project independently re-solving similar infrastructure concerns.

Better Swift ecosystem interoperability

A common client/runtime layer may help encourage:

  • more consistent LSP behavior
  • improved SourceKit-LSP integration quality
  • shared bug fixes
  • faster experimentation
  • reduced maintenance burden

across multiple editors and tools.

At minimum, I think this may be an interesting architectural discussion for the broader Swift tooling ecosystem — especially as more Swift-native editors and developer tools continue emerging outside of Xcode.

Pinned by furbytm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions