annotate runtime/indent/verilog.vim @ 11566:f3ac978df263

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