1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +03:00

Add extension stream method

This commit is contained in:
Tae Won Ha 2017-12-16 14:02:51 +01:00
parent 517e67ceba
commit 3091ee024a
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -5,6 +5,7 @@
import Foundation
import NvimMsgPack
import RxSwift
extension NvimApi {
@ -34,6 +35,28 @@ extension NvimApi {
}
}
extension StreamApi {
public func getBufGetInfo(
buffer: NvimApi.Buffer
) -> Single<Dictionary<String, NvimApi.Value>> {
let params: [NvimApi.Value] = [
.int(Int64(buffer.handle)),
]
return self
.rpc(method: "nvim_buf_get_info", params: params, expectsReturnValue: true)
.map {
guard let result = (msgPackDictToSwift($0.dictionaryValue)) else {
throw NvimApi.Error.conversion(type: Dictionary<String, NvimApi.Value>.self)
}
return result
}
}
}
func msgPackDictToSwift(_ dict: Dictionary<NvimApi.Value, NvimApi.Value>?) -> Dictionary<String, NvimApi.Value>? {
return dict?.flatMapToDict { k, v in
guard let strKey = k.stringValue else {