liquid.vim 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " Vim filetype plugin
  2. " Language: Liquid
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " Last Change: 2010 May 21
  5. if exists('b:did_ftplugin')
  6. finish
  7. endif
  8. if !exists('g:liquid_default_subtype')
  9. let g:liquid_default_subtype = 'html'
  10. endif
  11. if !exists('b:liquid_subtype')
  12. let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
  13. let b:liquid_subtype = matchstr(s:lines,'liquid_subtype=\zs\w\+')
  14. if b:liquid_subtype == ''
  15. let b:liquid_subtype = matchstr(&filetype,'^liquid\.\zs\w\+')
  16. endif
  17. if b:liquid_subtype == ''
  18. let b:liquid_subtype = matchstr(substitute(expand('%:t'),'\c\%(\.liquid\)\+$','',''),'\.\zs\w\+$')
  19. endif
  20. if b:liquid_subtype == ''
  21. let b:liquid_subtype = g:liquid_default_subtype
  22. endif
  23. endif
  24. if exists('b:liquid_subtype') && b:liquid_subtype != ''
  25. exe 'runtime! ftplugin/'.b:liquid_subtype.'.vim ftplugin/'.b:liquid_subtype.'_*.vim ftplugin/'.b:liquid_subtype.'/*.vim'
  26. else
  27. runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
  28. endif
  29. let b:did_ftplugin = 1
  30. if exists('b:undo_ftplugin')
  31. let b:undo_ftplugin .= '|'
  32. else
  33. let b:undo_ftplugin = ''
  34. endif
  35. if exists('b:browsefilter')
  36. let b:browsefilter = "\n".b:browsefilter
  37. else
  38. let b:browsefilter = ''
  39. endif
  40. if exists('b:match_words')
  41. let b:match_words .= ','
  42. elseif exists('loaded_matchit')
  43. let b:match_words = ''
  44. endif
  45. if has('gui_win32')
  46. let b:browsefilter="Liquid Files (*.liquid)\t*.liquid" . b:browsefilter
  47. endif
  48. if exists('loaded_matchit')
  49. let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\<end\%(if\w*\|unless\|case\)\>,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\<end\%(for\|tablerow\)\>,<\(capture\|comment\|highlight\)\>:\<end\1\>'
  50. endif
  51. setlocal commentstring={%\ comment\ %}%s{%\ endcomment\ %}
  52. let b:undo_ftplugin .= 'setl cms< | unlet! b:browsefilter b:match_words'