Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | "Description: Indent scheme for the tilde weblanguage |
Bram Moolenaar | cb80aa2 | 2020-10-26 21:12:46 +0100 | [diff] [blame] | 2 | "Author: Tobias Rundstrรถm <tobi@tobi.nu> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 3 | "URL: http://tilde.tildesoftware.net |
| 4 | "Last Change: May 8 09:15:09 CEST 2002 |
| 5 | |
| 6 | if exists ("b:did_indent") |
| 7 | finish |
| 8 | endif |
| 9 | |
| 10 | let b:did_indent = 1 |
| 11 | |
| 12 | setlocal autoindent |
| 13 | setlocal indentexpr=GetTildeIndent(v:lnum) |
| 14 | setlocal indentkeys=o,O,) |
| 15 | |
| 16 | if exists("*GetTildeIndent") |
| 17 | finish |
| 18 | endif |
| 19 | |
| 20 | function GetTildeIndent(lnum) |
| 21 | let plnum = prevnonblank(v:lnum-1) |
| 22 | |
| 23 | if plnum == 0 |
| 24 | return 0 |
| 25 | endif |
| 26 | |
| 27 | if getline(v:lnum) =~ '^\s*\~\(endif\|else\|elseif\|end\)\>' |
Bram Moolenaar | 3ec574f | 2017-06-13 18:12:01 +0200 | [diff] [blame] | 28 | return indent(v:lnum) - shiftwidth() |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 29 | endif |
| 30 | |
| 31 | 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\)\>' |
Bram Moolenaar | 3ec574f | 2017-06-13 18:12:01 +0200 | [diff] [blame] | 32 | return indent(plnum) + shiftwidth() |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 33 | else |
| 34 | return -1 |
| 35 | endif |
| 36 | endfunction |