annotate runtime/indent/systemverilog.vim @ 28125:ed151877ebac v8.2.4587

patch 8.2.4587: Vim9: double free after unpacking a list Commit: https://github.com/vim/vim/commit/61efa16932d485fc724e4b94a8e7078a176c9946 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 18 13:10:48 2022 +0000 patch 8.2.4587: Vim9: double free after unpacking a list Problem: Vim9: double free after unpacking a list. Solution: Make a copy of the value instead of moving it. (closes https://github.com/vim/vim/issues/9968)
author Bram Moolenaar <Bram@vim.org>
date Fri, 18 Mar 2022 14:15:04 +0100
parents 11b656e74444
children 6dd88e45d47d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 " Vim indent file
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 " Language: SystemVerilog
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 " Maintainer: kocha <kocha.lsifrontend@gmail.com>
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
4 " Last Change: 05-Feb-2017 by Bilal Wasim
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 " Only load this indent file when no other was loaded.
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
7 if exists("b:did_indent")
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 finish
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 let b:did_indent = 1
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12 setlocal indentexpr=SystemVerilogIndent()
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 setlocal indentkeys=!^F,o,O,0),0},=begin,=end,=join,=endcase,=join_any,=join_none
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14 setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 setlocal indentkeys+==endclass,=endpackage,=endsequence,=endclocking
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 setlocal indentkeys+==endinterface,=endgroup,=endprogram,=endproperty,=endchecker
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 setlocal indentkeys+==`else,=`endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 " Only define the function once.
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20 if exists("*SystemVerilogIndent")
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 finish
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 let s:cpo_save = &cpo
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 set cpo&vim
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
27 function SystemVerilogIndent()
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
28
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
29 if exists('b:systemverilog_indent_width')
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
30 let offset = b:systemverilog_indent_width
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
31 else
11518
63b0b7b79b25 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 5663
diff changeset
32 let offset = shiftwidth()
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
33 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
34 if exists('b:systemverilog_indent_modules')
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
35 let indent_modules = offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
36 else
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
37 let indent_modules = 0
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
38 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
39
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
40 " Find a non-blank line above the current line.
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
41 let lnum = prevnonblank(v:lnum - 1)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 " At the start of the file use zero indent.
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44 if lnum == 0
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 return 0
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 let lnum2 = prevnonblank(lnum - 1)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 let curr_line = getline(v:lnum)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50 let last_line = getline(lnum)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
51 let last_line2 = getline(lnum2)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
52 let ind = indent(lnum)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
53 let ind2 = indent(lnum - 1)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
54 let offset_comment1 = 1
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
55 " Define the condition of an open statement
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
56 " Exclude the match of //, /* or */
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 let sv_openstat = '\(\<or\>\|\([*/]\)\@<![*(,{><+-/%^&|!=?:]\([*/]\)\@!\)'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 " Define the condition when the statement ends with a one-line comment
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59 let sv_comment = '\(//.*\|/\*.*\*/\s*\)'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 if exists('b:verilog_indent_verbose')
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 let vverb_str = 'INDENT VERBOSE:'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 let vverb = 1
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63 else
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 let vverb = 0
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66
25773
11b656e74444 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
67 " Indent according to last line
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68 " End of multiple-line comment
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 if last_line =~ '\*/\s*$' && last_line !~ '/\*.\{-}\*/'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 let ind = ind - offset_comment1
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72 echo vverb_str "De-indent after a multiple-line comment."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 " Indent after if/else/for/case/always/initial/specify/fork blocks
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76 elseif last_line =~ '`\@<!\<\(if\|else\)\>' ||
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
77 \ last_line =~ '^\s*\<\(for\|case\%[[zx]]\|do\|foreach\|forever\|randcase\)\>' ||
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
78 \ last_line =~ '^\s*\<\(always\|always_comb\|always_ff\|always_latch\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
79 \ last_line =~ '^\s*\<\(initial\|specify\|fork\|final\)\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80 if last_line !~ '\(;\|\<end\>\)\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . sv_comment . '*$'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83 if vverb | echo vverb_str "Indent after a block statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 " Indent after function/task/class/package/sequence/clocking/
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 " interface/covergroup/property/checkerprogram blocks
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87 elseif last_line =~ '^\s*\<\(function\|task\|class\|package\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 \ last_line =~ '^\s*\<\(sequence\|clocking\|interface\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
89 \ last_line =~ '^\s*\(\w\+\s*:\)\=\s*\<covergroup\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90 \ last_line =~ '^\s*\<\(property\|checker\|program\)\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
91 if last_line !~ '\<end\>\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . sv_comment . '*$'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 echo vverb_str "Indent after function/task/class block statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 " Indent after module/function/task/specify/fork blocks
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100 elseif last_line =~ '^\s*\(\<extern\>\s*\)\=\<module\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 let ind = ind + indent_modules
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 if vverb && indent_modules
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 echo vverb_str "Indent after module statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
105 if last_line =~ '[(,]\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
106 \ last_line !~ '\(//\|/\*\).*[(,]\s*' . sv_comment . '*$'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
109 echo vverb_str "Indent after a multiple-line module statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 " Indent after a 'begin' statement
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 elseif last_line =~ '\(\<begin\>\)\(\s*:\s*\w\+\)*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 \ last_line !~ '\(//\|/\*\).*\(\<begin\>\)' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 \ ( last_line2 !~ sv_openstat . '\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 \ last_line2 =~ '^\s*[^=!]\+\s*:\s*' . sv_comment . '*$' )
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 if vverb | echo vverb_str "Indent after begin statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
120
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121 " Indent after a '{' or a '('
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 elseif last_line =~ '[{(]' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 \ last_line !~ '\(//\|/\*\).*[{(]' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 \ ( last_line2 !~ sv_openstat . '\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 \ last_line2 =~ '^\s*[^=!]\+\s*:\s*' . sv_comment . '*$' )
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127 if vverb | echo vverb_str "Indent after begin statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 " De-indent for the end of one-line block
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 elseif ( last_line !~ '\<begin\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131 \ last_line =~ '\(//\|/\*\).*\<begin\>' ) &&
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
132 \ last_line2 =~ '\<\(`\@<!if\|`\@<!else\|for\|always\|initial\|do\|foreach\|forever\|final\)\>.*' .
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
133 \ sv_comment . '*$' &&
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
134 \ last_line2 !~ '\(//\|/\*\).*\<\(`\@<!if\|`\@<!else\|for\|always\|initial\|do\|foreach\|forever\|final\)\>' &&
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
135 \ last_line2 !~ sv_openstat . '\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
136 \ ( last_line2 !~ '\<begin\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 \ last_line2 =~ '\(//\|/\*\).*\<begin\>' )
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
138 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 echo vverb_str "De-indent after the end of one-line statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
142
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
143 " Multiple-line statement (including case statement)
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
144 " Open statement
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
145 " Ident the first open line
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
146 elseif last_line =~ sv_openstat . '\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
147 \ last_line !~ '\(//\|/\*\).*' . sv_openstat . '\s*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
148 \ last_line2 !~ sv_openstat . '\s*' . sv_comment . '*$'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
149 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
150 if vverb | echo vverb_str "Indent after an open statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
151
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
152 " Close statement
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
153 " De-indent for an optional close parenthesis and a semicolon, and only
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
154 " if there exists precedent non-whitespace char
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
155 elseif last_line =~ ')*\s*;\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
156 \ last_line !~ '^\s*)*\s*;\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
157 \ last_line !~ '\(//\|/\*\).*\S)*\s*;\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 \ ( last_line2 =~ sv_openstat . '\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
159 \ last_line2 !~ ';\s*//.*$') &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
160 \ last_line2 !~ '^\s*' . sv_comment . '$'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
161 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
162 if vverb | echo vverb_str "De-indent after a close statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
163
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
164 " `ifdef and `else
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
165 elseif last_line =~ '^\s*`\<\(ifdef\|else\)\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
166 let ind = ind + offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 echo vverb_str "Indent after a `ifdef or `else statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
172
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 " Re-indent current line
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
175 " De-indent on the end of the block
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
176 " join/end/endcase/endfunction/endtask/endspecify
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177 if curr_line =~ '^\s*\<\(join\|join_any\|join_none\|\|end\|endcase\|while\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
178 \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\|endclass\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
179 \ curr_line =~ '^\s*\<\(endpackage\|endsequence\|endclocking\|endinterface\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
180 \ curr_line =~ '^\s*\<\(endgroup\|endproperty\|endchecker\|endprogram\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
181 \ curr_line =~ '^\s*}'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
182 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
183 if vverb | echo vverb_str "De-indent the end of a block." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
184 elseif curr_line =~ '^\s*\<endmodule\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
185 let ind = ind - indent_modules
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
186 if vverb && indent_modules
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
187 echo vverb_str "De-indent the end of a module."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
188 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
189
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
190 " De-indent on a stand-alone 'begin'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191 elseif curr_line =~ '^\s*\<begin\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
192 if last_line !~ '^\s*\<\(function\|task\|specify\|module\|class\|package\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
193 \ last_line !~ '^\s*\<\(sequence\|clocking\|interface\|covergroup\)\>' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
194 \ last_line !~ '^\s*\<\(property\|checker\|program\)\>' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
195 \ last_line !~ '^\s*\()*\s*;\|)\+\)\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
196 \ ( last_line =~
18186
03b854983b14 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 11518
diff changeset
197 \ '\<\(`\@<!if\|`\@<!else\|for\|case\%[[zx]]\|always\|initial\|do\|foreach\|forever\|randcase\|final\)\>' ||
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
198 \ last_line =~ ')\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
199 \ last_line =~ sv_openstat . '\s*' . sv_comment . '*$' )
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
200 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
201 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
202 echo vverb_str "De-indent a stand alone begin statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
203 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
204 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
205
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
206 " De-indent after the end of multiple-line statement
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
207 elseif curr_line =~ '^\s*)' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
208 \ ( last_line =~ sv_openstat . '\s*' . sv_comment . '*$' ||
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
209 \ last_line !~ sv_openstat . '\s*' . sv_comment . '*$' &&
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
210 \ last_line2 =~ sv_openstat . '\s*' . sv_comment . '*$' )
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
211 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
212 if vverb
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
213 echo vverb_str "De-indent the end of a multiple statement."
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
214 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
215
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
216 " De-indent `else and `endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
217 elseif curr_line =~ '^\s*`\<\(else\|endif\)\>'
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
218 let ind = ind - offset
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
219 if vverb | echo vverb_str "De-indent `else and `endif statement." | endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
220
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
221 endif
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
222
25773
11b656e74444 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 23573
diff changeset
223 " Return the indentation
5663
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
224 return ind
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
225 endfunction
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
226
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
227 let &cpo = s:cpo_save
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
228 unlet s:cpo_save
1dea14d4c738 Update runtime files. Add support for systemverilog.
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
229
23573
e2e2cc5d0856 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 18186
diff changeset
230 " vim:sw=2