From 0c3e5a4b0b15cf0f0b772ece1c4b335ef1636e40 Mon Sep 17 00:00:00 2001 From: Rainux Luo Date: Mon, 8 Apr 2024 16:52:00 +0800 Subject: [PATCH] Revert part of the changes in 68afc66a This should fix the filetype detection issue --- NvimView/Sources/NvimView/NvimView+Key.swift | 10 +- .../Sources/NvimView/NvimView+Resize.swift | 4 +- NvimView/Sources/NvimView/NvimView.swift | 12 +- .../RxNeovim/RxNeovimApi.generated.swift | 4905 +++++++++++++---- RxPack/Sources/RxNeovim/RxNeovimApi.swift | 13 + RxPack/bin/generate_api_methods.py | 22 +- 6 files changed, 3775 insertions(+), 1191 deletions(-) diff --git a/NvimView/Sources/NvimView/NvimView+Key.swift b/NvimView/Sources/NvimView/NvimView+Key.swift index 6001ae84..0b9c0ce7 100644 --- a/NvimView/Sources/NvimView/NvimView+Key.swift +++ b/NvimView/Sources/NvimView/NvimView+Key.swift @@ -43,7 +43,7 @@ public extension NvimView { let finalInput = isWrapNeeded ? self.wrapNamedKeys(flags + namedChars) : self.vimPlainString(chars) - _ = self.api.input(keys: finalInput).syncValue() + _ = self.api.input(keys: finalInput, errWhenBlocked: false).syncValue() self.keyDownDone = true } @@ -60,7 +60,7 @@ public extension NvimView { // try? self.api.feedkeys(keys: self.vimPlainString(text), mode:"m", escape_ks: false) // .wait() - _ = self.api.input(keys: self.vimPlainString(text)).syncValue() + _ = self.api.input(keys: self.vimPlainString(text), errWhenBlocked: false).syncValue() if self.hasMarkedText() { self._unmarkText() } self.keyDownDone = true @@ -125,7 +125,7 @@ public extension NvimView { // So we escape as early as possible if chars == "\0" { self.api - .input(keys: self.wrapNamedKeys("Nul")) + .input(keys: self.wrapNamedKeys("Nul"), errWhenBlocked: false) .subscribe(onFailure: { [weak self] error in self?.log.error("Error in \(#function): \(error)") }) @@ -138,7 +138,7 @@ public extension NvimView { // Also mentioned in MacVim's KeyBindings.plist if flags == .control, chars == "6" { self.api - .input(keys: "\u{1e}") // AKA ^^ + .input(keys: "\u{1e}", errWhenBlocked: false) // AKA ^^ .subscribe(onFailure: { [weak self] error in self?.log.error("Error in \(#function): \(error)") }) @@ -149,7 +149,7 @@ public extension NvimView { if flags == .control, chars == "2" { // should generate \0, escaping as above self.api - .input(keys: self.wrapNamedKeys("Nul")) + .input(keys: self.wrapNamedKeys("Nul"), errWhenBlocked: false) .subscribe(onFailure: { [weak self] error in self?.log.error("Error in \(#function): \(error)") }) diff --git a/NvimView/Sources/NvimView/NvimView+Resize.swift b/NvimView/Sources/NvimView/NvimView+Resize.swift index 02f1576b..b90928c9 100644 --- a/NvimView/Sources/NvimView/NvimView+Resize.swift +++ b/NvimView/Sources/NvimView/NvimView+Resize.swift @@ -99,7 +99,7 @@ extension NvimView { // NvimView.swift try? self.api.run(inPipe: inPipe, outPipe: outPipe, errorPipe: errorPipe) .andThen( - self.api.getApiInfo() + self.api.getApiInfo(errWhenBlocked: false) .flatMapCompletable { value in guard let info = value.arrayValue, info.count == 2, @@ -128,7 +128,7 @@ extension NvimView { autocmd VimEnter * call rpcnotify(\(channel), 'autocommand', 'vimenter') autocmd ColorScheme * call rpcnotify(\(channel), 'autocommand', 'colorscheme', get(nvim_get_hl(0, {'id': hlID('Normal')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Normal')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'fg', -1), get(nvim_get_hl(0, {'id': hlID('Visual')}), 'bg', -1), get(nvim_get_hl(0, {'id': hlID('Directory')}), 'fg', -1)) autocmd VimEnter * call rpcrequest(\(channel), 'vimenter') - """, opts: [:]) + """, opts: [:], errWhenBlocked: false) // swiftformat:enable all .asCompletable() } diff --git a/NvimView/Sources/NvimView/NvimView.swift b/NvimView/Sources/NvimView/NvimView.swift index 9208cee0..e20789c1 100644 --- a/NvimView/Sources/NvimView/NvimView.swift +++ b/NvimView/Sources/NvimView/NvimView.swift @@ -350,7 +350,7 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie private var _characterspacing = NvimView.defaultCharacterspacing private func doSetupForVimenterAndSendResponse(forMsgid msgid: UInt32) { - self.api.getApiInfo() + self.api.getApiInfo(errWhenBlocked: false) .flatMapCompletable { value in guard let info = value.arrayValue, info.count == 2, @@ -368,14 +368,18 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie autocmd BufEnter * call rpcnotify(\(channel), 'autocommand', 'bufenter', str2nr(expand(''))) autocmd DirChanged * call rpcnotify(\( channel), 'autocommand', 'dirchanged', expand('')) autocmd BufModifiedSet * call rpcnotify(\(channel), 'autocommand', 'bufmodifiedset', str2nr(expand('')), getbufinfo(str2nr(expand('')))[0].changed) - """, opts: [:]) + """, opts: [:], errWhenBlocked: false) // swiftformat:enable all .asCompletable() - .andThen(self.api.subscribe(event: NvimView.rpcEventName)) + .andThen(self.api.subscribe(event: NvimView.rpcEventName, expectsReturnValue: false)) .andThen( self.sourceFileUrls.reduce(.empty()) { prev, url in prev.andThen( - self.api.exec2(src: "source \(url.shellEscapedPath)", opts: ["output": true]) + self.api.exec2( + src: "source \(url.shellEscapedPath)", + opts: ["output": true], + errWhenBlocked: false + ) .map { retval in guard let output = retval["output"]?.stringValue else { throw RxNeovimApi.Error diff --git a/RxPack/Sources/RxNeovim/RxNeovimApi.generated.swift b/RxPack/Sources/RxNeovim/RxNeovimApi.generated.swift index 28236b22..862268e5 100644 --- a/RxPack/Sources/RxNeovim/RxNeovimApi.generated.swift +++ b/RxPack/Sources/RxNeovim/RxNeovimApi.generated.swift @@ -1,12 +1,14 @@ -// Auto generated for nvim version 0.9.4. +// Auto generated for nvim version 0.9.5. // See bin/generate_api_methods.py import Foundation import MessagePack import RxSwift -public extension RxNeovimApi { - enum Error: Swift.Error { +extension RxNeovimApi { + + public enum Error: Swift.Error { + public static let exceptionRawValue = UInt64(0) public static let validationRawValue = UInt64(1) @@ -30,169 +32,262 @@ public extension RxNeovimApi { switch rawValue { case Error.exceptionRawValue: self = .exception(message: message) - case Error.validationRawValue: self = .validation(message: message) + case Error.validationRawValue: self = .validation(message: message) default: self = .unknown } } } } -public extension RxNeovimApi { - func getAutocmds( - opts: [String: RxNeovimApi.Value] +extension RxNeovimApi { + + public func getAutocmds( + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .map(opts.mapToDict { (Value.string($0), $1) }), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_autocmds", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_autocmds", params: params) .map(transform) } - func createAutocmd( + public func createAutocmd( event: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - event, - .map(opts.mapToDict { (Value.string($0), $1) }), + event, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_create_autocmd", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_create_autocmd", params: params) .map(transform) } - func delAutocmd( - id: Int + public func delAutocmd( + id: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(id)), + .int(Int64(id)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_autocmd", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_autocmd", params: params) .asCompletable() } - func clearAutocmds( - opts: [String: RxNeovimApi.Value] + public func clearAutocmds( + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .map(opts.mapToDict { (Value.string($0), $1) }), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_clear_autocmds", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_clear_autocmds", params: params) .asCompletable() } - func createAugroup( + public func createAugroup( name: String, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_create_augroup", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_create_augroup", params: params) .map(transform) } - func delAugroupById( - id: Int + public func delAugroupById( + id: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(id)), + .int(Int64(id)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_augroup_by_id", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_augroup_by_id", params: params) .asCompletable() } - func delAugroupByName( - name: String + public func delAugroupByName( + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_augroup_by_name", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_augroup_by_name", params: params) .asCompletable() } - func execAutocmds( + public func execAutocmds( event: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - event, - .map(opts.mapToDict { (Value.string($0), $1) }), + event, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_exec_autocmds", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_exec_autocmds", params: params) .asCompletable() } - func bufLineCount( - buffer: RxNeovimApi.Buffer + public func bufLineCount( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_line_count", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_line_count", params: params) .map(transform) } - func bufAttach( + public func bufAttach( buffer: RxNeovimApi.Buffer, send_buffer: Bool, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .bool(send_buffer), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .bool(send_buffer), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Bool in @@ -203,16 +298,26 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_attach", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_attach", params: params) .map(transform) } - func bufDetach( - buffer: RxNeovimApi.Buffer + public func bufDetach( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -223,266 +328,396 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_detach", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_detach", params: params) .map(transform) } - func bufGetLines( + public func bufGetLines( buffer: RxNeovimApi.Buffer, start: Int, end: Int, - strict_indexing: Bool + strict_indexing: Bool, + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(strict_indexing), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(strict_indexing), ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "nvim_buf_get_lines", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_lines", params: params) .map(transform) } - func bufSetLines( + public func bufSetLines( buffer: RxNeovimApi.Buffer, start: Int, end: Int, strict_indexing: Bool, - replacement: [String] + replacement: [String], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(strict_indexing), - .array(replacement.map { .string($0) }), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(strict_indexing), + .array(replacement.map { .string($0) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_lines", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_lines", params: params) .asCompletable() } - func bufSetText( + public func bufSetText( buffer: RxNeovimApi.Buffer, start_row: Int, start_col: Int, end_row: Int, end_col: Int, - replacement: [String] + replacement: [String], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start_row)), - .int(Int64(start_col)), - .int(Int64(end_row)), - .int(Int64(end_col)), - .array(replacement.map { .string($0) }), + .int(Int64(buffer.handle)), + .int(Int64(start_row)), + .int(Int64(start_col)), + .int(Int64(end_row)), + .int(Int64(end_col)), + .array(replacement.map { .string($0) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_text", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_text", params: params) .asCompletable() } - func bufGetText( + public func bufGetText( buffer: RxNeovimApi.Buffer, start_row: Int, start_col: Int, end_row: Int, end_col: Int, - opts: [String: RxNeovimApi.Value] + 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) }), + .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) })), ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "nvim_buf_get_text", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_text", params: params) .map(transform) } - func bufGetOffset( + public func bufGetOffset( buffer: RxNeovimApi.Buffer, - index: Int + index: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(index)), + .int(Int64(buffer.handle)), + .int(Int64(index)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_get_offset", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_offset", params: params) .map(transform) } - func bufGetVar( + public func bufGetVar( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_var", params: params) .map(transform) } - func bufGetChangedtick( - buffer: RxNeovimApi.Buffer + public func bufGetChangedtick( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_get_changedtick", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_changedtick", params: params) .map(transform) } - func bufGetKeymap( + public func bufGetKeymap( buffer: RxNeovimApi.Buffer, - mode: String - ) -> Single<[[String: RxNeovimApi.Value]]> { + mode: String, + errWhenBlocked: Bool = true + ) -> Single<[Dictionary]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(mode), + .int(Int64(buffer.handle)), + .string(mode), ] - let transform = { (_ value: Value) throws -> [[String: RxNeovimApi.Value]] in - guard let result = msgPackArrayDictToSwift(value.arrayValue) else { - throw RxNeovimApi.Error.conversion(type: [[String: RxNeovimApi.Value]].self) + let transform = { (_ value: Value) throws -> [Dictionary] in + guard let result = (msgPackArrayDictToSwift(value.arrayValue)) else { + throw RxNeovimApi.Error.conversion(type: [Dictionary].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_keymap", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_keymap", params: params) .map(transform) } - func bufSetKeymap( + public func bufSetKeymap( buffer: RxNeovimApi.Buffer, mode: String, lhs: String, rhs: String, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(mode), - .string(lhs), - .string(rhs), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .string(mode), + .string(lhs), + .string(rhs), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_keymap", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_keymap", params: params) .asCompletable() } - func bufDelKeymap( + public func bufDelKeymap( buffer: RxNeovimApi.Buffer, mode: String, - lhs: String + lhs: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(mode), - .string(lhs), + .int(Int64(buffer.handle)), + .string(mode), + .string(lhs), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_del_keymap", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_del_keymap", params: params) .asCompletable() } - func bufSetVar( + public func bufSetVar( buffer: RxNeovimApi.Buffer, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - value, + .int(Int64(buffer.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_var", params: params) .asCompletable() } - func bufDelVar( + public func bufDelVar( buffer: RxNeovimApi.Buffer, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_del_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_del_var", params: params) .asCompletable() } - func bufGetName( - buffer: RxNeovimApi.Buffer + public func bufGetName( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> String in @@ -493,30 +728,50 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_name", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_name", params: params) .map(transform) } - func bufSetName( + public func bufSetName( buffer: RxNeovimApi.Buffer, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_name", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_name", params: params) .asCompletable() } - func bufIsLoaded( - buffer: RxNeovimApi.Buffer + public func bufIsLoaded( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -527,30 +782,50 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_is_loaded", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_is_loaded", params: params) .map(transform) } - func bufDelete( + public func bufDelete( buffer: RxNeovimApi.Buffer, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_delete", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_delete", params: params) .asCompletable() } - func bufIsValid( - buffer: RxNeovimApi.Buffer + public func bufIsValid( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -561,18 +836,28 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_is_valid", params: params) .map(transform) } - func bufDelMark( + public func bufDelMark( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> Bool in @@ -583,24 +868,34 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_del_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_del_mark", params: params) .map(transform) } - func bufSetMark( + public func bufSetMark( buffer: RxNeovimApi.Buffer, name: String, line: Int, col: Int, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - .int(Int64(line)), - .int(Int64(col)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .string(name), + .int(Int64(line)), + .int(Int64(col)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Bool in @@ -611,87 +906,124 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_set_mark", params: params) .map(transform) } - func bufGetMark( + public func bufGetMark( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_mark", params: params) .map(transform) } - func bufCall( + public func bufCall( buffer: RxNeovimApi.Buffer, - fun: RxNeovimApi.Value + fun: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - fun, + .int(Int64(buffer.handle)), + fun, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_call", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_call", params: params) .map(transform) } - func parseCmd( + public func parseCmd( str: String, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(str), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(str), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_parse_cmd", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_parse_cmd", params: params) .map(transform) } - func cmd( - cmd: [String: RxNeovimApi.Value], - opts: [String: RxNeovimApi.Value] + public func cmd( + cmd: Dictionary, + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .map(cmd.mapToDict { (Value.string($0), $1) }), - .map(opts.mapToDict { (Value.string($0), $1) }), + .map(cmd.mapToDict({ (Value.string($0), $1) })), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> String in @@ -702,121 +1034,191 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_cmd", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_cmd", params: params) .map(transform) } - func createUserCommand( + public func createUserCommand( name: String, command: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - command, - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + command, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_create_user_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_create_user_command", params: params) .asCompletable() } - func delUserCommand( - name: String + public func delUserCommand( + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_user_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_user_command", params: params) .asCompletable() } - func bufCreateUserCommand( + public func bufCreateUserCommand( buffer: RxNeovimApi.Buffer, name: String, command: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - command, - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .string(name), + command, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_create_user_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_create_user_command", params: params) .asCompletable() } - func bufDelUserCommand( + public func bufDelUserCommand( buffer: RxNeovimApi.Buffer, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_del_user_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_del_user_command", params: params) .asCompletable() } - func getCommands( - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + public func getCommands( + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .map(opts.mapToDict { (Value.string($0), $1) }), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_commands", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_commands", params: params) .map(transform) } - func bufGetCommands( + public func bufGetCommands( buffer: RxNeovimApi.Buffer, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_commands", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_commands", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func exec( + public func exec( src: String, - output: Bool + output: Bool, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(src), - .bool(output), + .string(src), + .bool(output), ] let transform = { (_ value: Value) throws -> String in @@ -827,17 +1229,27 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_exec", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_exec", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func commandOutput( - command: String + public func commandOutput( + command: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(command), + .string(command), ] let transform = { (_ value: Value) throws -> String in @@ -848,174 +1260,254 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_command_output", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_command_output", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func executeLua( + public func executeLua( code: String, - args: RxNeovimApi.Value + args: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(code), - args, + .string(code), + args, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_execute_lua", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_execute_lua", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func bufGetNumber( - buffer: RxNeovimApi.Buffer + public func bufGetNumber( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_get_number", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_number", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func bufClearHighlight( + public func bufClearHighlight( buffer: RxNeovimApi.Buffer, ns_id: Int, line_start: Int, - line_end: Int + line_end: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(line_start)), - .int(Int64(line_end)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(line_start)), + .int(Int64(line_end)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_clear_highlight", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_clear_highlight", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func bufSetVirtualText( + public func bufSetVirtualText( buffer: RxNeovimApi.Buffer, src_id: Int, line: Int, chunks: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(src_id)), - .int(Int64(line)), - chunks, - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .int(Int64(src_id)), + .int(Int64(line)), + chunks, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_set_virtual_text", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_set_virtual_text", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func getHlById( + public func getHlById( hl_id: Int, - rgb: Bool - ) -> Single<[String: RxNeovimApi.Value]> { + rgb: Bool, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(hl_id)), - .bool(rgb), + .int(Int64(hl_id)), + .bool(rgb), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_hl_by_id", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_hl_by_id", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func getHlByName( + public func getHlByName( name: String, - rgb: Bool - ) -> Single<[String: RxNeovimApi.Value]> { + rgb: Bool, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(name), - .bool(rgb), + .string(name), + .bool(rgb), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_hl_by_name", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_hl_by_name", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rInsert( + public func rInsert( buffer: RxNeovimApi.Buffer, lnum: Int, - lines: [String] + lines: [String], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(lnum)), - .array(lines.map { .string($0) }), + .int(Int64(buffer.handle)), + .int(Int64(lnum)), + .array(lines.map { .string($0) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_insert", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_insert", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rGetLine( + public func rGetLine( buffer: RxNeovimApi.Buffer, - index: Int + index: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(index)), + .int(Int64(buffer.handle)), + .int(Int64(index)), ] let transform = { (_ value: Value) throws -> String in @@ -1026,435 +1518,623 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_get_line", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_line", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rSetLine( + public func rSetLine( buffer: RxNeovimApi.Buffer, index: Int, - line: String + line: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(index)), - .string(line), + .int(Int64(buffer.handle)), + .int(Int64(index)), + .string(line), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_set_line", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rDelLine( + public func rDelLine( buffer: RxNeovimApi.Buffer, - index: Int + index: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(index)), + .int(Int64(buffer.handle)), + .int(Int64(index)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_del_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_del_line", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rGetLineSlice( + public func rGetLineSlice( buffer: RxNeovimApi.Buffer, start: Int, end: Int, include_start: Bool, - include_end: Bool + include_end: Bool, + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(include_start), - .bool(include_end), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(include_start), + .bool(include_end), ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "buffer_get_line_slice", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_line_slice", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rSetLineSlice( + public func rSetLineSlice( buffer: RxNeovimApi.Buffer, start: Int, end: Int, include_start: Bool, include_end: Bool, - replacement: [String] + replacement: [String], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(include_start), - .bool(include_end), - .array(replacement.map { .string($0) }), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(include_start), + .bool(include_end), + .array(replacement.map { .string($0) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_line_slice", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_set_line_slice", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rSetVar( + public func rSetVar( buffer: RxNeovimApi.Buffer, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - value, + .int(Int64(buffer.handle)), + .string(name), + value, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_set_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rDelVar( + public func rDelVar( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_del_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_del_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wSetVar( + public func wSetVar( window: RxNeovimApi.Window, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), - value, + .int(Int64(window.handle)), + .string(name), + value, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_set_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_set_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wDelVar( + public func wDelVar( window: RxNeovimApi.Window, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_del_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_del_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func geSetVar( + public func geSetVar( tabpage: RxNeovimApi.Tabpage, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), - value, + .int(Int64(tabpage.handle)), + .string(name), + value, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_set_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_set_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func geDelVar( + public func geDelVar( tabpage: RxNeovimApi.Tabpage, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), + .int(Int64(tabpage.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_del_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_del_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etVar( + public func etVar( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_set_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func elVar( - name: String + public func elVar( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_del_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_del_var", params: params) .map(transform) } - func getOptionInfo( - name: String - ) -> Single<[String: RxNeovimApi.Value]> { + public func getOptionInfo( + name: String, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_option_info", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_option_info", params: params) .map(transform) } - func createNamespace( - name: String + public func createNamespace( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_create_namespace", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_create_namespace", params: params) .map(transform) } - func getNamespaces( - ) -> Single<[String: RxNeovimApi.Value]> { + public func getNamespaces( + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ + ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_namespaces", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_namespaces", params: params) .map(transform) } - func bufGetExtmarkById( + public func bufGetExtmarkById( buffer: RxNeovimApi.Buffer, ns_id: Int, id: Int, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(id)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(id)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_extmark_by_id", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_extmark_by_id", params: params) .map(transform) } - func bufGetExtmarks( + public func bufGetExtmarks( buffer: RxNeovimApi.Buffer, ns_id: Int, start: RxNeovimApi.Value, end: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - start, - end, - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + start, + end, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_extmarks", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_extmarks", params: params) .map(transform) } - func bufSetExtmark( + public func bufSetExtmark( buffer: RxNeovimApi.Buffer, ns_id: Int, line: Int, col: Int, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(line)), - .int(Int64(col)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(line)), + .int(Int64(col)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_set_extmark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_set_extmark", params: params) .map(transform) } - func bufDelExtmark( + public func bufDelExtmark( buffer: RxNeovimApi.Buffer, ns_id: Int, - id: Int + id: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(id)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(id)), ] let transform = { (_ value: Value) throws -> Bool in @@ -1465,338 +2145,519 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_del_extmark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_del_extmark", params: params) .map(transform) } - func bufAddHighlight( + public func bufAddHighlight( buffer: RxNeovimApi.Buffer, ns_id: Int, hl_group: String, line: Int, col_start: Int, - col_end: Int + col_end: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .string(hl_group), - .int(Int64(line)), - .int(Int64(col_start)), - .int(Int64(col_end)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .string(hl_group), + .int(Int64(line)), + .int(Int64(col_start)), + .int(Int64(col_end)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_buf_add_highlight", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_add_highlight", params: params) .map(transform) } - func bufClearNamespace( + public func bufClearNamespace( buffer: RxNeovimApi.Buffer, ns_id: Int, line_start: Int, - line_end: Int + line_end: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(line_start)), - .int(Int64(line_end)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(line_start)), + .int(Int64(line_end)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_clear_namespace", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_clear_namespace", params: params) .asCompletable() } - func setDecorationProvider( + public func setDecorationProvider( ns_id: Int, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(ns_id)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(ns_id)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_decoration_provider", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_decoration_provider", params: params) .asCompletable() } - func getOptionValue( + public func getOptionValue( name: String, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_option_value", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_option_value", params: params) .map(transform) } - func setOptionValue( + public func setOptionValue( name: String, value: RxNeovimApi.Value, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + value, + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_option_value", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_option_value", params: params) .asCompletable() } - func getAllOptionsInfo( - ) -> Single<[String: RxNeovimApi.Value]> { + public func getAllOptionsInfo( + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ + ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_all_options_info", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_all_options_info", params: params) .map(transform) } - func getOptionInfo2( + public func getOptionInfo2( name: String, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(name), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_option_info2", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_option_info2", params: params) .map(transform) } - func setOption( + public func setOption( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_option", params: params) .asCompletable() } - func getOption( - name: String + public func getOption( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_option", params: params) .map(transform) } - func bufGetOption( + public func bufGetOption( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_buf_get_option", params: params) .map(transform) } - func bufSetOption( + public func bufSetOption( buffer: RxNeovimApi.Buffer, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - value, + .int(Int64(buffer.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_buf_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_buf_set_option", params: params) .asCompletable() } - func winGetOption( + public func winGetOption( window: RxNeovimApi.Window, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_option", params: params) .map(transform) } - func winSetOption( + public func winSetOption( window: RxNeovimApi.Window, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), - value, + .int(Int64(window.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_option", params: params) .asCompletable() } - func tabpageListWins( - tabpage: RxNeovimApi.Tabpage + public func tabpageListWins( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Window] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Window(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Window(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Window].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_list_wins", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_tabpage_list_wins", params: params) .map(transform) } - func tabpageGetVar( + public func tabpageGetVar( tabpage: RxNeovimApi.Tabpage, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), + .int(Int64(tabpage.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_tabpage_get_var", params: params) .map(transform) } - func tabpageSetVar( + public func tabpageSetVar( tabpage: RxNeovimApi.Tabpage, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), - value, + .int(Int64(tabpage.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_set_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_tabpage_set_var", params: params) .asCompletable() } - func tabpageDelVar( + public func tabpageDelVar( tabpage: RxNeovimApi.Tabpage, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), + .int(Int64(tabpage.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_del_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_tabpage_del_var", params: params) .asCompletable() } - func tabpageGetWin( - tabpage: RxNeovimApi.Tabpage + public func tabpageGetWin( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Window in @@ -1807,36 +2668,56 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_get_win", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_tabpage_get_win", params: params) .map(transform) } - func tabpageGetNumber( - tabpage: RxNeovimApi.Tabpage + public func tabpageGetNumber( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_tabpage_get_number", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_tabpage_get_number", params: params) .map(transform) } - func tabpageIsValid( - tabpage: RxNeovimApi.Tabpage + public func tabpageIsValid( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -1847,291 +2728,472 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_tabpage_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_tabpage_is_valid", params: params) .map(transform) } - func uiAttach( + public func uiAttach( width: Int, height: Int, - options: [String: RxNeovimApi.Value] + options: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(width)), - .int(Int64(height)), - .map(options.mapToDict { (Value.string($0), $1) }), + .int(Int64(width)), + .int(Int64(height)), + .map(options.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_attach", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_attach", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func tach( + public func tach( width: Int, height: Int, - enable_rgb: Bool + enable_rgb: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(width)), - .int(Int64(height)), - .bool(enable_rgb), + .int(Int64(width)), + .int(Int64(height)), + .bool(enable_rgb), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "ui_attach", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "ui_attach", params: params) .asCompletable() } - func uiSetFocus( - gained: Bool + public func uiSetFocus( + gained: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .bool(gained), + .bool(gained), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_set_focus", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_set_focus", params: params) .asCompletable() } - func uiDetach( + public func uiDetach( + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ + ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_detach", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_detach", params: params) .asCompletable() } - func uiTryResize( + public func uiTryResize( width: Int, - height: Int + height: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(width)), - .int(Int64(height)), + .int(Int64(width)), + .int(Int64(height)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_try_resize", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_try_resize", params: params) .asCompletable() } - func uiSetOption( + public func uiSetOption( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_set_option", params: params) .asCompletable() } - func uiTryResizeGrid( + public func uiTryResizeGrid( grid: Int, width: Int, - height: Int + height: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(grid)), - .int(Int64(width)), - .int(Int64(height)), + .int(Int64(grid)), + .int(Int64(width)), + .int(Int64(height)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_try_resize_grid", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_try_resize_grid", params: params) .asCompletable() } - func uiPumSetHeight( - height: Int + public func uiPumSetHeight( + height: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(height)), + .int(Int64(height)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_pum_set_height", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_pum_set_height", params: params) .asCompletable() } - func uiPumSetBounds( + public func uiPumSetBounds( width: Float, height: Float, row: Float, - col: Float + col: Float, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .float(width), - .float(height), - .float(row), - .float(col), + .float(width), + .float(height), + .float(row), + .float(col), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_ui_pum_set_bounds", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_ui_pum_set_bounds", params: params) .asCompletable() } - func getHlIdByName( - name: String + public func getHlIdByName( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_get_hl_id_by_name", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_hl_id_by_name", params: params) .map(transform) } - func getHl( + public func getHl( ns_id: Int, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(ns_id)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(ns_id)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_hl", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_hl", params: params) .map(transform) } - func setHl( + public func setHl( ns_id: Int, name: String, - val: [String: RxNeovimApi.Value] + val: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(ns_id)), - .string(name), - .map(val.mapToDict { (Value.string($0), $1) }), + .int(Int64(ns_id)), + .string(name), + .map(val.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_hl", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_hl", params: params) .asCompletable() } - func setHlNs( - ns_id: Int + public func setHlNs( + ns_id: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(ns_id)), + .int(Int64(ns_id)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_hl_ns", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_hl_ns", params: params) .asCompletable() } - func setHlNsFast( - ns_id: Int + public func setHlNsFast( + ns_id: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(ns_id)), + .int(Int64(ns_id)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_hl_ns_fast", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_hl_ns_fast", params: params) .asCompletable() } - func feedkeys( + public func feedkeys( keys: String, mode: String, - escape_ks: Bool + escape_ks: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(keys), - .string(mode), - .bool(escape_ks), + .string(keys), + .string(mode), + .bool(escape_ks), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_feedkeys", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_feedkeys", params: params) .asCompletable() } - func input( - keys: String + public func input( + keys: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(keys), + .string(keys), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_input", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_input", params: params) .map(transform) } - func inputMouse( + public func inputMouse( button: String, action: String, modifier: String, grid: Int, row: Int, - col: Int + col: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(button), - .string(action), - .string(modifier), - .int(Int64(grid)), - .int(Int64(row)), - .int(Int64(col)), + .string(button), + .string(action), + .string(modifier), + .int(Int64(grid)), + .int(Int64(row)), + .int(Int64(col)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_input_mouse", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_input_mouse", params: params) .asCompletable() } - func replaceTermcodes( + public func replaceTermcodes( str: String, from_part: Bool, do_lt: Bool, - special: Bool + special: Bool, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(str), - .bool(from_part), - .bool(do_lt), - .bool(special), + .string(str), + .bool(from_part), + .bool(do_lt), + .bool(special), ] let transform = { (_ value: Value) throws -> String in @@ -2142,132 +3204,204 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_replace_termcodes", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_replace_termcodes", params: params) .map(transform) } - func execLua( + public func execLua( code: String, - args: RxNeovimApi.Value + args: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(code), - args, + .string(code), + args, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_exec_lua", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_exec_lua", params: params) .map(transform) } - func notify( + public func notify( msg: String, log_level: Int, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(msg), - .int(Int64(log_level)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(msg), + .int(Int64(log_level)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_notify", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_notify", params: params) .map(transform) } - func strwidth( - text: String + public func strwidth( + text: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(text), + .string(text), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_strwidth", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_strwidth", params: params) .map(transform) } - func listRuntimePaths( + public func listRuntimePaths( + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "nvim_list_runtime_paths", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_runtime_paths", params: params) .map(transform) } - func getRuntimeFile( + public func getRuntimeFile( name: String, - all: Bool + all: Bool, + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ - .string(name), - .bool(all), + .string(name), + .bool(all), ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "nvim_get_runtime_file", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_runtime_file", params: params) .map(transform) } - func setCurrentDir( - dir: String + public func setCurrentDir( + dir: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(dir), + .string(dir), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_current_dir", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_current_dir", params: params) .asCompletable() } - func getCurrentLine( + public func getCurrentLine( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> String in @@ -2278,186 +3412,319 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_current_line", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_current_line", params: params) .map(transform) } - func setCurrentLine( - line: String + public func setCurrentLine( + line: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(line), + .string(line), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_current_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_current_line", params: params) .asCompletable() } - func delCurrentLine( + public func delCurrentLine( + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ + ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_current_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_current_line", params: params) .asCompletable() } - func getVar( - name: String + public func getVar( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_var", params: params) .map(transform) } - func setVar( + public func setVar( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_var", params: params) .asCompletable() } - func delVar( - name: String + public func delVar( + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_var", params: params) .asCompletable() } - func getVvar( - name: String + public func getVvar( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_vvar", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_vvar", params: params) .map(transform) } - func setVvar( + public func setVvar( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_vvar", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_vvar", params: params) .asCompletable() } - func echo( + public func echo( chunks: RxNeovimApi.Value, history: Bool, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - chunks, - .bool(history), - .map(opts.mapToDict { (Value.string($0), $1) }), + chunks, + .bool(history), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_echo", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_echo", params: params) .asCompletable() } - func outWrite( - str: String + public func outWrite( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_out_write", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_out_write", params: params) .asCompletable() } - func errWrite( - str: String + public func errWrite( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_err_write", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_err_write", params: params) .asCompletable() } - func errWriteln( - str: String + public func errWriteln( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_err_writeln", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_err_writeln", params: params) .asCompletable() } - func listBufs( + public func listBufs( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Buffer]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Buffer] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Buffer(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Buffer(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Buffer].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_list_bufs", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_bufs", params: params) .map(transform) } - func getCurrentBuf( + public func getCurrentBuf( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Buffer in @@ -2468,44 +3735,76 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_current_buf", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_current_buf", params: params) .map(transform) } - func setCurrentBuf( - buffer: RxNeovimApi.Buffer + public func setCurrentBuf( + buffer: RxNeovimApi.Buffer, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_current_buf", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_current_buf", params: params) .asCompletable() } - func listWins( + public func listWins( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Window] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Window(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Window(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Window].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_list_wins", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_wins", params: params) .map(transform) } - func getCurrentWin( + public func getCurrentWin( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Window in @@ -2516,30 +3815,50 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_current_win", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_current_win", params: params) .map(transform) } - func setCurrentWin( - window: RxNeovimApi.Window + public func setCurrentWin( + window: RxNeovimApi.Window, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_current_win", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_current_win", params: params) .asCompletable() } - func createBuf( + public func createBuf( listed: Bool, - scratch: Bool + scratch: Bool, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .bool(listed), - .bool(scratch), + .bool(listed), + .bool(scratch), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Buffer in @@ -2550,68 +3869,110 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_create_buf", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_create_buf", params: params) .map(transform) } - func openTerm( + public func openTerm( buffer: RxNeovimApi.Buffer, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_open_term", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_open_term", params: params) .map(transform) } - func chanSend( + public func chanSend( chan: Int, - data: String + data: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(chan)), - .string(data), + .int(Int64(chan)), + .string(data), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_chan_send", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_chan_send", params: params) .asCompletable() } - func listTabpages( + public func listTabpages( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Tabpage]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Tabpage] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Tabpage(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Tabpage(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Tabpage].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_list_tabpages", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_tabpages", params: params) .map(transform) } - func getCurrentTabpage( + public func getCurrentTabpage( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Tabpage in @@ -2622,32 +3983,52 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_current_tabpage", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_current_tabpage", params: params) .map(transform) } - func setCurrentTabpage( - tabpage: RxNeovimApi.Tabpage + public func setCurrentTabpage( + tabpage: RxNeovimApi.Tabpage, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_current_tabpage", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_current_tabpage", params: params) .asCompletable() } - func paste( + public func paste( data: String, crlf: Bool, - phase: Int + phase: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(data), - .bool(crlf), - .int(Int64(phase)), + .string(data), + .bool(crlf), + .int(Int64(phase)), ] let transform = { (_ value: Value) throws -> Bool in @@ -2658,375 +4039,581 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_paste", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_paste", params: params) .map(transform) } - func put( + public func put( lines: [String], type: String, after: Bool, - follow: Bool + follow: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .array(lines.map { .string($0) }), - .string(type), - .bool(after), - .bool(follow), + .array(lines.map { .string($0) }), + .string(type), + .bool(after), + .bool(follow), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_put", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_put", params: params) .asCompletable() } - func subscribe( - event: String + public func subscribe( + event: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(event), + .string(event), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_subscribe", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_subscribe", params: params) .asCompletable() } - func unsubscribe( - event: String + public func unsubscribe( + event: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(event), + .string(event), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_unsubscribe", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_unsubscribe", params: params) .asCompletable() } - func getColorByName( - name: String + public func getColorByName( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_get_color_by_name", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_color_by_name", params: params) .map(transform) } - func getColorMap( - ) -> Single<[String: RxNeovimApi.Value]> { + public func getColorMap( + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ + ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_color_map", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_color_map", params: params) .map(transform) } - func getContext( - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + public func getContext( + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .map(opts.mapToDict { (Value.string($0), $1) }), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_context", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_context", params: params) .map(transform) } - func loadContext( - dict: [String: RxNeovimApi.Value] + public func loadContext( + dict: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .map(dict.mapToDict { (Value.string($0), $1) }), + .map(dict.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_load_context", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_load_context", params: params) .map(transform) } - func getMode( - ) -> Single<[String: RxNeovimApi.Value]> { + public func getMode( + ) -> Single> { + let params: [RxNeovimApi.Value] = [ + ] return self .sendRequest(method: "nvim_get_mode", params: params) .map { value in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } } - func getKeymap( - mode: String - ) -> Single<[[String: RxNeovimApi.Value]]> { + public func getKeymap( + mode: String, + errWhenBlocked: Bool = true + ) -> Single<[Dictionary]> { + let params: [RxNeovimApi.Value] = [ - .string(mode), + .string(mode), ] - let transform = { (_ value: Value) throws -> [[String: RxNeovimApi.Value]] in - guard let result = msgPackArrayDictToSwift(value.arrayValue) else { - throw RxNeovimApi.Error.conversion(type: [[String: RxNeovimApi.Value]].self) + let transform = { (_ value: Value) throws -> [Dictionary] in + guard let result = (msgPackArrayDictToSwift(value.arrayValue)) else { + throw RxNeovimApi.Error.conversion(type: [Dictionary].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_keymap", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_keymap", params: params) .map(transform) } - func setKeymap( + public func setKeymap( mode: String, lhs: String, rhs: String, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(mode), - .string(lhs), - .string(rhs), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(mode), + .string(lhs), + .string(rhs), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_keymap", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_keymap", params: params) .asCompletable() } - func delKeymap( + public func delKeymap( mode: String, - lhs: String + lhs: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(mode), - .string(lhs), + .string(mode), + .string(lhs), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_keymap", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_del_keymap", params: params) .asCompletable() } - func getApiInfo( + public func getApiInfo( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_api_info", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_api_info", params: params) .map(transform) } - func setClientInfo( + public func setClientInfo( name: String, - version: [String: RxNeovimApi.Value], + version: Dictionary, type: String, - methods: [String: RxNeovimApi.Value], - attributes: [String: RxNeovimApi.Value] + methods: Dictionary, + attributes: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - .map(version.mapToDict { (Value.string($0), $1) }), - .string(type), - .map(methods.mapToDict { (Value.string($0), $1) }), - .map(attributes.mapToDict { (Value.string($0), $1) }), + .string(name), + .map(version.mapToDict({ (Value.string($0), $1) })), + .string(type), + .map(methods.mapToDict({ (Value.string($0), $1) })), + .map(attributes.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_set_client_info", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_set_client_info", params: params) .asCompletable() } - func getChanInfo( - chan: Int - ) -> Single<[String: RxNeovimApi.Value]> { + public func getChanInfo( + chan: Int, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(chan)), + .int(Int64(chan)), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_chan_info", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_chan_info", params: params) .map(transform) } - func listChans( + public func listChans( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_list_chans", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_chans", params: params) .map(transform) } - func callAtomic( - calls: RxNeovimApi.Value + public func callAtomic( + calls: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - calls, + calls, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_call_atomic", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_call_atomic", params: params) .map(transform) } - func listUis( + public func listUis( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_list_uis", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_list_uis", params: params) .map(transform) } - func getProcChildren( - pid: Int + public func getProcChildren( + pid: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(pid)), + .int(Int64(pid)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_proc_children", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_proc_children", params: params) .map(transform) } - func getProc( - pid: Int + public func getProc( + pid: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(pid)), + .int(Int64(pid)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_proc", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_proc", params: params) .map(transform) } - func selectPopupmenuItem( + public func selectPopupmenuItem( item: Int, insert: Bool, finish: Bool, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(item)), - .bool(insert), - .bool(finish), - .map(opts.mapToDict { (Value.string($0), $1) }), + .int(Int64(item)), + .bool(insert), + .bool(finish), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_select_popupmenu_item", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_select_popupmenu_item", params: params) .asCompletable() } - func delMark( - name: String + public func delMark( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> Bool in @@ -3037,188 +4624,278 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_del_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_del_mark", params: params) .map(transform) } - func getMark( + public func getMark( name: String, - opts: [String: RxNeovimApi.Value] + opts: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(name), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_get_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_get_mark", params: params) .map(transform) } - func evalStatusline( + public func evalStatusline( str: String, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(str), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(str), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_eval_statusline", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_eval_statusline", params: params) .map(transform) } - func exec2( + public func exec2( src: String, - opts: [String: RxNeovimApi.Value] - ) -> Single<[String: RxNeovimApi.Value]> { + opts: Dictionary, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(src), - .map(opts.mapToDict { (Value.string($0), $1) }), + .string(src), + .map(opts.mapToDict({ (Value.string($0), $1) })), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_exec2", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_exec2", params: params) .map(transform) } - func command( - command: String + public func command( + command: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(command), + .string(command), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_command", params: params) .asCompletable() } - func eval( - expr: String + public func eval( + expr: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(expr), + .string(expr), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_eval", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_eval", params: params) .map(transform) } - func callFunction( + public func callFunction( fn: String, - args: RxNeovimApi.Value + args: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(fn), - args, + .string(fn), + args, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_call_function", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_call_function", params: params) .map(transform) } - func callDictFunction( + public func callDictFunction( dict: RxNeovimApi.Value, fn: String, - args: RxNeovimApi.Value + args: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - dict, - .string(fn), - args, + dict, + .string(fn), + args, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_call_dict_function", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_call_dict_function", params: params) .map(transform) } - func parseExpression( + public func parseExpression( expr: String, flags: String, - highlight: Bool - ) -> Single<[String: RxNeovimApi.Value]> { + highlight: Bool, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .string(expr), - .string(flags), - .bool(highlight), + .string(expr), + .string(flags), + .bool(highlight), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_parse_expression", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_parse_expression", params: params) .map(transform) } - func openWin( + public func openWin( buffer: RxNeovimApi.Buffer, enter: Bool, - config: [String: RxNeovimApi.Value] + config: Dictionary, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .bool(enter), - .map(config.mapToDict { (Value.string($0), $1) }), + .int(Int64(buffer.handle)), + .bool(enter), + .map(config.mapToDict({ (Value.string($0), $1) })), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Window in @@ -3229,50 +4906,80 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_open_win", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_open_win", params: params) .map(transform) } - func winSetConfig( + public func winSetConfig( window: RxNeovimApi.Window, - config: [String: RxNeovimApi.Value] + config: Dictionary, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .map(config.mapToDict { (Value.string($0), $1) }), + .int(Int64(window.handle)), + .map(config.mapToDict({ (Value.string($0), $1) })), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_config", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_config", params: params) .asCompletable() } - func winGetConfig( - window: RxNeovimApi.Window - ) -> Single<[String: RxNeovimApi.Value]> { + public func winGetConfig( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_config", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_config", params: params) .map(transform) } - func winGetBuf( - window: RxNeovimApi.Window + public func winGetBuf( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Buffer in @@ -3283,210 +4990,324 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_buf", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_buf", params: params) .map(transform) } - func winSetBuf( + public func winSetBuf( window: RxNeovimApi.Window, - buffer: RxNeovimApi.Buffer + buffer: RxNeovimApi.Buffer, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(buffer.handle)), + .int(Int64(window.handle)), + .int(Int64(buffer.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_buf", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_buf", params: params) .asCompletable() } - func winGetCursor( - window: RxNeovimApi.Window + public func winGetCursor( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_cursor", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_cursor", params: params) .map(transform) } - func winSetCursor( + public func winSetCursor( window: RxNeovimApi.Window, - pos: [Int] + pos: [Int], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .array(pos.map { .int(Int64($0)) }), + .int(Int64(window.handle)), + .array(pos.map { .int(Int64($0)) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_cursor", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_cursor", params: params) .asCompletable() } - func winGetHeight( - window: RxNeovimApi.Window + public func winGetHeight( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_win_get_height", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_height", params: params) .map(transform) } - func winSetHeight( + public func winSetHeight( window: RxNeovimApi.Window, - height: Int + height: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(height)), + .int(Int64(window.handle)), + .int(Int64(height)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_height", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_height", params: params) .asCompletable() } - func winGetWidth( - window: RxNeovimApi.Window + public func winGetWidth( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_win_get_width", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_width", params: params) .map(transform) } - func winSetWidth( + public func winSetWidth( window: RxNeovimApi.Window, - width: Int + width: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(width)), + .int(Int64(window.handle)), + .int(Int64(width)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_width", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_width", params: params) .asCompletable() } - func winGetVar( + public func winGetVar( window: RxNeovimApi.Window, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_var", params: params) .map(transform) } - func winSetVar( + public func winSetVar( window: RxNeovimApi.Window, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), - value, + .int(Int64(window.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_var", params: params) .asCompletable() } - func winDelVar( + public func winDelVar( window: RxNeovimApi.Window, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_del_var", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_del_var", params: params) .asCompletable() } - func winGetPosition( - window: RxNeovimApi.Window + public func winGetPosition( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_position", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_position", params: params) .map(transform) } - func winGetTabpage( - window: RxNeovimApi.Window + public func winGetTabpage( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Tabpage in @@ -3497,36 +5318,56 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_get_tabpage", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_tabpage", params: params) .map(transform) } - func winGetNumber( - window: RxNeovimApi.Window + public func winGetNumber( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "nvim_win_get_number", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_get_number", params: params) .map(transform) } - func winIsValid( - window: RxNeovimApi.Window + public func winIsValid( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -3537,171 +5378,261 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_is_valid", params: params) .map(transform) } - func winHide( - window: RxNeovimApi.Window + public func winHide( + window: RxNeovimApi.Window, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_hide", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_hide", params: params) .asCompletable() } - func winClose( + public func winClose( window: RxNeovimApi.Window, - force: Bool + force: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .bool(force), + .int(Int64(window.handle)), + .bool(force), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_close", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_close", params: params) .asCompletable() } - func winCall( + public func winCall( window: RxNeovimApi.Window, - fun: RxNeovimApi.Value + fun: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - fun, + .int(Int64(window.handle)), + fun, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_call", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "nvim_win_call", params: params) .map(transform) } - func winSetHlNs( + public func winSetHlNs( window: RxNeovimApi.Window, - ns_id: Int + ns_id: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(ns_id)), + .int(Int64(window.handle)), + .int(Int64(ns_id)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "nvim_win_set_hl_ns", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "nvim_win_set_hl_ns", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rLineCount( - buffer: RxNeovimApi.Buffer + public func rLineCount( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "buffer_line_count", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_line_count", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rGetLines( + public func rGetLines( buffer: RxNeovimApi.Buffer, start: Int, end: Int, - strict_indexing: Bool + strict_indexing: Bool, + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(strict_indexing), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(strict_indexing), ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "buffer_get_lines", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_lines", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rSetLines( + public func rSetLines( buffer: RxNeovimApi.Buffer, start: Int, end: Int, strict_indexing: Bool, - replacement: [String] + replacement: [String], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(start)), - .int(Int64(end)), - .bool(strict_indexing), - .array(replacement.map { .string($0) }), + .int(Int64(buffer.handle)), + .int(Int64(start)), + .int(Int64(end)), + .bool(strict_indexing), + .array(replacement.map { .string($0) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_lines", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_set_lines", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rGetVar( + public func rGetVar( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rGetName( - buffer: RxNeovimApi.Buffer + public func rGetName( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> String in @@ -3712,32 +5643,52 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_get_name", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_name", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rSetName( + public func rSetName( buffer: RxNeovimApi.Buffer, - name: String + name: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_name", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_set_name", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rIsValid( - buffer: RxNeovimApi.Buffer + public func rIsValid( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -3748,43 +5699,60 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_is_valid", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rGetMark( + public func rGetMark( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_get_mark", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_mark", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func ommandOutput( - command: String + public func ommandOutput( + command: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(command), + .string(command), ] let transform = { (_ value: Value) throws -> String in @@ -3795,248 +5763,368 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_command_output", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_command_output", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rGetNumber( - buffer: RxNeovimApi.Buffer + public func rGetNumber( + buffer: RxNeovimApi.Buffer, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "buffer_get_number", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_number", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rClearHighlight( + public func rClearHighlight( buffer: RxNeovimApi.Buffer, ns_id: Int, line_start: Int, - line_end: Int + line_end: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .int(Int64(line_start)), - .int(Int64(line_end)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .int(Int64(line_start)), + .int(Int64(line_end)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_clear_highlight", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_clear_highlight", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rAddHighlight( + public func rAddHighlight( buffer: RxNeovimApi.Buffer, ns_id: Int, hl_group: String, line: Int, col_start: Int, - col_end: Int + col_end: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .int(Int64(ns_id)), - .string(hl_group), - .int(Int64(line)), - .int(Int64(col_start)), - .int(Int64(col_end)), + .int(Int64(buffer.handle)), + .int(Int64(ns_id)), + .string(hl_group), + .int(Int64(line)), + .int(Int64(col_start)), + .int(Int64(col_end)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "buffer_add_highlight", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_add_highlight", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etOption( + public func etOption( name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(name), - value, + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_set_option", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etOption( - name: String + public func etOption( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_option", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rGetOption( + public func rGetOption( buffer: RxNeovimApi.Buffer, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), + .int(Int64(buffer.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "buffer_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "buffer_get_option", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func rSetOption( + public func rSetOption( buffer: RxNeovimApi.Buffer, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), - .string(name), - value, + .int(Int64(buffer.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "buffer_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "buffer_set_option", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func wGetOption( + public func wGetOption( window: RxNeovimApi.Window, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_option", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_option", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wSetOption( + public func wSetOption( window: RxNeovimApi.Window, name: String, - value: RxNeovimApi.Value + value: RxNeovimApi.Value, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), - value, + .int(Int64(window.handle)), + .string(name), + value, ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "window_set_option", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "window_set_option", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func geGetWindows( - tabpage: RxNeovimApi.Tabpage + public func geGetWindows( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Window] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Window(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Window(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Window].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_get_windows", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_get_windows", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func geGetVar( + public func geGetVar( tabpage: RxNeovimApi.Tabpage, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), - .string(name), + .int(Int64(tabpage.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_get_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func geGetWindow( - tabpage: RxNeovimApi.Tabpage + public func geGetWindow( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Window in @@ -4047,17 +6135,27 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_get_window", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_get_window", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func geIsValid( - tabpage: RxNeovimApi.Tabpage + public func geIsValid( + tabpage: RxNeovimApi.Tabpage, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -4068,95 +6166,146 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "tabpage_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "tabpage_is_valid", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func tach( + public func tach( + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ + ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "ui_detach", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "ui_detach", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func yResize( + public func yResize( width: Int, - height: Int + height: Int, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(width)), - .int(Int64(height)), + .int(Int64(width)), + .int(Int64(height)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "ui_try_resize", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "ui_try_resize", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func eedkeys( + public func eedkeys( keys: String, mode: String, - escape_ks: Bool + escape_ks: Bool, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(keys), - .string(mode), - .bool(escape_ks), + .string(keys), + .string(mode), + .bool(escape_ks), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_feedkeys", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_feedkeys", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func nput( - keys: String + public func nput( + keys: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(keys), + .string(keys), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "vim_input", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_input", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func eplaceTermcodes( + public func eplaceTermcodes( str: String, from_part: Bool, do_lt: Bool, - special: Bool + special: Bool, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(str), - .bool(from_part), - .bool(do_lt), - .bool(special), + .string(str), + .bool(from_part), + .bool(do_lt), + .bool(special), ] let transform = { (_ value: Value) throws -> String in @@ -4167,68 +6316,110 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_replace_termcodes", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_replace_termcodes", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func trwidth( - text: String + public func trwidth( + text: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(text), + .string(text), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "vim_strwidth", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_strwidth", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func istRuntimePaths( + public func istRuntimePaths( + errWhenBlocked: Bool = true ) -> Single<[String]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [String] in - guard let result = (value.arrayValue?.compactMap { v in v.stringValue }) else { + 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.sendRequest(method: "vim_list_runtime_paths", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_list_runtime_paths", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func hangeDirectory( - dir: String + public func hangeDirectory( + dir: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(dir), + .string(dir), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_change_directory", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_change_directory", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentLine( + public func etCurrentLine( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> String in @@ -4239,139 +6430,232 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_current_line", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_current_line", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentLine( - line: String + public func etCurrentLine( + line: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(line), + .string(line), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_current_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_set_current_line", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func elCurrentLine( + public func elCurrentLine( + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ + ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_del_current_line", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_del_current_line", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etVar( - name: String + public func etVar( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etVvar( - name: String + public func etVvar( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_vvar", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_vvar", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func utWrite( - str: String + public func utWrite( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_out_write", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_out_write", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func rrWrite( - str: String + public func rrWrite( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_err_write", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_err_write", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func eportError( - str: String + public func eportError( + str: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(str), + .string(str), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_report_error", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_report_error", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etBuffers( + public func etBuffers( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Buffer]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Buffer] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Buffer(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Buffer(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Buffer].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_buffers", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_buffers", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentBuffer( + public func etCurrentBuffer( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Buffer in @@ -4382,47 +6666,79 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_current_buffer", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_current_buffer", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentBuffer( - buffer: RxNeovimApi.Buffer + public func etCurrentBuffer( + buffer: RxNeovimApi.Buffer, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(buffer.handle)), + .int(Int64(buffer.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_current_buffer", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_set_current_buffer", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etWindows( + public func etWindows( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Window]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Window] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Window(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Window(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Window].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_windows", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_windows", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentWindow( + public func etCurrentWindow( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Window in @@ -4433,47 +6749,79 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_current_window", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_current_window", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentWindow( - window: RxNeovimApi.Window + public func etCurrentWindow( + window: RxNeovimApi.Window, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_current_window", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_set_current_window", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func etTabpages( + public func etTabpages( + errWhenBlocked: Bool = true ) -> Single<[RxNeovimApi.Tabpage]> { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> [RxNeovimApi.Tabpage] in - guard let result = (value.arrayValue?.compactMap { v in RxNeovimApi.Tabpage(v) }) else { + guard let result = (value.arrayValue?.compactMap({ v in RxNeovimApi.Tabpage(v) })) else { throw RxNeovimApi.Error.conversion(type: [RxNeovimApi.Tabpage].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_tabpages", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_tabpages", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentTabpage( + public func etCurrentTabpage( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Tabpage in @@ -4484,172 +6832,274 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_current_tabpage", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_current_tabpage", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etCurrentTabpage( - tabpage: RxNeovimApi.Tabpage + public func etCurrentTabpage( + tabpage: RxNeovimApi.Tabpage, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(tabpage.handle)), + .int(Int64(tabpage.handle)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_set_current_tabpage", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_set_current_tabpage", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func ubscribe( - event: String + public func ubscribe( + event: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(event), + .string(event), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_subscribe", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_subscribe", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func nsubscribe( - event: String + public func nsubscribe( + event: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(event), + .string(event), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_unsubscribe", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_unsubscribe", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func ameToColor( - name: String + public func ameToColor( + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(name), + .string(name), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "vim_name_to_color", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_name_to_color", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etColorMap( - ) -> Single<[String: RxNeovimApi.Value]> { + public func etColorMap( + errWhenBlocked: Bool = true + ) -> Single> { + let params: [RxNeovimApi.Value] = [ + ] - let transform = { (_ value: Value) throws -> [String: RxNeovimApi.Value] in - guard let result = msgPackDictToSwift(value.dictionaryValue) else { - throw RxNeovimApi.Error.conversion(type: [String: RxNeovimApi.Value].self) + let transform = { (_ value: Value) throws -> Dictionary in + guard let result = (msgPackDictToSwift(value.dictionaryValue)) else { + throw RxNeovimApi.Error.conversion(type: Dictionary.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_color_map", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_color_map", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func etApiInfo( + public func etApiInfo( + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ + ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_get_api_info", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_get_api_info", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func ommand( - command: String + public func ommand( + command: String, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .string(command), + .string(command), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "vim_command", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "vim_command", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func val( - expr: String + public func val( + expr: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(expr), + .string(expr), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_eval", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_eval", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func allFunction( + public func allFunction( fn: String, - args: RxNeovimApi.Value + args: RxNeovimApi.Value, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .string(fn), - args, + .string(fn), + args, ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "vim_call_function", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "vim_call_function", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wGetBuffer( - window: RxNeovimApi.Window + public func wGetBuffer( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Buffer in @@ -4660,175 +7110,259 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_buffer", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_buffer", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wGetCursor( - window: RxNeovimApi.Window + public func wGetCursor( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_cursor", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_cursor", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wSetCursor( + public func wSetCursor( window: RxNeovimApi.Window, - pos: [Int] + pos: [Int], + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .array(pos.map { .int(Int64($0)) }), + .int(Int64(window.handle)), + .array(pos.map { .int(Int64($0)) }), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "window_set_cursor", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "window_set_cursor", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func wGetHeight( - window: RxNeovimApi.Window + public func wGetHeight( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "window_get_height", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_height", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wSetHeight( + public func wSetHeight( window: RxNeovimApi.Window, - height: Int + height: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(height)), + .int(Int64(window.handle)), + .int(Int64(height)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "window_set_height", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "window_set_height", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func wGetWidth( - window: RxNeovimApi.Window + public func wGetWidth( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Int in - guard let result = (value.int64Value == nil ? nil : Int(value.int64Value!)) else { + 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.sendRequest(method: "window_get_width", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_width", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wSetWidth( + public func wSetWidth( window: RxNeovimApi.Window, - width: Int + width: Int, + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .int(Int64(width)), + .int(Int64(window.handle)), + .int(Int64(width)), ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "window_set_width", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "window_set_width", params: params) .asCompletable() } @available(*, deprecated, message: "This method has been deprecated.") - func wGetVar( + public func wGetVar( window: RxNeovimApi.Window, - name: String + name: String, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), - .string(name), + .int(Int64(window.handle)), + .string(name), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Value in - guard let result = Optional(value) else { + guard let result = (Optional(value)) else { throw RxNeovimApi.Error.conversion(type: RxNeovimApi.Value.self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_var", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_var", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wGetPosition( - window: RxNeovimApi.Window + public func wGetPosition( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single<[Int]> { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> [Int] in - guard let result = (value.arrayValue?.compactMap { v in - v.int64Value == nil ? nil : Int(v.int64Value!) - }) - else { + guard let result = (value.arrayValue?.compactMap({ v in (v.int64Value == nil ? nil : Int(v.int64Value!)) })) else { throw RxNeovimApi.Error.conversion(type: [Int].self) } return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_position", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_position", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wGetTabpage( - window: RxNeovimApi.Window + public func wGetTabpage( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> RxNeovimApi.Tabpage in @@ -4839,17 +7373,27 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_get_tabpage", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_get_tabpage", params: params) .map(transform) } @available(*, deprecated, message: "This method has been deprecated.") - func wIsValid( - window: RxNeovimApi.Window + public func wIsValid( + window: RxNeovimApi.Window, + errWhenBlocked: Bool = true ) -> Single { + let params: [RxNeovimApi.Value] = [ - .int(Int64(window.handle)), + .int(Int64(window.handle)), ] let transform = { (_ value: Value) throws -> Bool in @@ -4860,14 +7404,24 @@ public extension RxNeovimApi { return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "window_is_valid", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "window_is_valid", params: params) .map(transform) } + } -public extension RxNeovimApi.Buffer { - init?(_ value: RxNeovimApi.Value) { +extension RxNeovimApi.Buffer { + + public init?(_ value: RxNeovimApi.Value) { guard let (type, data) = value.extendedValue else { return nil } @@ -4884,8 +7438,9 @@ public extension RxNeovimApi.Buffer { } } -public extension RxNeovimApi.Window { - init?(_ value: RxNeovimApi.Value) { +extension RxNeovimApi.Window { + + public init?(_ value: RxNeovimApi.Value) { guard let (type, data) = value.extendedValue else { return nil } @@ -4902,8 +7457,9 @@ public extension RxNeovimApi.Window { } } -public extension RxNeovimApi.Tabpage { - init?(_ value: RxNeovimApi.Value) { +extension RxNeovimApi.Tabpage { + + public init?(_ value: RxNeovimApi.Value) { guard let (type, data) = value.extendedValue else { return nil } @@ -4920,10 +7476,8 @@ public extension RxNeovimApi.Tabpage { } } -private func msgPackDictToSwift(_ dict: [RxNeovimApi.Value: RxNeovimApi.Value]?) - -> [String: RxNeovimApi.Value]? -{ - dict?.compactMapToDict { k, v in +fileprivate func msgPackDictToSwift(_ dict: Dictionary?) -> Dictionary? { + return dict?.compactMapToDict { k, v in guard let strKey = k.stringValue else { return nil } @@ -4932,35 +7486,28 @@ private func msgPackDictToSwift(_ dict: [RxNeovimApi.Value: RxNeovimApi.Value]?) } } -private func msgPackArrayDictToSwift(_ array: [RxNeovimApi.Value]?) - -> [[String: RxNeovimApi.Value]]? -{ - array? +fileprivate func msgPackArrayDictToSwift(_ array: [RxNeovimApi.Value]?) -> [Dictionary]? { + return array? .compactMap { v in v.dictionaryValue } .compactMap { d in msgPackDictToSwift(d) } } -private extension Dictionary { - func mapToDict< - K, - V - >(_ transform: ((key: Key, value: Value)) throws -> (K, V)) rethrows -> [K: V] { +extension Dictionary { + + fileprivate func mapToDict(_ transform: ((key: Key, value: Value)) throws -> (K, V)) rethrows -> Dictionary { let array = try self.map(transform) - return self.tuplesToDict(array) + return tuplesToDict(array) } - func compactMapToDict< - K, - V - >(_ transform: ((key: Key, value: Value)) throws -> (K, V)?) rethrows -> [K: V] { + fileprivate func compactMapToDict(_ transform: ((key: Key, value: Value)) throws -> (K, V)?) rethrows -> Dictionary { let array = try self.compactMap(transform) - return self.tuplesToDict(array) + return tuplesToDict(array) } - func tuplesToDict(_ sequence: S) - -> [K: V] where S.Iterator.Element == (K, V) - { - var result = [K: V](minimumCapacity: sequence.underestimatedCount) + fileprivate func tuplesToDict(_ sequence: S) + -> Dictionary where S.Iterator.Element == (K, V) { + + var result = Dictionary(minimumCapacity: sequence.underestimatedCount) for (key, value) in sequence { result[key] = value diff --git a/RxPack/Sources/RxNeovim/RxNeovimApi.swift b/RxPack/Sources/RxNeovim/RxNeovimApi.swift index 430a10e1..d56b90f7 100644 --- a/RxPack/Sources/RxNeovim/RxNeovimApi.swift +++ b/RxPack/Sources/RxNeovim/RxNeovimApi.swift @@ -40,6 +40,19 @@ public final class RxNeovimApi { public func stop() -> Completable { self.msgpackRpc.stop() } + public func checkBlocked(_ single: Single) -> Single { + self + .getMode() + .flatMap { dict -> Single in + guard (dict["blocking"]?.boolValue ?? false) == false else { + throw RxNeovimApi.Error.blocked + } + + return single + } + } + + public func sendRequest( method: String, params: [RxNeovimApi.Value] diff --git a/RxPack/bin/generate_api_methods.py b/RxPack/bin/generate_api_methods.py index c31d2ea9..c2ac0b1a 100755 --- a/RxPack/bin/generate_api_methods.py +++ b/RxPack/bin/generate_api_methods.py @@ -12,11 +12,21 @@ import io void_func_template = Template('''\ public func ${func_name}(${args} + expectsReturnValue: Bool = false ) -> Completable { + let params: [RxNeovimApi.Value] = [ ${params} ] + if expectsReturnValue { + return self + .checkBlocked( + self.sendRequest(method: "${nvim_func_name}", params: params) + ) + .asCompletable() + } + return self .sendRequest(method: "${nvim_func_name}", params: params) .asCompletable() @@ -26,6 +36,7 @@ void_func_template = Template('''\ get_mode_func_template = Template('''\ public func ${func_name}(${args} ) -> Single<${result_type}> { + let params: [RxNeovimApi.Value] = [ ${params} ] @@ -43,7 +54,9 @@ get_mode_func_template = Template('''\ func_template = Template('''\ public func ${func_name}(${args} + errWhenBlocked: Bool = true ) -> Single<${result_type}> { + let params: [RxNeovimApi.Value] = [ ${params} ] @@ -56,6 +69,14 @@ func_template = Template('''\ return result } + if errWhenBlocked { + return self + .checkBlocked( + self.sendRequest(method: "${nvim_func_name}", params: params) + ) + .map(transform) + } + return self .sendRequest(method: "${nvim_func_name}", params: params) .map(transform) @@ -331,7 +352,6 @@ def parse_args(raw_params): params = dict(zip(names, types)) result = '\n'.join([n + ': ' + t + ',' for n, t in params.items()]) - result = result[:-1] if not result: return ''