annotate runtime/indent/verilog.vim @ 3137:b5a2b4c0c1ca v7.3.339

updated for version 7.3.339 Problem: "make shadow" doesn't link all test files. Solution: Add a line in Makefile and Filelist.
author Bram Moolenaar <bram@vim.org>
date Thu, 20 Oct 2011 16:35:35 +0200
parents 3fc0f57ecb91
children 8b8ef1fed009
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Language: Verilog HDL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Maintainer: Chih-Tsun Huang <cthuang@larc.ee.nthu.edu.tw>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Last Change: Wed Oct 31 16:13:11 CST 2001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " URL: http://larc.ee.nthu.edu.tw/~cthuang/vim/indent/verilog.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Credits:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Suggestions for improvement, bug reports by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Leo Butlero <lbutler@brocade.com>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Buffer Variables:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " b:verilog_indent_modules : indenting after the declaration
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " of module blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " b:verilog_indent_width : indenting width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " b:verilog_indent_verbose : verbose to each indenting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 setlocal indentexpr=GetVerilogIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 setlocal indentkeys=!^F,o,O,0),=begin,=end,=join,=endcase
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 setlocal indentkeys+==`else,=`endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " Only define the function once.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 if exists("*GetVerilogIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 function GetVerilogIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 if exists('b:verilog_indent_width')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let offset = b:verilog_indent_width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let offset = &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 if exists('b:verilog_indent_modules')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 let indent_modules = offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 let indent_modules = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 let lnum2 = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 let curr_line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let last_line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let last_line2 = getline(lnum2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let ind2 = indent(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let offset_comment1 = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Define the condition of an open statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " Exclude the match of //, /* or */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let vlog_openstat = '\(\<or\>\|\([*/]\)\@<![*(,{><+-/%^&|!=?:]\([*/]\)\@!\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " Define the condition when the statement ends with a one-line comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 let vlog_comment = '\(//.*\|/\*.*\*/\s*\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if exists('b:verilog_indent_verbose')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 let vverb_str = 'INDENT VERBOSE:'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let vverb = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let vverb = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " Indent accoding to last line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " End of multiple-line comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 let ind = ind - offset_comment1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 echo vverb_str "De-indent after a multiple-line comment."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " Indent after if/else/for/case/always/initial/specify/fork blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 elseif last_line =~ '`\@<!\<\(if\|else\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 \ last_line =~ '^\s*\<\(for\|case\%[[zx]]\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 \ last_line =~ '^\s*\<\(always\|initial\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 \ last_line =~ '^\s*\<\(specify\|fork\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 if last_line !~ '\(;\|\<end\>\)\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 if vverb | echo vverb_str "Indent after a block statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 " Indent after function/task blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 elseif last_line =~ '^\s*\<\(function\|task\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 if last_line !~ '\<end\>\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 echo vverb_str "Indent after function/task block statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 " Indent after module/function/task/specify/fork blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 elseif last_line =~ '^\s*\<module\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let ind = ind + indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 if vverb && indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 echo vverb_str "Indent after module statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 if last_line =~ '[(,]\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 \ last_line !~ '\(//\|/\*\).*[(,]\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 echo vverb_str "Indent after a multiple-line module statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 " Indent after a 'begin' statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 elseif last_line =~ '\(\<begin\>\)\(\s*:\s*\w\+\)*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 \ last_line !~ '\(//\|/\*\).*\(\<begin\>\)' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 \ ( last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 \ last_line2 =~ '^\s*[^=!]\+\s*:\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 if vverb | echo vverb_str "Indent after begin statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 " De-indent for the end of one-line block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 elseif ( last_line !~ '\<begin\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 \ last_line =~ '\(//\|/\*\).*\<begin\>' ) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 \ last_line2 =~ '\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>.*' .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 \ vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 \ last_line2 !~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 \ '\(//\|/\*\).*\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 \ ( last_line2 !~ '\<begin\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 \ last_line2 =~ '\(//\|/\*\).*\<begin\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 echo vverb_str "De-indent after the end of one-line statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 " Multiple-line statement (including case statement)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 " Open statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 " Ident the first open line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 elseif last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 \ last_line !~ '\(//\|/\*\).*' . vlog_openstat . '\s*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 if vverb | echo vverb_str "Indent after an open statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 " Close statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 " De-indent for an optional close parenthesis and a semicolon, and only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 " if there exists precedent non-whitespace char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 elseif last_line =~ ')*\s*;\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 \ last_line !~ '^\s*)*\s*;\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 \ last_line !~ '\(//\|/\*\).*\S)*\s*;\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 \ ( last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 \ last_line2 !~ ';\s*//.*$') &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 \ last_line2 !~ '^\s*' . vlog_comment . '$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 if vverb | echo vverb_str "De-indent after a close statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 " `ifdef and `else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 elseif last_line =~ '^\s*`\<\(ifdef\|else\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 echo vverb_str "Indent after a `ifdef or `else statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 " Re-indent current line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 " De-indent on the end of the block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 " join/end/endcase/endfunction/endtask/endspecify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 if curr_line =~ '^\s*\<\(join\|end\|endcase\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 if vverb | echo vverb_str "De-indent the end of a block." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 elseif curr_line =~ '^\s*\<endmodule\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 let ind = ind - indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 if vverb && indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 echo vverb_str "De-indent the end of a module."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 " De-indent on a stand-alone 'begin'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 elseif curr_line =~ '^\s*\<begin\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 if last_line !~ '^\s*\<\(function\|task\|specify\|module\)\>' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 \ last_line !~ '^\s*\()*\s*;\|)\+\)\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 \ ( last_line =~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 \ '\<\(`\@<!if\|`\@<!else\|for\|case\%[[zx]]\|always\|initial\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 \ last_line =~ ')\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 \ last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 echo vverb_str "De-indent a stand alone begin statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 " De-indent after the end of multiple-line statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 elseif curr_line =~ '^\s*)' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 \ ( last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 \ last_line !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 \ last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 echo vverb_str "De-indent the end of a multiple statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 " De-indent `else and `endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 elseif curr_line =~ '^\s*`\<\(else\|endif\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 if vverb | echo vverb_str "De-indent `else and `endif statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 " Return the indention
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 " vim:sw=2