context.vim 752 B

12345678910111213141516171819202122232425262728293031323334353637
  1. " ConTeXt indent file
  2. " Language: ConTeXt typesetting engine
  3. " Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
  4. " Last Change: 2016 Oct 15
  5. if exists("b:did_indent")
  6. finish
  7. endif
  8. if !get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
  9. finish
  10. endif
  11. " Load MetaPost indentation script
  12. runtime! indent/mp.vim
  13. let s:keepcpo= &cpo
  14. set cpo&vim
  15. setlocal indentexpr=GetConTeXtIndent()
  16. let b:undo_indent = "setl indentexpr<"
  17. function! GetConTeXtIndent()
  18. " Use MetaPost rules inside MetaPost graphic environments
  19. if len(synstack(v:lnum, 1)) > 0 &&
  20. \ synIDattr(synstack(v:lnum, 1)[0], "name") ==# 'contextMPGraphic'
  21. return GetMetaPostIndent()
  22. endif
  23. return -1
  24. endfunc
  25. let &cpo = s:keepcpo
  26. unlet s:keepcpo
  27. " vim:sw=2