framescript.vim 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. " Vim indent file
  2. " Language: FrameScript
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
  5. " Last Change: 24 Sep 2021
  6. if exists("b:did_indent")
  7. finish
  8. endif
  9. let b:did_indent = 1
  10. setlocal indentexpr=GetFrameScriptIndent()
  11. setlocal indentkeys=!^F,o,O,0=~Else,0=~EndIf,0=~EndLoop,0=~EndSub
  12. setlocal nosmartindent
  13. let b:undo_indent = "setl inde< indk< si<"
  14. if exists("*GetFrameScriptIndent")
  15. finish
  16. endif
  17. function GetFrameScriptIndent()
  18. let lnum = prevnonblank(v:lnum - 1)
  19. if lnum == 0
  20. return 0
  21. endif
  22. if getline(v:lnum) =~ '^\s*\*'
  23. return cindent(v:lnum)
  24. endif
  25. let ind = indent(lnum)
  26. if getline(lnum) =~? '^\s*\%(If\|Loop\|Sub\)'
  27. let ind = ind + shiftwidth()
  28. endif
  29. if getline(v:lnum) =~? '^\s*\%(Else\|End\%(If\|Loop\|Sub\)\)'
  30. let ind = ind - shiftwidth()
  31. endif
  32. return ind
  33. endfunction