annotate runtime/indent/liquid.vim @ 34316:bce11c34ef41 v9.1.0092

patch 9.1.0092: Compiler warning for missing type in scroll_event() Commit: https://github.com/vim/vim/commit/c908371aec920b8174e40a1adb73a50e326a5668 Author: Christian Brabandt <cb@256bit.org> Date: Sat Feb 10 13:17:16 2024 +0100 patch 9.1.0092: Compiler warning for missing type in scroll_event() Problem: Compiler warning for missing type in scroll_event() (chdiza) Solution: Declare display_type explicitly as integer fixes: #14005 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 10 Feb 2024 13:30:03 +0100
parents dce918af0c00
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: Liquid
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Last Change: 2022 Mar 15
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 if exists('b:did_indent')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 finish
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 set indentexpr=
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 if exists('b:liquid_subtype')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 exe 'runtime! indent/'.b:liquid_subtype.'.vim'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 else
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 runtime! indent/html.vim
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 unlet! b:did_indent
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 if &l:indentexpr == ''
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 if &l:cindent
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 let &l:indentexpr = 'cindent(v:lnum)'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 else
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 let b:liquid_subtype_indentexpr = &l:indentexpr
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 let b:did_indent = 1
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 setlocal indentexpr=GetLiquidIndent()
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=endif,=endunless,=endifchanged,=endcase,=endfor,=endtablerow,=endcapture,=else,=elsif,=when,=empty
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
32 let b:undo_indent = "setl inde< indk<"
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
33
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 " Only define the function once.
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 if exists('*GetLiquidIndent')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 finish
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
39 function! s:count(string, pattern) abort
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40 let string = substitute(a:string,'\C'.a:pattern,"\n",'g')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 return strlen(substitute(string,"[^\n]",'','g'))
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42 endfunction
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
44 function! GetLiquidIndent(...) abort
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 if a:0 && a:1 == '.'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 let v:lnum = line('.')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 elseif a:0 && a:1 =~ '^\d'
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 let v:lnum = a:1
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 endif
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 let vcol = col('.')
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 call cursor(v:lnum,1)
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 exe "let ind = ".b:liquid_subtype_indentexpr
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 let lnum = prevnonblank(v:lnum-1)
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 let line = getline(lnum)
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 let cline = getline(v:lnum)
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
56 let line = substitute(line,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
57 let line = substitute(line,'\C\%(\s*{%-\=\s*if.\+-\=%}.\+{%-\=\s*endif\s*-\=%}\)\+','','g')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
58 let line .= matchstr(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
59 let cline = substitute(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','')
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
60 let sw = shiftwidth()
28141
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
61 let ind += sw * s:count(line,'{%-\=\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
62 let ind -= sw * s:count(line,'{%-\=\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
63 let ind -= sw * s:count(cline,'{%-\=\s*\%(elsif\|else\|when\|empty\)\>')
dce918af0c00 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
64 let ind -= sw * s:count(cline,'{%-\=\s*end\w*$')
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 return ind
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 endfunction