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