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