annotate runtime/indent/sqlanywhere.vim @ 29963:ee373646730e

Added tag v9.0.0319 for changeset 32e35a6d42926400c28c86e6f1bbab0f7e43b3b7
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Aug 2022 16:30:04 +0200
parents 3b34837f4538
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
1 " Vim indent file
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
2 " Language: SQL
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
3 " Maintainer: David Fishburn <dfishburn dot vim at gmail dot com>
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
4 " Last Change: 2021 Oct 11
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
5 " Version: 4.0
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
6 " Download: http://vim.sourceforge.net/script.php?script_id=495
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
7
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
8 " Notes:
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
9 " Indenting keywords are based on Oracle and Sybase Adaptive Server
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
10 " Anywhere (ASA). Test indenting was done with ASA stored procedures and
25773
11b656e74444 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 20753
diff changeset
11 " functions and Oracle packages which contain stored procedures and
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
12 " functions.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
13 " This has not been tested against Microsoft SQL Server or
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
14 " Sybase Adaptive Server Enterprise (ASE) which use the Transact-SQL
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
15 " syntax. That syntax does not have end tags for IF's, which makes
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
16 " indenting more difficult.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
17 "
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
18 " Known Issues:
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
19 " The Oracle MERGE statement does not have an end tag associated with
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
20 " it, this can leave the indent hanging to the right one too many.
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
21 "
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
22 " History:
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
23 " 4.0 (Oct 2021)
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
24 " Added b:undo_indent
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
25 "
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
26 " 3.0 (Dec 2012)
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
27 " Added cpo check
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
28 "
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
29 " 2.0
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
30 " Added the FOR keyword to SQLBlockStart to handle (Alec Tica):
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
31 " for i in 1..100 loop
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
32 " |<-- I expect to have indentation here
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
33 " end loop;
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
34 "
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
35
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
36 " Only load this indent file when no other was loaded.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
37 if exists("b:did_indent")
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
38 finish
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
39 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
40 let b:did_indent = 1
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
41 let b:current_indent = "sqlanywhere"
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
42
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
43 setlocal indentkeys-=0{
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
44 setlocal indentkeys-=0}
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
45 setlocal indentkeys-=:
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
46 setlocal indentkeys-=0#
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
47 setlocal indentkeys-=e
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
48
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
49 " This indicates formatting should take place when one of these
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
50 " expressions is used. These expressions would normally be something
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
51 " you would type at the BEGINNING of a line
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
52 " SQL is generally case insensitive, so this files assumes that
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
53 " These keywords are something that would trigger an indent LEFT, not
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
54 " an indent right, since the SQLBlockStart is used for those keywords
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
55 setlocal indentkeys+==~end,=~else,=~elseif,=~elsif,0=~when,0=)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
56
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
57 " GetSQLIndent is executed whenever one of the expressions
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
58 " in the indentkeys is typed
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
59 setlocal indentexpr=GetSQLIndent()
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
60
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
61 let b:undo_indent = "setl indentexpr< indentkeys<"
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
62
4073
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
63 " Only define the functions once.
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
64 if exists("*GetSQLIndent")
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
65 finish
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
66 endif
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
67
4073
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
68 let s:keepcpo= &cpo
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
69 set cpo&vim
e362db8b2d7b Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3996
diff changeset
70
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
71 " List of all the statements that start a new block.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
72 " These are typically words that start a line.
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
73 " IS is excluded, since it is difficult to determine when the
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
74 " ending block is (especially for procedures/functions).
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
75 let s:SQLBlockStart = '^\s*\%('.
25973
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
76 \ 'if\|else\|elseif\|elsif\|'.
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
77 \ 'while\|loop\|do\|for\|'.
3b34837f4538 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 25773
diff changeset
78 \ 'begin\|'.
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
79 \ 'case\|when\|merge\|exception'.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
80 \ '\)\>'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
81 let s:SQLBlockEnd = '^\s*\(end\)\>'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
82
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
83 " The indent level is also based on unmatched parentheses
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
84 " If a line has an extra "(" increase the indent
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
85 " If a line has an extra ")" decrease the indent
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
86 function! s:CountUnbalancedParen( line, paren_to_check )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
87 let l = a:line
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
88 let lp = substitute(l, '[^(]', '', 'g')
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
89 let l = a:line
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
90 let rp = substitute(l, '[^)]', '', 'g')
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
91
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
92 if a:paren_to_check =~ ')'
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
93 " echom 'CountUnbalancedParen ) returning: ' .
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
94 " \ (strlen(rp) - strlen(lp))
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
95 return (strlen(rp) - strlen(lp))
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
96 elseif a:paren_to_check =~ '('
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
97 " echom 'CountUnbalancedParen ( returning: ' .
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
98 " \ (strlen(lp) - strlen(rp))
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
99 return (strlen(lp) - strlen(rp))
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
100 else
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
101 " echom 'CountUnbalancedParen unknown paren to check: ' .
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
102 " \ a:paren_to_check
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
103 return 0
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
104 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
105 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
106
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
107 " Unindent commands based on previous indent level
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
108 function! s:CheckToIgnoreRightParen( prev_lnum, num_levels )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
109 let lnum = a:prev_lnum
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
110 let line = getline(lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
111 let ends = 0
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
112 let num_right_paren = a:num_levels
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
113 let ignore_paren = 0
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
114 let vircol = 1
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
115
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
116 while num_right_paren > 0
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
117 silent! exec 'norm! '.lnum."G\<bar>".vircol."\<bar>"
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
118 let right_paren = search( ')', 'W' )
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
119 if right_paren != lnum
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
120 " This should not happen since there should be at least
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
121 " num_right_paren matches for this line
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
122 break
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
123 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
124 let vircol = virtcol(".")
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
125
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
126 " if getline(".") =~ '^)'
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
127 let matching_paren = searchpair('(', '', ')', 'bW',
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
128 \ 's:IsColComment(line("."), col("."))')
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
129
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
130 if matching_paren < 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
131 " No match found
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
132 " echom 'CTIRP - no match found, ignoring'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
133 break
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
134 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
135
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
136 if matching_paren == lnum
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
137 " This was not an unmatched parentheses, start the search again
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
138 " again after this column
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
139 " echom 'CTIRP - same line match, ignoring'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
140 continue
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
141 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
142
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
143 " echom 'CTIRP - match: ' . line(".") . ' ' . getline(".")
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
144
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
145 if getline(matching_paren) =~? '\(if\|while\)\>'
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
146 " echom 'CTIRP - if/while ignored: ' . line(".") . ' ' . getline(".")
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
147 let ignore_paren = ignore_paren + 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
148 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
149
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
150 " One match found, decrease and check for further matches
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
151 let num_right_paren = num_right_paren - 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
152
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
153 endwhile
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
154
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
155 " Fallback - just move back one
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
156 " return a:prev_indent - shiftwidth()
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
157 return ignore_paren
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
158 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
159
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
160 " Based on the keyword provided, loop through previous non empty
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
161 " non comment lines to find the statement that initiated the keyword.
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
162 " Return its indent level
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
163 " CASE ..
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
164 " WHEN ...
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
165 " Should return indent level of CASE
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
166 " EXCEPTION ..
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
167 " WHEN ...
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
168 " something;
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
169 " WHEN ...
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
170 " Should return indent level of exception.
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
171 function! s:GetStmtStarterIndent( keyword, curr_lnum )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
172 let lnum = a:curr_lnum
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
173
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
174 " Default - reduce indent by 1
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
175 let ind = indent(a:curr_lnum) - shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
176
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
177 if a:keyword =~? 'end'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
178 exec 'normal! ^'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
179 let stmts = '^\s*\%('.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
180 \ '\<begin\>\|' .
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
181 \ '\%(\%(\<end\s\+\)\@<!\<loop\>\)\|' .
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
182 \ '\%(\%(\<end\s\+\)\@<!\<case\>\)\|' .
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
183 \ '\%(\%(\<end\s\+\)\@<!\<for\>\)\|' .
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
184 \ '\%(\%(\<end\s\+\)\@<!\<if\>\)'.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
185 \ '\)'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
186 let matching_lnum = searchpair(stmts, '', '\<end\>\zs', 'bW',
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
187 \ 's:IsColComment(line("."), col(".")) == 1')
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
188 exec 'normal! $'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
189 if matching_lnum > 0 && matching_lnum < a:curr_lnum
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
190 let ind = indent(matching_lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
191 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
192 elseif a:keyword =~? 'when'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
193 exec 'normal! ^'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
194 let matching_lnum = searchpair(
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
195 \ '\%(\<end\s\+\)\@<!\<case\>\|\<exception\>\|\<merge\>',
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
196 \ '',
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
197 \ '\%(\%(\<when\s\+others\>\)\|\%(\<end\s\+case\>\)\)',
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
198 \ 'bW',
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
199 \ 's:IsColComment(line("."), col(".")) == 1')
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
200 exec 'normal! $'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
201 if matching_lnum > 0 && matching_lnum < a:curr_lnum
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
202 let ind = indent(matching_lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
203 else
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
204 let ind = indent(a:curr_lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
205 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
206 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
207
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
208 return ind
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
209 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
210
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
211
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
212 " Check if the line is a comment
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
213 function! s:IsLineComment(lnum)
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
214 let rc = synIDattr(
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
215 \ synID(a:lnum,
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
216 \ match(getline(a:lnum), '\S')+1, 0)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
217 \ , "name")
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
218 \ =~? "comment"
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
219
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
220 return rc
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
221 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
222
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
223
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
224 " Check if the column is a comment
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
225 function! s:IsColComment(lnum, cnum)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
226 let rc = synIDattr(synID(a:lnum, a:cnum, 0), "name")
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
227 \ =~? "comment"
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
228
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
229 return rc
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
230 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
231
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
232
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
233 " Instead of returning a column position, return
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
234 " an appropriate value as a factor of shiftwidth.
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
235 function! s:ModuloIndent(ind)
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
236 let ind = a:ind
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
237
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
238 if ind > 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
239 let modulo = ind % shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
240
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
241 if modulo > 0
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
242 let ind = ind - modulo
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
243 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
244 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
245
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
246 return ind
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
247 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
248
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
249
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
250 " Find correct indent of a new line based upon the previous line
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
251 function! GetSQLIndent()
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
252 let lnum = v:lnum
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
253 let ind = indent(lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
254
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
255 " If the current line is a comment, leave the indent as is
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
256 " Comment out this additional check since it affects the
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
257 " indenting of =, and will not reindent comments as it should
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
258 " if s:IsLineComment(lnum) == 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
259 " return ind
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
260 " endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
261
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
262 " Get previous non-blank line
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
263 let prevlnum = prevnonblank(lnum - 1)
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
264 if prevlnum <= 0
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
265 return ind
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
266 endif
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
267
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
268 if s:IsLineComment(prevlnum) == 1
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
269 if getline(v:lnum) =~ '^\s*\*'
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
270 let ind = s:ModuloIndent(indent(prevlnum))
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
271 return ind + 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
272 endif
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
273 " If the previous line is a comment, then return -1
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
274 " to tell Vim to use the formatoptions setting to determine
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
275 " the indent to use
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
276 " But only if the next line is blank. This would be true if
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
277 " the user is typing, but it would not be true if the user
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
278 " is reindenting the file
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
279 if getline(v:lnum) =~ '^\s*$'
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
280 return -1
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
281 endif
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
282 endif
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
283
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
284 " echom 'PREVIOUS INDENT: ' . indent(prevlnum) . ' LINE: ' . getline(prevlnum)
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
285
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
286 " This is the line you just hit return on, it is not the current line
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
287 " which is new and empty
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
288 " Based on this line, we can determine how much to indent the new
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
289 " line
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
290
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
291 " Get default indent (from prev. line)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
292 let ind = indent(prevlnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
293 let prevline = getline(prevlnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
294
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
295 " Now check what's on the previous line to determine if the indent
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
296 " should be changed, for example IF, BEGIN, should increase the indent
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
297 " where END IF, END, should decrease the indent.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
298 if prevline =~? s:SQLBlockStart
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
299 " Move indent in
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
300 let ind = ind + shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
301 " echom 'prevl - SQLBlockStart - indent ' . ind . ' line: ' . prevline
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
302 elseif prevline =~ '[()]'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
303 if prevline =~ '('
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
304 let num_unmatched_left = s:CountUnbalancedParen( prevline, '(' )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
305 else
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
306 let num_unmatched_left = 0
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
307 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
308 if prevline =~ ')'
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
309 let num_unmatched_right = s:CountUnbalancedParen( prevline, ')' )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
310 else
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
311 let num_unmatched_right = 0
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
312 " let num_unmatched_right = s:CountUnbalancedParen( prevline, ')' )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
313 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
314 if num_unmatched_left > 0
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
315 " There is a open left parenthesis
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
316 " increase indent
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
317 let ind = ind + ( shiftwidth() * num_unmatched_left )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
318 elseif num_unmatched_right > 0
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
319 " if it is an unbalanced parenthesis only unindent if
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
320 " it was part of a command (ie create table(..) )
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
321 " instead of part of an if (ie if (....) then) which should
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
322 " maintain the indent level
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
323 let ignore = s:CheckToIgnoreRightParen( prevlnum, num_unmatched_right )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
324 " echom 'prevl - ) unbalanced - CTIRP - ignore: ' . ignore
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
325
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
326 if prevline =~ '^\s*)'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
327 let ignore = ignore + 1
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
328 " echom 'prevl - begins ) unbalanced ignore: ' . ignore
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
329 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
330
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
331 if (num_unmatched_right - ignore) > 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
332 let ind = ind - ( shiftwidth() * (num_unmatched_right - ignore) )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
333 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
334
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
335 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
336 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
337
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
338
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
339 " echom 'CURRENT INDENT: ' . ind . ' LINE: ' . getline(v:lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
340
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
341 " This is a new blank line since we just typed a carriage return
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
342 " Check current line; search for simplistic matching start-of-block
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
343 let line = getline(v:lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
344
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
345 if line =~? '^\s*els'
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
346 " Any line when you type else will automatically back up one
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
347 " ident level (ie else, elseif, elsif)
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
348 let ind = ind - shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
349 " echom 'curr - else - indent ' . ind
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
350 elseif line =~? '^\s*end\>'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
351 let ind = s:GetStmtStarterIndent('end', v:lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
352 " General case for end
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
353 " let ind = ind - shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
354 " echom 'curr - end - indent ' . ind
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
355 elseif line =~? '^\s*when\>'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
356 let ind = s:GetStmtStarterIndent('when', v:lnum)
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
357 " If the WHEN clause is used with a MERGE or EXCEPTION
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
358 " clause, do not change the indent level, since these
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
359 " statements do not have a corresponding END statement.
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
360 " if stmt_starter =~? 'case'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
361 " let ind = ind - shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
362 " endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
363 " elseif line =~ '^\s*)\s*;\?\s*$'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
364 " elseif line =~ '^\s*)'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
365 elseif line =~ '^\s*)'
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
366 let num_unmatched_right = s:CountUnbalancedParen( line, ')' )
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
367 let ignore = s:CheckToIgnoreRightParen( v:lnum, num_unmatched_right )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
368 " If the line ends in a ), then reduce the indent
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
369 " This catches items like:
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
370 " CREATE TABLE T1(
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
371 " c1 int,
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
372 " c2 int
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
373 " );
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
374 " But we do not want to unindent a line like:
856
8cd729851562 updated for version 7.0g
vimboss
parents: 718
diff changeset
375 " IF ( c1 = 1
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
376 " AND c2 = 3 ) THEN
20753
661eb972cb22 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
377 " let num_unmatched_right = s:CountUnbalancedParen( line, ')' )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
378 " if num_unmatched_right > 0
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
379 " elseif strpart( line, strlen(line)-1, 1 ) =~ ')'
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
380 " let ind = ind - shiftwidth()
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
381 if line =~ '^\s*)'
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
382 " let ignore = ignore + 1
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
383 " echom 'curr - begins ) unbalanced ignore: ' . ignore
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
384 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
385
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
386 if (num_unmatched_right - ignore) > 0
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 4073
diff changeset
387 let ind = ind - ( shiftwidth() * (num_unmatched_right - ignore) )
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
388 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
389 " endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
390 endif
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
391
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
392 " echom 'final - indent ' . ind
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 856
diff changeset
393 return s:ModuloIndent(ind)
718
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
394 endfunction
7b21554be7a1 updated for version 7.0219
vimboss
parents:
diff changeset
395
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
396 " Restore:
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
397 let &cpo= s:keepcpo
3526
dd6c2497c997 Fix more 'cpo' issues in runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1619
diff changeset
398 unlet s:keepcpo
3996
b3f3237a3d72 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3526
diff changeset
399 " vim: ts=4 fdm=marker sw=4