annotate runtime/indent/verilog.vim @ 5371:2238fb040256

Added tag v7-4-036 for changeset 90e2f0729a0d
author Bram Moolenaar <bram@vim.org>
date Wed, 25 Sep 2013 16:41:55 +0200
parents 8b8ef1fed009
children 1218c5353e2b
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>
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
3 " Last Change: 2011 Dec 10 by Thilo Six
7
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
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
33 let s:cpo_save = &cpo
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
34 set cpo&vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 function GetVerilogIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 if exists('b:verilog_indent_width')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let offset = b:verilog_indent_width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 let offset = &sw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 if exists('b:verilog_indent_modules')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 let indent_modules = offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 let indent_modules = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 " Find a non-blank line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 " At the start of the file use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 let lnum2 = prevnonblank(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let curr_line = getline(v:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let last_line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 let last_line2 = getline(lnum2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let ind2 = indent(lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 let offset_comment1 = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " Define the condition of an open statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " Exclude the match of //, /* or */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let vlog_openstat = '\(\<or\>\|\([*/]\)\@<![*(,{><+-/%^&|!=?:]\([*/]\)\@!\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " Define the condition when the statement ends with a one-line comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 let vlog_comment = '\(//.*\|/\*.*\*/\s*\)'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if exists('b:verilog_indent_verbose')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let vverb_str = 'INDENT VERBOSE:'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 let vverb = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 let vverb = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " Indent accoding to last line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " End of multiple-line comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 let ind = ind - offset_comment1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 echo vverb_str "De-indent after a multiple-line comment."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 " Indent after if/else/for/case/always/initial/specify/fork blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 elseif last_line =~ '`\@<!\<\(if\|else\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 \ last_line =~ '^\s*\<\(for\|case\%[[zx]]\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 \ last_line =~ '^\s*\<\(always\|initial\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 \ last_line =~ '^\s*\<\(specify\|fork\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 if last_line !~ '\(;\|\<end\>\)\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 if vverb | echo vverb_str "Indent after a block statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 " Indent after function/task blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 elseif last_line =~ '^\s*\<\(function\|task\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 if last_line !~ '\<end\>\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 echo vverb_str "Indent after function/task block statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 " Indent after module/function/task/specify/fork blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 elseif last_line =~ '^\s*\<module\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 let ind = ind + indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 if vverb && indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 echo vverb_str "Indent after module statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 if last_line =~ '[(,]\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 \ last_line !~ '\(//\|/\*\).*[(,]\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 echo vverb_str "Indent after a multiple-line module statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 " Indent after a 'begin' statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 elseif last_line =~ '\(\<begin\>\)\(\s*:\s*\w\+\)*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 \ last_line !~ '\(//\|/\*\).*\(\<begin\>\)' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 \ ( last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 \ last_line2 =~ '^\s*[^=!]\+\s*:\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 if vverb | echo vverb_str "Indent after begin statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 " De-indent for the end of one-line block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 elseif ( last_line !~ '\<begin\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 \ last_line =~ '\(//\|/\*\).*\<begin\>' ) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 \ last_line2 =~ '\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>.*' .
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 \ vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 \ last_line2 !~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 \ '\(//\|/\*\).*\<\(`\@<!if\|`\@<!else\|for\|always\|initial\)\>' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
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 \ last_line2 =~ '\(//\|/\*\).*\<begin\>' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 echo vverb_str "De-indent after the end of one-line statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 " Multiple-line statement (including case statement)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 " Open statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 " Ident the first open line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 elseif last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 \ last_line !~ '\(//\|/\*\).*' . vlog_openstat . '\s*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 \ last_line2 !~ vlog_openstat . '\s*' . vlog_comment . '*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 if vverb | echo vverb_str "Indent after an open statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 " Close statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 " De-indent for an optional close parenthesis and a semicolon, and only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 " if there exists precedent non-whitespace char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 elseif last_line =~ ')*\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_line !~ '\(//\|/\*\).*\S)*\s*;\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 \ ( last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 \ last_line2 !~ ';\s*//.*$') &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 \ last_line2 !~ '^\s*' . vlog_comment . '$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 if vverb | echo vverb_str "De-indent after a close statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 " `ifdef and `else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 elseif last_line =~ '^\s*`\<\(ifdef\|else\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 let ind = ind + offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 echo vverb_str "Indent after a `ifdef or `else statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 " Re-indent current line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 " De-indent on the end of the block
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 " join/end/endcase/endfunction/endtask/endspecify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 if curr_line =~ '^\s*\<\(join\|end\|endcase\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 if vverb | echo vverb_str "De-indent the end of a block." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 elseif curr_line =~ '^\s*\<endmodule\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 let ind = ind - indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 if vverb && indent_modules
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 echo vverb_str "De-indent the end of a module."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 " De-indent on a stand-alone 'begin'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 elseif curr_line =~ '^\s*\<begin\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 if last_line !~ '^\s*\<\(function\|task\|specify\|module\)\>' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 \ last_line !~ '^\s*\()*\s*;\|)\+\)\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 \ ( last_line =~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 \ '\<\(`\@<!if\|`\@<!else\|for\|case\%[[zx]]\|always\|initial\)\>' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 \ last_line =~ ')\s*' . vlog_comment . '*$' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 \ last_line =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 echo vverb_str "De-indent a stand alone begin statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 " De-indent after the end of multiple-line statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 elseif curr_line =~ '^\s*)' &&
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_line !~ vlog_openstat . '\s*' . vlog_comment . '*$' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 \ last_line2 =~ vlog_openstat . '\s*' . vlog_comment . '*$' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 if vverb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 echo vverb_str "De-indent the end of a multiple statement."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 " De-indent `else and `endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 elseif curr_line =~ '^\s*`\<\(else\|endif\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 let ind = ind - offset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 if vverb | echo vverb_str "De-indent `else and `endif statement." | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 " Return the indention
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219
3224
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
220 let &cpo = s:cpo_save
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
221 unlet s:cpo_save
8b8ef1fed009 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 7
diff changeset
222
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 " vim:sw=2