bullets-vim / bullets.vim

🔫 Bullets.vim is a Vim/NeoVim plugin for automated bullet lists.
https://doriankarter.com
Other
482 stars 35 forks source link

bullets-newline fails to trigger InsertEnter and InsertLeave events #151

Open VimWei opened 6 months ago

VimWei commented 6 months ago

brglng/vim-im-select is dedicated to automatically toggling the state of input methods, significantly improving the experience for users working with non-English input methods.

But bullets-vim conflicts with brglng/vim-im-select:

`let g:bullets_custom_mappings = [ ['nmap', 'o', '<Plug>(bullets-newline)'] ]`

o can add bullets-newline but fails to trigger vim's InsertEnter and InsertLeave events. but this trigger is required by vim-im-select.

harshad1 commented 5 months ago

FWIW, o appears to work correctly without the custom mapping - it inserts a new line below, adds the correct bullet / number, and enters insert mode..

Ignore this

VimWei commented 5 months ago

After update RIME/weasel from 0.15 to 0.16 : https://github.com/rime/weasel/releases/tag/0.16.0

There have been some changes in the results:

  1. o can add bullets-newline and trigger vim-im-select properly.
  2. But O with the following definition fails to trigger vim-im-select:
    function! SmartBulletsNewlineAbove()
        let l:save_cursor = getcurpos()
        let l:current_line_num = l:save_cursor[1]
        execute "normal! \<Plug>(bullets-newline)"
        if line('.') > l:current_line_num
            execute line('.') . 'move ' . (l:current_line_num - 1)
        endif
        execute "normal! \<Plug>(bullets-renumber)"
        call setpos('.', [0, l:current_line_num, 0, 0])
        call feedkeys('A', 'i')
    endfunction

    let g:bullets_custom_mappings = [ ['nmap', 'O', ':call SmartBulletsNewlineAbove()<CR>']]

It seems that the issue lies with the line: execute "normal! \<Plug>(bullets-newline)"

Hoping that Bullets.vim can provide an official <Plug>(bullets-newline-above) for better compatibility with other plugins.

ref: https://github.com/bullets-vim/bullets.vim/issues/110