mirror of
https://github.com/qvacua/vimr.git
synced 2024-09-11 17:15:34 +03:00
Do not check blocked
This commit is contained in:
parent
87ff3929b6
commit
68afc66a8b
@ -1,6 +1,6 @@
|
||||
--swiftversion 5.9
|
||||
|
||||
--exclude Carthage,third-party,**/*.generated.swift,**/*.template.swift
|
||||
--exclude Carthage,third-party,**/*.template.swift
|
||||
|
||||
--indent 2
|
||||
--maxwidth 100
|
||||
|
@ -43,7 +43,7 @@ public extension NvimView {
|
||||
let finalInput = isWrapNeeded ? self.wrapNamedKeys(flags + namedChars)
|
||||
: self.vimPlainString(chars)
|
||||
|
||||
_ = self.api.input(keys: finalInput, errWhenBlocked: false).syncValue()
|
||||
_ = self.api.input(keys: finalInput).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), errWhenBlocked: false).syncValue()
|
||||
_ = self.api.input(keys: self.vimPlainString(text)).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"), errWhenBlocked: false)
|
||||
.input(keys: self.wrapNamedKeys("Nul"))
|
||||
.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}", errWhenBlocked: false) // AKA ^^
|
||||
.input(keys: "\u{1e}") // 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" {
|
||||
// <C-2> should generate \0, escaping as above
|
||||
self.api
|
||||
.input(keys: self.wrapNamedKeys("Nul"), errWhenBlocked: false)
|
||||
.input(keys: self.wrapNamedKeys("Nul"))
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.log.error("Error in \(#function): \(error)")
|
||||
})
|
||||
|
@ -42,14 +42,14 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .insert, .replace:
|
||||
self.api
|
||||
.input(keys: "<Esc>ui", errWhenBlocked: false)
|
||||
.input(keys: "<Esc>ui")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not undo", cause: error))
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
case .normal, .visual:
|
||||
self.api
|
||||
.input(keys: "u", errWhenBlocked: false)
|
||||
.input(keys: "u")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not undo", cause: error))
|
||||
})
|
||||
@ -63,14 +63,14 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .insert, .replace:
|
||||
self.api
|
||||
.input(keys: "<Esc><C-r>i", errWhenBlocked: false)
|
||||
.input(keys: "<Esc><C-r>i")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not redo", cause: error))
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
case .normal, .visual:
|
||||
self.api
|
||||
.input(keys: "<C-r>", errWhenBlocked: false)
|
||||
.input(keys: "<C-r>")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not redo", cause: error))
|
||||
})
|
||||
@ -84,7 +84,7 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .visual, .normal:
|
||||
self.api
|
||||
.input(keys: "\"+d", errWhenBlocked: false)
|
||||
.input(keys: "\"+d")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not cut", cause: error))
|
||||
})
|
||||
@ -98,7 +98,7 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .visual, .normal:
|
||||
self.api
|
||||
.input(keys: "\"+y", errWhenBlocked: false)
|
||||
.input(keys: "\"+y")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not copy", cause: error))
|
||||
})
|
||||
@ -124,7 +124,7 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .normal, .visual:
|
||||
self.api
|
||||
.input(keys: "x", errWhenBlocked: false)
|
||||
.input(keys: "x")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not delete", cause: error))
|
||||
})
|
||||
@ -138,14 +138,14 @@ extension NvimView {
|
||||
switch self.mode {
|
||||
case .insert, .visual:
|
||||
self.api
|
||||
.input(keys: "<Esc>ggVG", errWhenBlocked: false)
|
||||
.input(keys: "<Esc>ggVG")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not select all", cause: error))
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
default:
|
||||
self.api
|
||||
.input(keys: "ggVG", errWhenBlocked: false)
|
||||
.input(keys: "ggVG")
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.eventsSubject.onNext(.apiError(msg: "Could not select all", cause: error))
|
||||
})
|
||||
|
@ -59,8 +59,8 @@ public extension NvimView {
|
||||
cellPosition: cellPosition
|
||||
)
|
||||
self.api
|
||||
.input(keys: vimInputX, errWhenBlocked: false).asCompletable()
|
||||
.andThen(self.api.input(keys: vimInputY, errWhenBlocked: false).asCompletable())
|
||||
.input(keys: vimInputX).asCompletable()
|
||||
.andThen(self.api.input(keys: vimInputY).asCompletable())
|
||||
.subscribe(onError: { [weak self] error in
|
||||
self?.log.error("Error in \(#function): \(error)")
|
||||
})
|
||||
@ -169,7 +169,7 @@ public extension NvimView {
|
||||
}
|
||||
|
||||
self.api
|
||||
.input(keys: result, errWhenBlocked: false)
|
||||
.input(keys: result)
|
||||
.subscribe(onFailure: { [weak self] error in
|
||||
self?.log.error("Error in \(#function): \(error)")
|
||||
})
|
||||
|
@ -99,7 +99,7 @@ extension NvimView {
|
||||
// NvimView.swift
|
||||
try? self.api.run(inPipe: inPipe, outPipe: outPipe, errorPipe: errorPipe)
|
||||
.andThen(
|
||||
self.api.getApiInfo(errWhenBlocked: false)
|
||||
self.api.getApiInfo()
|
||||
.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: [:], errWhenBlocked: false)
|
||||
""", opts: [:])
|
||||
// swiftformat:enable all
|
||||
.asCompletable()
|
||||
}
|
||||
|
@ -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(errWhenBlocked: false)
|
||||
self.api.getApiInfo()
|
||||
.flatMapCompletable { value in
|
||||
guard let info = value.arrayValue,
|
||||
info.count == 2,
|
||||
@ -368,18 +368,14 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie
|
||||
autocmd BufEnter * call rpcnotify(\(channel), 'autocommand', 'bufenter', str2nr(expand('<abuf>')))
|
||||
autocmd DirChanged * call rpcnotify(\( channel), 'autocommand', 'dirchanged', expand('<afile>'))
|
||||
autocmd BufModifiedSet * call rpcnotify(\(channel), 'autocommand', 'bufmodifiedset', str2nr(expand('<abuf>')), getbufinfo(str2nr(expand('<abuf>')))[0].changed)
|
||||
""", opts: [:], errWhenBlocked: false)
|
||||
""", opts: [:])
|
||||
// swiftformat:enable all
|
||||
.asCompletable()
|
||||
.andThen(self.api.subscribe(event: NvimView.rpcEventName, expectsReturnValue: false))
|
||||
.andThen(self.api.subscribe(event: NvimView.rpcEventName))
|
||||
.andThen(
|
||||
self.sourceFileUrls.reduce(.empty()) { prev, url in
|
||||
prev.andThen(
|
||||
self.api.exec2(
|
||||
src: "source \(url.shellEscapedPath)",
|
||||
opts: ["output": true],
|
||||
errWhenBlocked: false
|
||||
)
|
||||
self.api.exec2(src: "source \(url.shellEscapedPath)", opts: ["output": true])
|
||||
.map { retval in
|
||||
guard let output = retval["output"]?.stringValue else {
|
||||
throw RxNeovimApi.Error
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -216,7 +216,11 @@ public final class RxMsgpackRpc {
|
||||
self?.errorPipe = nil
|
||||
|
||||
self?.streamSubject.onCompleted()
|
||||
self?.singles.forEach { _, single in single(.failure(Error(msg: "Rpc closed"))) }
|
||||
self?.singles.forEach { msgid, single in single(.success(.init(
|
||||
msgid: msgid,
|
||||
error: .nil,
|
||||
result: .nil
|
||||
))) }
|
||||
|
||||
self?.log.info("RxMsgpackRpc closed")
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ class RxNeovimApiExample: XCTestCase {
|
||||
formatter.dateFormat = "mm:ss.SSS"
|
||||
for i in 0...100 {
|
||||
let date = Date()
|
||||
let response = try self.api.commandOutput(
|
||||
command: "echo '\(i) \(formatter.string(from: date))'"
|
||||
let response = try self.api.exec2(
|
||||
src: "echo '\(i) \(formatter.string(from: date))'", opts: ["output": true]
|
||||
).toBlocking().first()!
|
||||
Swift.print(response)
|
||||
}
|
||||
|
@ -12,23 +12,13 @@ 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.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: expectsReturnValue)
|
||||
)
|
||||
.asCompletable()
|
||||
}
|
||||
|
||||
return self
|
||||
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: expectsReturnValue)
|
||||
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
|
||||
.asCompletable()
|
||||
}
|
||||
''')
|
||||
@ -36,7 +26,6 @@ void_func_template = Template('''\
|
||||
get_mode_func_template = Template('''\
|
||||
public func ${func_name}(${args}
|
||||
) -> Single<${result_type}> {
|
||||
|
||||
let params: [RxNeovimApi.Value] = [
|
||||
${params}
|
||||
]
|
||||
@ -54,9 +43,7 @@ get_mode_func_template = Template('''\
|
||||
|
||||
func_template = Template('''\
|
||||
public func ${func_name}(${args}
|
||||
errWhenBlocked: Bool = true
|
||||
) -> Single<${result_type}> {
|
||||
|
||||
let params: [RxNeovimApi.Value] = [
|
||||
${params}
|
||||
]
|
||||
@ -69,14 +56,6 @@ func_template = Template('''\
|
||||
return result
|
||||
}
|
||||
|
||||
if errWhenBlocked {
|
||||
return self
|
||||
.checkBlocked(
|
||||
self.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
|
||||
)
|
||||
.map(transform)
|
||||
}
|
||||
|
||||
return self
|
||||
.rpc(method: "${nvim_func_name}", params: params, expectsReturnValue: true)
|
||||
.map(transform)
|
||||
@ -352,6 +331,7 @@ 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 ''
|
||||
|
||||
|
@ -15,6 +15,7 @@ main() {
|
||||
|
||||
pushd RxPack >/dev/null
|
||||
NVIM_PATH="../Neovim/build/bin/nvim" ./bin/generate_api_methods.py
|
||||
swiftformat ./Sources/RxNeovim/RxNeovimApi.generated.swift
|
||||
popd >/dev/null
|
||||
|
||||
popd >/dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user