Mercurial > vim
annotate runtime/indent/liquid.vim @ 14958:b898f9093199 v8.1.0490
patch 8.1.0490: MS-Windows: doesn't handle missing glibwinpthread-1.dll
commit https://github.com/vim/vim/commit/eda9e9c2fe4577ad451418253b990a3f60b70444
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 21 22:45:43 2018 +0200
patch 8.1.0490: MS-Windows: doesn't handle missing glibwinpthread-1.dll
Problem: MS-Windows: doesn't handle missing glibwinpthread-1.dll.
Solution: Adjust Cygwin/MinGW build file. (Ken Takata, closes https://github.com/vim/vim/issues/2827)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Oct 2018 23:00:05 +0200 |
parents | 63b0b7b79b25 |
children | dce918af0c00 |
rev | line source |
---|---|
2202 | 1 " Vim indent file |
2 " Language: Liquid | |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | |
11518 | 4 " Last Change: 2017 Jun 13 |
2202 | 5 |
6 if exists('b:did_indent') | |
7 finish | |
8 endif | |
9 | |
10 set indentexpr= | |
11 if exists('b:liquid_subtype') | |
12 exe 'runtime! indent/'.b:liquid_subtype.'.vim' | |
13 else | |
14 runtime! indent/html.vim | |
15 endif | |
16 unlet! b:did_indent | |
17 | |
18 if &l:indentexpr == '' | |
19 if &l:cindent | |
20 let &l:indentexpr = 'cindent(v:lnum)' | |
21 else | |
22 let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))' | |
23 endif | |
24 endif | |
25 let b:liquid_subtype_indentexpr = &l:indentexpr | |
26 | |
27 let b:did_indent = 1 | |
28 | |
29 setlocal indentexpr=GetLiquidIndent() | |
30 setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=endif,=endunless,=endifchanged,=endcase,=endfor,=endtablerow,=endcapture,=else,=elsif,=when,=empty | |
31 | |
32 " Only define the function once. | |
33 if exists('*GetLiquidIndent') | |
34 finish | |
35 endif | |
36 | |
37 function! s:count(string,pattern) | |
38 let string = substitute(a:string,'\C'.a:pattern,"\n",'g') | |
39 return strlen(substitute(string,"[^\n]",'','g')) | |
40 endfunction | |
41 | |
42 function! GetLiquidIndent(...) | |
43 if a:0 && a:1 == '.' | |
44 let v:lnum = line('.') | |
45 elseif a:0 && a:1 =~ '^\d' | |
46 let v:lnum = a:1 | |
47 endif | |
48 let vcol = col('.') | |
49 call cursor(v:lnum,1) | |
50 exe "let ind = ".b:liquid_subtype_indentexpr | |
51 let lnum = prevnonblank(v:lnum-1) | |
52 let line = getline(lnum) | |
53 let cline = getline(v:lnum) | |
54 let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') | |
55 let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+') | |
56 let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') | |
11518 | 57 let sw = shiftwidth() |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
58 let ind += sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
59 let ind -= sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
60 let ind -= sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>') |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
61 let ind -= sw * s:count(cline,'{%\s*end\w*$') |
2202 | 62 return ind |
63 endfunction |