annotate runtime/indent/systemverilog.vim @ 28419:6e501ecd1bb7 v8.2.4734

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