summaryrefslogtreecommitdiff
path: root/doc/tips/vim_syntax_highlighting/ikiwiki.vim
blob: fd87f49a21678dd7f9c56ecb1ce6221246c3d977 (plain)
  1. " Vim syntax file
  2. " Language: Ikiwiki (links)
  3. " Maintainer: Recai Oktaþ (roktasATdebian.org)
  4. " Last Change: 2007 May 29
  5. " Instructions:
  6. " - make sure to use the relevant syntax file which can be found
  7. " at vim.org; below are the syntax files for markdown and reST,
  8. " respectively:
  9. " http://www.vim.org/scripts/script.php?script_id=1242
  10. " http://www.vim.org/scripts/script.php?script_id=973
  11. " - put the file into your syntax directory (e.g. ~/.vim/syntax)
  12. " - if you use markdown (with .mdwn extension) add sth like below
  13. " in your VIM startup file:
  14. " au BufNewFile,BufRead *.mdwn set ft=ikiwiki
  15. " - if you use a different markup other than markdown (e.g. reST)
  16. " make sure to setup 'g:ikiwiki_render_filetype' properly in
  17. " your startup file (skip this step for mkd.vim, it should work
  18. " out of the box)
  19. " Todo:
  20. " - revamp the whole file so as to detect valid ikiwiki directives
  21. " and parameters (needs a serious work)
  22. let s:cpo_save = &cpo
  23. set cpo&vim
  24. " Load the base syntax (default to markdown) if nothing was loaded.
  25. if !exists("b:current_syntax")
  26. let s:ikiwiki_render_filetype = "mkd"
  27. if exists("g:ikiwiki_render_filetype")
  28. let s:ikiwiki_render_filetype = g:ikiwiki_render_filetype
  29. endif
  30. exe 'runtime! syntax/' . s:ikiwiki_render_filetype . '.vim'
  31. endif
  32. unlet b:current_syntax
  33. syn case match
  34. syn region ikiwikiLinkContent matchgroup=ikiwikiLink start=+\[\[\(\w\+\s\+\)\{,1}+ end=+\]\]+ contains=ikiwikiLinkNested,ikiwikiParam,ikiwikiNoParam
  35. syn region ikiwikiLinkNested matchgroup=ikiwikiLinkNested start=+"""+ end=+"""+ contains=ikiwikiLinkContent contained
  36. " FIXME: Below is an ugly hack to prevent highlighting of simple links
  37. " as directives. Links with spaces are still problematic though.
  38. syn region ikiwikiNoParam start=+\[\[[^|=]\+|+ end=+[^|=]\+\]\]+ keepend contains=ikiwikiMagic,ikiwikiDelim
  39. syn match ikiwikiDelim "\(\[\[\|\]\]\)" contained
  40. syn match ikiwikiMagic "|" contained
  41. syn match ikiwikiParam "\<\i\+\ze=" nextgroup=ikiwikiParamAssign contained
  42. syn match ikiwikiParamAssign "=" nextgroup=ikiwikiValue contained
  43. syn region ikiwikiValue start=+"[^"]+hs=e-1 end=+[^"]"+ skip=+\\"+ keepend contains=ikiwikiValueMagic,ikiwikiDelim contained
  44. syn match ikiwikiValueMagic +\(!\<\|\*\|\<\(and\|or\)\>\|\<\i*(\|\>)\)+ contained
  45. syn sync minlines=50
  46. hi def link ikiwikiLink Statement
  47. hi def link ikiwikiLinkNested String
  48. hi def link ikiwikiLinkContent Underlined
  49. hi def link ikiwikiMagic Operator
  50. hi def link ikiwikiDelim Operator
  51. hi def link ikiwikiNoParam Underlined
  52. hi def link ikiwikiParam Identifier
  53. hi def link ikiwikiParamAssign Operator
  54. hi def link ikiwikiValue String
  55. hi def link ikiwikiValueMagic Type
  56. let b:current_syntax = "ikiwiki"
  57. unlet s:cpo_save
  58. " vim:ts=8:sts=8:noet