diff --git a/NvimServer b/NvimServer index c503e419..bc7937e3 160000 --- a/NvimServer +++ b/NvimServer @@ -1 +1 @@ -Subproject commit c503e4192cfc293eb60b708ace175ee8fd6438d4 +Subproject commit bc7937e337e3c5233092949d33dd6cc09165a59c diff --git a/RxPack/Sources/RxPack/RxNeovimApi.generated.swift b/RxPack/Sources/RxPack/RxNeovimApi.generated.swift index 370803d7..60c09d2d 100644 --- a/RxPack/Sources/RxPack/RxNeovimApi.generated.swift +++ b/RxPack/Sources/RxPack/RxNeovimApi.generated.swift @@ -41,6 +41,190 @@ extension RxNeovimApi { extension RxNeovimApi { + public func getAutocmds( + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single { + + let params: [RxNeovimApi.Value] = [ + .map(opts.mapToDict({ (Value.string($0), $1) })), + ] + + func transform(_ value: Value) throws -> RxNeovimApi.Value { + guard let result = (Optional(value)) else { + throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) + } + + return result + } + + if errWhenBlocked { + return self + .checkBlocked( + self.rpc(method: "nvim_get_autocmds", params: params, expectsReturnValue: true) + ) + .map(transform) + } + + return self + .rpc(method: "nvim_get_autocmds", params: params, expectsReturnValue: true) + .map(transform) + } + + public func createAutocmd( + event: RxNeovimApi.Value, + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single { + + let params: [RxNeovimApi.Value] = [ + event, + .map(opts.mapToDict({ (Value.string($0), $1) })), + ] + + func transform(_ value: Value) throws -> Int { + guard let result = ((value.int64Value == nil ? nil : Int(value.int64Value!))) else { + throw RxNeovimApi.Error.conversion(type: Int.self) + } + + return result + } + + if errWhenBlocked { + return self + .checkBlocked( + self.rpc(method: "nvim_create_autocmd", params: params, expectsReturnValue: true) + ) + .map(transform) + } + + return self + .rpc(method: "nvim_create_autocmd", params: params, expectsReturnValue: true) + .map(transform) + } + + public func delAutocmd( + id: Int, + expectsReturnValue: Bool = false + ) -> Completable { + + let params: [RxNeovimApi.Value] = [ + .int(Int64(id)), + ] + + if expectsReturnValue { + return self + .checkBlocked( + self.rpc(method: "nvim_del_autocmd", params: params, expectsReturnValue: expectsReturnValue) + ) + .asCompletable() + } + + return self + .rpc(method: "nvim_del_autocmd", params: params, expectsReturnValue: expectsReturnValue) + .asCompletable() + } + + public func createAugroup( + name: String, + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single { + + let params: [RxNeovimApi.Value] = [ + .string(name), + .map(opts.mapToDict({ (Value.string($0), $1) })), + ] + + func transform(_ value: Value) throws -> Int { + guard let result = ((value.int64Value == nil ? nil : Int(value.int64Value!))) else { + throw RxNeovimApi.Error.conversion(type: Int.self) + } + + return result + } + + if errWhenBlocked { + return self + .checkBlocked( + self.rpc(method: "nvim_create_augroup", params: params, expectsReturnValue: true) + ) + .map(transform) + } + + return self + .rpc(method: "nvim_create_augroup", params: params, expectsReturnValue: true) + .map(transform) + } + + public func delAugroupById( + id: Int, + expectsReturnValue: Bool = false + ) -> Completable { + + let params: [RxNeovimApi.Value] = [ + .int(Int64(id)), + ] + + if expectsReturnValue { + return self + .checkBlocked( + self.rpc(method: "nvim_del_augroup_by_id", params: params, expectsReturnValue: expectsReturnValue) + ) + .asCompletable() + } + + return self + .rpc(method: "nvim_del_augroup_by_id", params: params, expectsReturnValue: expectsReturnValue) + .asCompletable() + } + + public func delAugroupByName( + name: String, + expectsReturnValue: Bool = false + ) -> Completable { + + let params: [RxNeovimApi.Value] = [ + .string(name), + ] + + if expectsReturnValue { + return self + .checkBlocked( + self.rpc(method: "nvim_del_augroup_by_name", params: params, expectsReturnValue: expectsReturnValue) + ) + .asCompletable() + } + + return self + .rpc(method: "nvim_del_augroup_by_name", params: params, expectsReturnValue: expectsReturnValue) + .asCompletable() + } + + public func doAutocmd( + event: RxNeovimApi.Value, + opts: Dictionary, + expectsReturnValue: Bool = false + ) -> Completable { + + let params: [RxNeovimApi.Value] = [ + event, + .map(opts.mapToDict({ (Value.string($0), $1) })), + ] + + if expectsReturnValue { + return self + .checkBlocked( + self.rpc(method: "nvim_do_autocmd", params: params, expectsReturnValue: expectsReturnValue) + ) + .asCompletable() + } + + return self + .rpc(method: "nvim_do_autocmd", params: params, expectsReturnValue: expectsReturnValue) + .asCompletable() + } + public func bufLineCount( buffer: RxNeovimApi.Buffer, errWhenBlocked: Bool = true @@ -233,6 +417,46 @@ extension RxNeovimApi { .asCompletable() } + public func bufGetText( + buffer: RxNeovimApi.Buffer, + start_row: Int, + start_col: Int, + end_row: Int, + end_col: Int, + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single<[String]> { + + let params: [RxNeovimApi.Value] = [ + .int(Int64(buffer.handle)), + .int(Int64(start_row)), + .int(Int64(start_col)), + .int(Int64(end_row)), + .int(Int64(end_col)), + .map(opts.mapToDict({ (Value.string($0), $1) })), + ] + + func transform(_ value: Value) throws -> [String] { + guard let result = (value.arrayValue?.compactMap({ v in v.stringValue })) else { + throw RxNeovimApi.Error.conversion(type: [String].self) + } + + return result + } + + if errWhenBlocked { + return self + .checkBlocked( + self.rpc(method: "nvim_buf_get_text", params: params, expectsReturnValue: true) + ) + .map(transform) + } + + return self + .rpc(method: "nvim_buf_get_text", params: params, expectsReturnValue: true) + .map(transform) + } + public func bufGetOffset( buffer: RxNeovimApi.Buffer, index: Int,