7
|
1 "Description: Indent scheme for the tilde weblanguage
|
28620
|
2 "Author: Tobias Rundström <tobi@tobi.nu> (Invalid email address)
|
7
|
3 "URL: http://tilde.tildesoftware.net
|
|
4 "Last Change: May 8 09:15:09 CEST 2002
|
28620
|
5 " 2022 April: b:undo_indent added by Doug Kearns
|
7
|
6
|
|
7 if exists ("b:did_indent")
|
|
8 finish
|
|
9 endif
|
|
10
|
|
11 let b:did_indent = 1
|
|
12
|
|
13 setlocal autoindent
|
|
14 setlocal indentexpr=GetTildeIndent(v:lnum)
|
|
15 setlocal indentkeys=o,O,)
|
|
16
|
28620
|
17 let b:undo_indent = "setl ai< inde< indk<"
|
|
18
|
7
|
19 if exists("*GetTildeIndent")
|
|
20 finish
|
|
21 endif
|
|
22
|
|
23 function GetTildeIndent(lnum)
|
|
24 let plnum = prevnonblank(v:lnum-1)
|
|
25
|
|
26 if plnum == 0
|
|
27 return 0
|
|
28 endif
|
|
29
|
|
30 if getline(v:lnum) =~ '^\s*\~\(endif\|else\|elseif\|end\)\>'
|
11518
|
31 return indent(v:lnum) - shiftwidth()
|
7
|
32 endif
|
|
33
|
|
34 if getline(plnum) =~ '^\s*\~\(if\|foreach\|foreach_row\|xml_loop\|file_loop\|file_write\|file_append\|imap_loopsections\|imap_index\|imap_list\|ldap_search\|post_loopall\|post_loop\|file_loop\|sql_loop_num\|sql_dbmsselect\|search\|sql_loop\|post\|for\|function_define\|silent\|while\|setvalbig\|mail_create\|systempipe\|mail_send\|dual\|elseif\|else\)\>'
|
11518
|
35 return indent(plnum) + shiftwidth()
|
7
|
36 else
|
|
37 return -1
|
|
38 endif
|
|
39 endfunction
|