SwiftLSPClient 0.8.1

SwiftLSPClient 0.8.1

Matt Massicotte 维护。



Github CI Carthage compatible CocoaPods

SwiftLSPClient

这是一个用于与 语言服务器协议 实现交互的 Swift 库。

LSP 服务器提供有关源代码的大量信息。LSP 客户端消费这些信息。这个库全是关于客户端的。

示例

import SwiftLSPClient

let executablePath = "path/to/your/lsp-server-executable"
let host = LanguageServerProcessHost(path: executablePath, arguments: [],
    environemnt: [/* the environment your lsp server requires e.g. PATH */])

host.start { (server) in
    guard let server = server else {
        Swift.print("unable to launch server")
        return
    }

    let processId = Int(ProcessInfo.processInfo.processIdentifier)
    let capabilities = ClientCapabilities(workspace: nil, textDocument: nil, experimental: nil)

    let params = InitializeParams(processId: processId,
                                  rootPath: nil,
                                  rootURI: nil,
                                  initializationOptions: nil,
                                  capabilities: capabilities,
                                  trace: Tracing.off,
                                  workspaceFolders: nil)

    server.initialize(params: params, block: { (result) in
        switch result {
        case .failure(let error):
            Swift.print("unable to initialize \(error)")
        case .success(let value):
            Swift.print("initialized \(value)")
        }
    })
}

支持的功能

LSP 规范 很大,这个库目前并没有实现全部功能。目标是支持 3.x 规范,同时尽可能与 3.0 之前的服务器保持兼容。

特性 支持
window/showMessage
window/showMessageRequest
window/logMessage
telemetry/event -
client/registerCapability -
client/unregisterCapability -
workspace/workspaceFolders -
workspace/didChangeWorkspaceFolders -
workspace/didChangeConfiguration -
workspace/configuration -
workspace/didChangeWatchedFiles -
workspace/symbol -
workspace/executeCommand -
workspace/applyEdit -
textDocument/didOpen
textDocument/didChange
textDocument/willSave
textDocument/willSaveWaitUntil
textDocument/didSave
textDocument/didClose
textDocument/publishDiagnostics
textDocument/completion
completionItem/resolve -
textDocument/hover
textDocument/signatureHelp
textDocument/declaration
textDocument/definition
textDocument/typeDefinition
textDocument/implementation
textDocument/references
textDocument/documentHighlight -
textDocument/documentSymbol
textDocument/codeAction -
textDocument/codeLens -
codeLens/resolve -
textDocument/documentLink -
documentLink/resolve -
textDocument/documentColor -
textDocument/colorPresentation -
textDocument/格式化
textDocument/范围格式化
textDocument/按类型格式化
textDocument/重命名 -
textDocument/准备重命名 -
textDocument/折叠范围 -

集成

Swift 包管理器

dependencies: [
    .package(url: "https://github.com/ChimeHQ/SwiftLSPClient.git")
]

Carthage

github "ChimeHQ/SwiftLSPClient"

CocoaPods

pod 'SwiftLSPClient'

建议或反馈

我们很高兴收到您的反馈!请通过 twitter、问题或拉取请求与我们联系。

请注意,本项目使用 贡献者行为准则 发布。参与本项目即表示您同意遵守其条款。