vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

liquid.vim (1983B)


      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 
      7 if exists('b:did_ftplugin')
      8   finish
      9 endif
     10 
     11 if !exists('g:liquid_default_subtype')
     12   let g:liquid_default_subtype = 'html'
     13 endif
     14 
     15 if !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
     27 endif
     28 
     29 if 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'
     31 else
     32   runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
     33 endif
     34 let b:did_ftplugin = 1
     35 
     36 if exists('b:undo_ftplugin')
     37   let b:undo_ftplugin .= '|'
     38 else
     39   let b:undo_ftplugin = ''
     40 endif
     41 if exists('b:browsefilter')
     42   let b:browsefilter = "\n".b:browsefilter
     43 else
     44   let b:browsefilter = ''
     45 endif
     46 if exists('b:match_words')
     47   let b:match_words .= ','
     48 elseif exists('loaded_matchit')
     49   let b:match_words = ''
     50 endif
     51 
     52 if has('gui_win32')
     53   let b:browsefilter="Liquid Files (*.liquid)\t*.liquid" . b:browsefilter
     54 endif
     55 
     56 if exists('loaded_matchit')
     57   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\>'
     58 endif
     59 
     60 setlocal commentstring={%\ comment\ %}\ %s\ {%\ endcomment\ %}
     61 
     62 let b:undo_ftplugin .= 'setl cms< | unlet! b:browsefilter b:match_words'