liquid.vim 1.9 KB

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