tilde.vim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "Description: Indent scheme for the tilde weblanguage
  2. "Author: Tobias Rundström <tobi@tobi.nu> (Invalid email address)
  3. "URL: http://tilde.tildesoftware.net
  4. "Last Change: May 8 09:15:09 CEST 2002
  5. " 2022 April: b:undo_indent added by Doug Kearns
  6. if exists ("b:did_indent")
  7. finish
  8. endif
  9. let b:did_indent = 1
  10. setlocal autoindent
  11. setlocal indentexpr=GetTildeIndent(v:lnum)
  12. setlocal indentkeys=o,O,)
  13. let b:undo_indent = "setl ai< inde< indk<"
  14. if exists("*GetTildeIndent")
  15. finish
  16. endif
  17. function GetTildeIndent(lnum)
  18. let plnum = prevnonblank(v:lnum-1)
  19. if plnum == 0
  20. return 0
  21. endif
  22. if getline(v:lnum) =~ '^\s*\~\(endif\|else\|elseif\|end\)\>'
  23. return indent(v:lnum) - shiftwidth()
  24. endif
  25. if getline(plnum) =~ '^\s*\~\(if\|foreach\|foreach_row\|xml_loop\|file_loop\|file_write\|file_append\|imap_loopsections\|imap_index\|imap_list\|ldap_search\|post_loopall\|post_loop\|file_loop\|sql_loop_num\|sql_dbmsselect\|search\|sql_loop\|post\|for\|function_define\|silent\|while\|setvalbig\|mail_create\|systempipe\|mail_send\|dual\|elseif\|else\)\>'
  26. return indent(plnum) + shiftwidth()
  27. else
  28. return -1
  29. endif
  30. endfunction