cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

Is it possible to make lexima continue a bullet list? #150

Closed eight04 closed 6 months ago

eight04 commented 6 months ago

I tried something like:

call lexima#add_rule({'char': '<CR>', 'at': '\v^\s*\*\s+.*', 'input': '<CR>* ' })

It does work partially but if I try matching the cursor:

call lexima#add_rule({'char': '<CR>', 'at': '\v^\s*\*\s+.*\%#', 'input': '<CR>* ' })

It no longer works.

cohama commented 6 months ago

\v can not be used with \%# because it means literary %# sequence matching but not cursor matching.

How about this. call lexima#add_rule(#{char: '<CR>', at: '^\s*\*\s\+.*\%#', input: '<CR>* ' })

eight04 commented 6 months ago

👍

I tried mapping it to bullets.vim plugin (https://github.com/dkarter/bullets.vim/blob/746f92ae05cdcc988857d8e76418326f07af9494/plugin/bullets.vim#L1008C16-L1008C16)

call lexima#add_rule(#{char: '<CR>', at: '^\s*\*\s\+.*\%#', input: '<C-r>=BulletNewLine()<CR>' })

function! BulletNewLine()
  execute "normal \<Plug>(bullets-newline)"
  return ''
endfunction

Unfortunately, it seems there are some conflicts with cursor positioning so the cursor always ends with *| instead of * |.