Переход функции Vim на Neovim - PullRequest
0 голосов
/ 21 октября 2019

У меня была эта функция, работающая в vim:

" ---------------
" Auto record visual mode
" ---------------
" Allows executing operators with a different syntax.
" First we go to visual mode and we can select with the target-objects the text
" we wan to work on. Then we execute the operation. Finally we can repeat this
" with gv (goto visual, repeat visual)
nmap gv v@v

let s:last_mode = 'n'
augroup visual_enter_normal_enter
    au!
    au SafeState * call s:fire_visual_enter_normal_enter()
augroup END

fu! s:fire_visual_enter_normal_enter() abort
    let mode = mode()
    if s:last_mode is# 'n'
    \ && index(['v', 'V', "\<c-v>"], mode) != -1
    \ && exists('#User#VisualEnter')
        do <nomodeline> User VisualEnter
    elseif s:last_mode isnot# 'n'
    \ && mode() is# 'n'
    \ && exists('#User#NormalEnter')
        do <nomodeline> User NormalEnter
    endif
    let s:last_mode = mode
endfu

augroup record_keys_in_visual_mode
    au!
    au User VisualEnter call s:recording_start()
    au User NormalEnter call s:recording_stop()
augroup END

fu! s:recording_start() abort
    if reg_recording() is# ''
        call feedkeys('qv', 'int')
    endif
endfu

fu! s:recording_stop() abort
    if reg_recording() is# 'v' && mode() is# 'n'
        call feedkeys('q', 'int')
    endif
endfu

Я перешел на Neovim и все плагины и все работает, но эта функция жалуется, что:

E216: No such group or event: SafeState * call s:fire_visual_enter_normal_enter()

Интересно, как правильно перенести функции vim на neovim.

...