Interactive setup for Swift LSP development environment
Configures Swift LSP with SourceKit-LSP, SwiftFormat, and SwiftLint for iOS/macOS development. Use this to set up code intelligence and formatting tools before writing Swift code.
/plugin marketplace add zircote/swift-lsp/plugin install swift-lsp@zircote-lspThis command will configure your Swift development environment with SourceKit-LSP and essential tools.
First, verify Xcode/Swift is installed:
swift --version
xcode-select -p
xcode-select --install
SourceKit-LSP is included with Xcode.
# Formatting
brew install swiftformat
# Linting
brew install swiftlint
sourcekit-lsp --help
swiftformat --version
swiftlint version
export ENABLE_LSP_TOOL=1
Test the LSP integration:
# Create a test file
echo 'func greet(name: String) -> String { return "Hello, \(name)!" }' > test_lsp.swift
# Run SwiftFormat
swiftformat test_lsp.swift
# Run SwiftLint
swiftlint lint test_lsp.swift
# Clean up
rm test_lsp.swift