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

您好,我想要实现一个功能(请指导下) #35

Closed Leiyi548 closed 2 years ago

Leiyi548 commented 2 years ago

我想能够每打四个英文字母,就能够自动上屏,而不用自己打回车,如果有多个答案,就不让他自动选择,此时可以用数字来选择,我看了你的代码,也不是很清楚。请指教!

Leiyi548 commented 2 years ago

就是我打四个英文字母,然后就有中文然后自动选择第一个,如果没有这4个没有的话就自动清除。

ZSaberLv0 commented 2 years ago

更新一下, 加了个 ZFVimIME_state(), 然后可以类似这样玩:

function! s:check()
    let state = ZFVimIME_state()
    if len(state['key']) == 4
        if !empty(state['list'])
            call feedkeys("\<space>", 't')
        else
            call feedkeys(repeat("\<bs>", len(state['key'])), "nt")
        endif
    endif
endfunction
autocmd User ZFVimIM_event_OnUpdateOmni call s:check()
Leiyi548 commented 2 years ago

@ZSaberLv0 我怎么调用这个功能 ?

ZSaberLv0 commented 2 years ago

代码不是都贴了么,丢vimrc就行

Leiyi548 commented 2 years ago

@ZSaberLv0 没用

Leiyi548 commented 2 years ago

image @ZSaberLv0

Leiyi548 commented 2 years ago

@ZSaberLv0 我加在插件的/Users/macos/.local/share/lunarvim/site/pack/packer/start/ZFVimIM/plugin/ZFVimIM_IME.vim

Leiyi548 commented 2 years ago

@ZSaberLv0 生效了

Leiyi548 commented 2 years ago

@ZSaberLv0 再问下能不能不让他猜测我我这个词库有啥就打啥。比如我打一个字,本来是三个拼音打出来对应词库的就能出来对应单词,后面第四个字符找不到 就会重新去词库搜索。。 怎么取消这个输入模式,只按词库有的没有就拼音显示呢。

ZSaberLv0 commented 2 years ago

更新一下, 然后这几个参数自己看需求玩耍

let g:ZFVimIM_sentence = 0
let g:ZFVimIM_predictLimit = 0
let g:ZFVimIM_matchLimit = -1
Leiyi548 commented 2 years ago

@ZSaberLv0 niceeeeeeeeeee!!!非常感谢你!!!!!!!!!!!!!

Leiyi548 commented 2 years ago

@ZSaberLv0 请问我第一个能不能把匹配的显示出来,比如我打 hvvi 这有两个匹配项,这个时候我就不想让他自动的没掉, 我能够进行选择。

ZSaberLv0 commented 2 years ago

更新一下, 加了个 ZFVimIME_state(), 然后可以类似这样玩:

function! s:check()
    let state = ZFVimIME_state()
    if len(state['key']) == 4
        if !empty(state['list'])
            call feedkeys("\<space>", 't')
        else
            call feedkeys(repeat("\<bs>", len(state['key'])), "nt")
        endif
    endif
endfunction
autocmd User ZFVimIM_event_OnUpdateOmni call s:check()

可以参考这段自己实现想要的逻辑