cohama / lexima.vim

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

Lua endwise rules #107

Closed gegoune closed 2 years ago

gegoune commented 3 years ago

Please consider adding endwise rules for Lua filetype. Thanks!

curist commented 3 years ago
function! s:add_rule(at, end, filetype, syntax)
  return lexima#add_rule({
  \ 'char': '<CR>',
  \ 'input': '<CR>',
  \ 'input_after': '<CR>' . a:end,
  \ 'at': a:at,
  \ 'except': '\C\v^(\s*)\S.*%#\n%(%(\s*|\1\s.+)\n)*\1' . a:end,
  \ 'filetype': a:filetype,
  \ 'syntax': a:syntax,
  \ })
endfunction

call <sid>add_rule('\%(^\s*#.*\)\@<!\<\%(function\)\>\%(.*\<end\>\)\@!.*\%#', 'end', 'lua', [])
call <sid>add_rule('\%(^\s*#.*\)\@<!\s*\<\%(do\|then\)\s*\%#', 'end', 'lua', [])

This project seems to be less active recently; without upstream adding lua support, adding above config should do the work.