pandoc.vim 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. " vim: set fdm=marker et ts=4 sw=4 sts=4:
  2. " File: ftplugin/pandoc.vim
  3. " Description: vim-pandoc-handled buffer settings
  4. " Author: Felipe Morales
  5. " Source the plugin already here as Neovim has changed their loading order,
  6. " and without it, the variables being checked below is not present.
  7. "
  8. " GH: https://github.com/neovim/neovim/issues/19008
  9. " GH: https://github.com/vim-pandoc/vim-pandoc/issues/433
  10. runtime! plugin/pandoc.vim
  11. if (exists('b:did_ftplugin'))
  12. finish
  13. endif
  14. let b:did_ftplugin = 1
  15. let s:cpo_save = &cpoptions
  16. set cpoptions&vim
  17. " Start a new auto command group for all this plugin's hooks
  18. augroup VimPandoc
  19. autocmd!
  20. augroup END
  21. " Modules: {{{1
  22. " we initialize stuff depending on the values of g:pandoc#modules#enabled and
  23. " g:pandoc#modules#disabled so this ftplugin is simply a loader.
  24. "
  25. let s:enabled_modules = []
  26. for module in g:pandoc#modules#enabled
  27. if index(g:pandoc#modules#disabled, module) == -1
  28. let s:enabled_modules = add(s:enabled_modules, module)
  29. endif
  30. endfor
  31. for module in s:enabled_modules
  32. exe 'call pandoc#' . module . '#Init()'
  33. endfor
  34. if exists('loaded_matchit')
  35. setlocal matchpairs-=<:>
  36. let b:match_words = &l:matchpairs .
  37. \ ',' . '\%(^\|[ (/]\)\@<="' . ':' . '"\%($\|[ )/.\,;\:?!\-]\)' .
  38. \ ',' . '\%(^\|[ (/]\)\@<=''' . ':' . '''\%($\|[ )/.\,;\:?!\-]\)'
  39. let b:match_words .=
  40. \ ',' . '\%(^\|[ (/]\)\@<=\*' . ':' . '\*\%($\|[ )/.\,;\:?!\-]\)' .
  41. \ ',' . '\%(^\|[ (/]\)\@<=\*\*' . ':' . '\*\*\%($\|[ )/.\,;\:?!\-]\)' .
  42. \ ',' . '\%(^\|[ (/]\)\@<=\*\*\*' . ':' . '\*\*\*\%($\|[ )/.\,;\:?!\-]\)' .
  43. \ ',' . '\%(^\|[ (/]\)\@<=_' . ':' . '_\%($\|[ )/.\,;\:?!\-]\)' .
  44. \ ',' . '\%(^\|[ (/]\)\@<=__' . ':' . '__\%($\|[ )/.\,;\:?!\-]\)' .
  45. \ ',' . '\%(^\|[ (/]\)\@<=___' . ':' . '___\%($\|[ )/.\,;\:?!\-]\)' .
  46. \ ',' . '\%(^\|[ (/]\)\@<=`[^`]' . ':' . '[^`]\@<=`\%($\|[ )/.\,;\:?!\-]\)' .
  47. \ ',' . '\%(^\|\s\)\@<=```' . ':' . '```\%($\|\s\)'
  48. let b:match_words .=
  49. \ ',' . '\%(^\|[ (]\)\@<=\$[^$]' . ':' . '[^$]\@<=\$\%($\|[ ).\,;\:?!\-]\)' .
  50. \ ',' . '\%(^\|\s\)\@<=\$\$' . ':' . '\$\$\%($\|\s\)' .
  51. \ ',' . '\%(^\s*\)\@<=\\begin{\(\w\+\*\?\)}' . ':' . '\%(^\s*\)\@<=\\end{\1}'
  52. endif
  53. setlocal formatlistpat=\\C^\\s*[\\[({]\\\?\\([0-9]\\+\\\|[iIvVxXlLcCdDmM]\\+\\\|[a-zA-Z]\\)[\\]:.)}]\\s\\+\\\|^\\s*[-+o*]\\s\\+
  54. setlocal formatoptions+=n
  55. let b:undo_ftplugin = 'setlocal formatoptions< formatlistpat< matchpairs<'
  56. \ . '| unlet! b:match_words'
  57. if exists('g:pandoc#formatting#equalprg') && !empty(g:pandoc#formatting#equalprg)
  58. let b:undo_ftplugin .= '| setlocal equalprg<'
  59. endif
  60. let &cpoptions = s:cpo_save
  61. unlet s:cpo_save