chatito.vim 731 B

123456789101112131415161718192021222324252627282930313233
  1. " Vim indent file
  2. " Language: Chatito
  3. " Maintainer: ObserverOfTime <chronobserver@disroot.org>
  4. " Last Change: 2022 Sep 20
  5. if exists('b:did_indent')
  6. finish
  7. endif
  8. let b:did_indent = 1
  9. setlocal indentexpr=GetChatitoIndent()
  10. setlocal indentkeys=o,O,*<Return>,0#,!^F
  11. let b:undo_indent = 'setl inde< indk<'
  12. if exists('*GetChatitoIndent')
  13. finish
  14. endif
  15. function GetChatitoIndent()
  16. let l:prev = v:lnum - 1
  17. if getline(prevnonblank(l:prev)) =~# '^[~%@]\['
  18. " shift indent after definitions
  19. return shiftwidth()
  20. elseif getline(l:prev) !~# '^\s*$'
  21. " maintain indent in sentences
  22. return indent(l:prev)
  23. else
  24. " reset indent after a blank line
  25. return 0
  26. end
  27. endfunction