ZSaberLv0 / ZFVimIM

vim输入法 / Vim Input Method by pure vim script, support: user word, dynamic word priority, cloud db files
204 stars 14 forks source link

Async `upload` when using `local mode` #12

Closed suliveevil closed 4 years ago

suliveevil commented 4 years ago

Entering Vim and ZFVimIM is fast, but not when quit Vim. It seems only when :q ZFVimIM update the pinyin_count.txt which is time consuming.

I installed ZFVimJob, and ZFJobAvailable() is 1. This is my config file:

https://github.com/suliveevil/ZFVimIM_pinyin/blob/master/plugin/ZFVimIM_pinyin.vim


" config
let g:ZFVimIM_cloudSync_enable=1
let g:ZFVimIM_cloudAsync_autoInit=1
let g:ZFVimIM_cloudAsync_enable=5000
let g:ZFVimIM_cloudAsync_timeout=30000

" path(git/local)
let s:repoPath=expand('<sfile>:p:h:h')
function! s:dbInit()
    let repoPath = s:repoPath
    let dbFile = '/misc/pinyin.txt'
    let dbCountFile = '/misc/pinyin_count.txt'

    let db = ZFVimIM_dbInit({
                \   'name' : 'zh_CN',
                \ })

    call ZFVimIM_cloudRegister({
                \   'mode' : 'local',
                \   'repoPath' : repoPath,
                \   'dbFile' : dbFile,
                \   'dbCountFile' : dbCountFile,
                \   'dbId' : db['dbId'],
                \ })

endfunction

augroup ZFVimIM_pinyin_augroup
    autocmd!
    autocmd User ZFVimIM_event_OnDbInit call s:dbInit()
augroup END
ZSaberLv0 commented 4 years ago

it's a designed behavior, when there's db changes haven't been uploaded, we would perform sync upload before quitting vim, to prevent your changes from being lost

to pass this:

suliveevil commented 4 years ago

Thank you very much.

suliveevil commented 4 years ago

Is it possible to give user more choice on syncing? Choose when to sync and upload: InsertLeave BufferLeave or :q. Move the sync and upload forward and the delay will be invisible, just like the opposite of lazyload.

ZSaberLv0 commented 4 years ago

:IMCloud or call ZFVimIM_uploadAllSync() or call ZFVimIM_uploadAllAsync() whenever you want

suliveevil commented 4 years ago

Wow, this is great ! Just like how I remap the key.