annotate runtime/indent/verilog.vim @ 20554:296fd130e061

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