diff --git a/README.md b/README.md index d195a6d..3d7104b 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ The LSP [specification](https://microsoft.github.io/language-server-protocol/spe | ------|:---------:| | $/cancelRequest | ✅ | | $/progress | ✅ | +| server-defined | ✅ | ## Suggestions or Feedback diff --git a/Sources/LanguageServerProtocol/JSONRPCLanguageServer.swift b/Sources/LanguageServerProtocol/JSONRPCLanguageServer.swift index bce32a3..b9a0079 100644 --- a/Sources/LanguageServerProtocol/JSONRPCLanguageServer.swift +++ b/Sources/LanguageServerProtocol/JSONRPCLanguageServer.swift @@ -395,6 +395,8 @@ extension JSONRPCLanguageServer { sendRequestWithHandler(params, method: method, handler: completionHandler) case .workspaceWillDeleteFiles(let params): sendRequestWithHandler(params, method: method, handler: completionHandler) + case .custom(let method, let params): + sendRequestWithHandler(params, method: method, handler: completionHandler) } } } diff --git a/Sources/LanguageServerProtocol/LanguageServerProtocol.swift b/Sources/LanguageServerProtocol/LanguageServerProtocol.swift index 4b8cc86..d0e309a 100644 --- a/Sources/LanguageServerProtocol/LanguageServerProtocol.swift +++ b/Sources/LanguageServerProtocol/LanguageServerProtocol.swift @@ -1,4 +1,5 @@ import JSONRPC +import AnyCodable typealias UnusedResult = String? typealias UnusedParam = String? @@ -117,6 +118,7 @@ public enum ClientRequest { case textDocumentSemanticTokensFull = "textDocument/semanticTokens/full" case textDocumentSemanticTokensFullDelta = "textDocument/semanticTokens/full/delta" case textDocumentMoniker = "textDocument/moniker" + case custom } case initialize(InitializeParams) @@ -154,6 +156,7 @@ public enum ClientRequest { case semanticTokensFull(SemanticTokensParams) case semanticTokensFullDelta(SemanticTokensDeltaParams) case semanticTokensRange(SemanticTokensRangeParams) + case custom(String, AnyCodable) public var method: Method { switch self { @@ -227,6 +230,8 @@ public enum ClientRequest { return .textDocumentSemanticTokensFullDelta case .semanticTokensRange: return .textDocumentSemanticTokensRange + case .custom: + return .custom } } } diff --git a/Sources/LanguageServerProtocol/Server.swift b/Sources/LanguageServerProtocol/Server.swift index e8a6a34..d5dedd4 100644 --- a/Sources/LanguageServerProtocol/Server.swift +++ b/Sources/LanguageServerProtocol/Server.swift @@ -180,6 +180,10 @@ public extension Server { func semanticTokensRange(params: SemanticTokensRangeParams, block: @escaping (ServerResult) -> Void) { sendRequest(.semanticTokensRange(params), completionHandler: block) } + + func customRequest(method: String, params: AnyCodable, block: @escaping (ServerResult) -> Void) { + sendRequest(.custom(method, params), completionHandler: block) + } } // Workspace notifications