pandoc.vim 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. " vim: set fdm=marker et ts=4 sw=4 sts=4:
  2. " File: pandoc.vim
  3. " Description: pandoc support for vim
  4. " Author: Felipe Morales
  5. " Should we load? {{{1
  6. if exists('g:pandoc#loaded') && g:pandoc#loaded || &compatible
  7. finish
  8. endif
  9. let g:pandoc#loaded = 1
  10. " }}}1
  11. " Globals: {{{1
  12. " we use this to configure to what filetypes we attach to
  13. let g:pandoc_extensions_table = {
  14. \'beamer': ['beamer', 'bmr'],
  15. \'extra': ['text', 'txt'],
  16. \'html': ['html', 'htm'],
  17. \'json' : ['json'],
  18. \'latex': ['latex', 'tex', 'ltx'],
  19. \'markdown' : ['markdown', 'mkd', 'md'],
  20. \'pandoc': ['pandoc', 'pdk', 'pd', 'pdc'],
  21. \'native' : ['hs'],
  22. \'rst' : ['rst'],
  23. \'textile': ['textile'] }
  24. " }}}1
  25. " Defaults: {{{1
  26. " Modules: {{{2
  27. " Enabled modules {{{3
  28. if !exists('g:pandoc#modules#enabled')
  29. let g:pandoc#modules#enabled = [
  30. \'yaml',
  31. \'bibliographies',
  32. \'completion',
  33. \'command',
  34. \'folding',
  35. \'formatting',
  36. \'indent',
  37. \'menu',
  38. \'metadata',
  39. \'keyboard' ,
  40. \'toc',
  41. \'spell',
  42. \'hypertext']
  43. endif
  44. " Auxiliary module blacklist. {{{3
  45. if !exists('g:pandoc#modules#disabled')
  46. let g:pandoc#modules#disabled = []
  47. endif
  48. if !exists('g:pandoc#modules#warn_disabled')
  49. let g:pandoc#modules#warn_disabled = 1
  50. endif
  51. if v:version < 704
  52. let s:module_disabled = 0
  53. for incompatible_module in ['bibliographies', 'command']
  54. " user might have disabled them himself, check that
  55. if index(g:pandoc#modules#disabled, incompatible_module) == -1
  56. let g:pandoc#modules#disabled = add(g:pandoc#modules#disabled, incompatible_module)
  57. let s:module_disabled = 1
  58. endif
  59. endfor
  60. " only message the user if we have extended g:pandoc#modules#disabled
  61. " automatically
  62. if s:module_disabled == 1 && g:pandoc#modules#warn_disabled
  63. echomsg "vim-pandoc: 'bibliographies' and 'command' modules require vim >= 7.4 and have been disabled."
  64. endif
  65. endif
  66. "}}}
  67. " Markups to handle {{{3
  68. if !exists('g:pandoc#filetypes#handled')
  69. let g:pandoc#filetypes#handled = [
  70. \'pandoc',
  71. \'rst',
  72. \'textile']
  73. if get(g:, 'pandoc#filetypes#pandoc_markdown', 1) == 1
  74. let g:pandoc#filetypes#handled += ['markdown']
  75. endif
  76. endif
  77. "}}}
  78. "}}}1
  79. " Autocommands: {{{1
  80. " We must do this here instead of ftdetect because we need to be able to use
  81. " the value of g:pandoc#filetypes#handled and
  82. " g:pandoc#filetypes#pandoc_markdown
  83. " augroup pandoc_attach {{{2
  84. " this loads the vim-pandoc functionality for configured extensions
  85. augroup pandoc_attach
  86. let s:exts = []
  87. for ext in g:pandoc#filetypes#handled
  88. call extend(s:exts, map(g:pandoc_extensions_table[ext], '"*." . v:val'))
  89. endfor
  90. execute 'au BufRead,BufNewFile,BufFilePost ' . join(s:exts, ',') . ' runtime ftplugin/pandoc.vim'
  91. augroup END
  92. "}}}
  93. " }}}1