mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 15:25:14 +03:00
Reorder Neovim launch init sequence
Colorscheme change notification still not working
This commit is contained in:
parent
3a0b8a6ebf
commit
ca8c7fedb6
@ -93,10 +93,10 @@ extension NvimView {
|
||||
// We wait here, since the user of NvimView cannot subscribe
|
||||
// on the Completable. We could demand that the user call launchNeoVim()
|
||||
// by themselves, but...
|
||||
var c: Int32 = 0 // FIXME
|
||||
try?
|
||||
self.api.run(at: sockPath, inPipe: inPipe, outPipe: outPipe, errorPipe: errorPipe)
|
||||
.andThen(self.api.getApiInfo(errWhenBlocked: false).map { value in
|
||||
try? self.api.run(at: sockPath, inPipe: inPipe, outPipe: outPipe, errorPipe: errorPipe)
|
||||
.andThen(
|
||||
self.api.getApiInfo(errWhenBlocked: false)
|
||||
.map { value in
|
||||
guard let info = value.arrayValue,
|
||||
info.count == 2,
|
||||
let channel = info[0].int32Value,
|
||||
@ -114,70 +114,65 @@ extension NvimView {
|
||||
self.eventsSubject.onNext(.ipcBecameInvalid(
|
||||
"Incompatible neovim version \(major).\(minor)"
|
||||
))
|
||||
throw RxNeovimApi.Error
|
||||
.exception(message: "Incompatible neovim version.")
|
||||
throw RxNeovimApi.Error.exception(message: "Incompatible neovim version.")
|
||||
}
|
||||
|
||||
c = channel
|
||||
|
||||
return channel
|
||||
}.asCompletable())
|
||||
.andThen(
|
||||
self.api.command(command: "let g:gui_vimr = 1", expectsReturnValue: false)
|
||||
)
|
||||
.andThen(self.api.uiAttach(width: size.width, height: size.height, options: [
|
||||
"ext_linegrid": true,
|
||||
"ext_multigrid": false,
|
||||
"ext_tabline": MessagePackValue(self.usesCustomTabBar),
|
||||
"rgb": true,
|
||||
]))
|
||||
.andThen(
|
||||
}
|
||||
.map { (channel: Int32) in
|
||||
self.api.exec2(src: """
|
||||
":augroup vimr
|
||||
":augroup!
|
||||
:autocmd VimEnter * call rpcnotify(\(c), 'autocommand', 'vimenter')
|
||||
:autocmd VimEnter * call rpcnotify(\(channel), 'autocommand', 'vimenter')
|
||||
:autocmd BufWinEnter * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'bufwinenter', str2nr(expand('<abuf>')))
|
||||
:autocmd BufWinEnter * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'bufwinleave', str2nr(expand('<abuf>')))
|
||||
:autocmd TabEnter * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'tabenter', str2nr(expand('<abuf>')))
|
||||
:autocmd BufWritePost * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'bufwritepost', str2nr(expand('<abuf>')))
|
||||
:autocmd BufEnter * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'bufenter', str2nr(expand('<abuf>')))
|
||||
:autocmd DirChanged * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'dirchanged', expand('<afile>'))
|
||||
:autocmd ColorScheme * call rpcnotify(\(c), 'autocommand', 'colorscheme', \
|
||||
: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 ExitPre * call rpcnotify(\(c), 'autocommand', 'exitpre')
|
||||
:autocmd ExitPre * call rpcnotify(\(channel), 'autocommand', 'exitpre')
|
||||
:autocmd BufModifiedSet * call rpcnotify(\(
|
||||
c
|
||||
channel
|
||||
), 'autocommand', 'bufmodifiedset', \
|
||||
str2nr(expand('<abuf>')), getbufinfo(str2nr(expand('<abuf>')))[0].changed)
|
||||
":augroup END
|
||||
""", opts: [:], errWhenBlocked: false).asCompletable()
|
||||
""", opts: [:], errWhenBlocked: false)
|
||||
}
|
||||
.asCompletable()
|
||||
)
|
||||
.andThen(self.api.command(command: "let g:gui_vimr = 1", expectsReturnValue: false))
|
||||
.andThen(
|
||||
self.api.uiAttach(width: size.width, height: size.height, options: [
|
||||
"ext_linegrid": true,
|
||||
"ext_multigrid": false,
|
||||
"ext_tabline": MessagePackValue(self.usesCustomTabBar),
|
||||
"rgb": true,
|
||||
])
|
||||
)
|
||||
.andThen(
|
||||
self.sourceFileUrls.reduce(Completable.empty()) { prev, url in
|
||||
prev
|
||||
.andThen(
|
||||
self.sourceFileUrls.reduce(.empty()) { prev, url in
|
||||
prev.andThen(
|
||||
self.api.exec2(src: "source \(url.shellEscapedPath)", opts: ["output": true])
|
||||
.map {
|
||||
retval in
|
||||
guard let output_value = retval["output"] ?? retval["output"],
|
||||
let output = output_value.stringValue
|
||||
else {
|
||||
.map { retval in
|
||||
guard let output = retval["output"]?.stringValue else {
|
||||
throw RxNeovimApi.Error
|
||||
.exception(message: "Could not convert values to output.")
|
||||
}
|
||||
@ -187,7 +182,8 @@ extension NvimView {
|
||||
)
|
||||
}
|
||||
)
|
||||
.andThen(self.api.subscribe(event: NvimView.rpcEventName)).wait()
|
||||
.andThen(self.api.subscribe(event: NvimView.rpcEventName))
|
||||
.wait()
|
||||
}
|
||||
|
||||
private func randomEmoji() -> String {
|
||||
|
Loading…
Reference in New Issue
Block a user