diff runtime/indent/verilog.vim @ 12254:8d76a56861ec

Update runtime files commit https://github.com/vim/vim/commit/c572da5f67aa5cdbbc127fc6f1d0a42e38468325 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 27 16:52:01 2017 +0200 Update runtime files
author Christian Brabandt <cb@256bit.org>
date Sun, 27 Aug 2017 17:00:05 +0200
parents 1218c5353e2b
children 11b656e74444
line wrap: on
line diff
--- a/runtime/indent/verilog.vim
+++ b/runtime/indent/verilog.vim
@@ -1,6 +1,6 @@
 " Language:     Verilog HDL
 " Maintainer:	Chih-Tsun Huang <cthuang@cs.nthu.edu.tw>
-" Last Change:	2017 Feb 24 by Chih-Tsun Huang
+" Last Change:	2017 Aug 25 by Chih-Tsun Huang
 " URL:		    http://www.cs.nthu.edu.tw/~cthuang/vim/indent/verilog.vim
 "
 " Credits:
@@ -25,7 +25,8 @@ let b:did_indent = 1
 setlocal indentexpr=GetVerilogIndent()
 setlocal indentkeys=!^F,o,O,0),=begin,=end,=join,=endcase
 setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify
-setlocal indentkeys+==`else,=`endif
+setlocal indentkeys+==endconfig,=endgenerate,=endprimitive,=endtable
+setlocal indentkeys+==`else,=`elsif,=`endif
 
 " Only define the function once.
 if exists("*GetVerilogIndent")
@@ -84,7 +85,9 @@ function GetVerilogIndent()
     endif
 
   " Indent after if/else/for/case/always/initial/specify/fork blocks
-  elseif last_line =~ '`\@<!\<\(if\|else\)\>' ||
+  " Note: We exclude '`if' or '`else' and consider 'end else' 
+  "       'end if' is redundant here
+  elseif last_line =~ '^\s*\(end\)\=\s*`\@<!\<\(if\|else\)\>' ||
     \ last_line =~ '^\s*\<\(for\|case\%[[zx]]\)\>' ||
     \ last_line =~ '^\s*\<\(always\|initial\)\>' ||
     \ last_line =~ '^\s*\<\(specify\|fork\)\>'
@@ -93,8 +96,8 @@ function GetVerilogIndent()
       let ind = ind + offset
       if vverb | echo vverb_str "Indent after a block statement." | endif
     endif
-  " Indent after function/task blocks
-  elseif last_line =~ '^\s*\<\(function\|task\)\>'
+  " Indent after function/task/config/generate/primitive/table blocks
+  elseif last_line =~ '^\s*\<\(function\|task\|config\|generate\|primitive\|table\)\>'
     if last_line !~ '\<end\>\s*' . vlog_comment . '*$' ||
       \ last_line =~ '\(//\|/\*\).*\(;\|\<end\>\)\s*' . vlog_comment . '*$'
       let ind = ind + offset
@@ -161,11 +164,11 @@ function GetVerilogIndent()
       let ind = ind - offset
       if vverb | echo vverb_str "De-indent after a close statement." | endif
 
-  " `ifdef and `else
-  elseif last_line =~ '^\s*`\<\(ifdef\|else\)\>'
+  " `ifdef or `ifndef or `elsif or `else
+  elseif last_line =~ '^\s*`\<\(ifn\?def\|elsif\|else\)\>'
     let ind = ind + offset
     if vverb
-      echo vverb_str "Indent after a `ifdef or `else statement."
+      echo vverb_str "Indent after a `ifdef or `ifndef or `elsif or `else statement."
     endif
 
   endif
@@ -175,7 +178,8 @@ function GetVerilogIndent()
   " De-indent on the end of the block
   " join/end/endcase/endfunction/endtask/endspecify
   if curr_line =~ '^\s*\<\(join\|end\|endcase\)\>' ||
-    \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\)\>'
+    \ curr_line =~ '^\s*\<\(endfunction\|endtask\|endspecify\)\>' ||
+    \ curr_line =~ '^\s*\<\(endconfig\|endgenerate\|endprimitive\|endtable\)\>'
     let ind = ind - offset
     if vverb | echo vverb_str "De-indent the end of a block." | endif
   elseif curr_line =~ '^\s*\<endmodule\>'
@@ -186,7 +190,7 @@ function GetVerilogIndent()
 
   " De-indent on a stand-alone 'begin'
   elseif curr_line =~ '^\s*\<begin\>'
-    if last_line !~ '^\s*\<\(function\|task\|specify\|module\)\>' &&
+    if last_line !~ '^\s*\<\(function\|task\|specify\|module\|config\|generate\|primitive\|table\)\>' &&
       \ last_line !~ '^\s*\()*\s*;\|)\+\)\s*' . vlog_comment . '*$' &&
       \ ( last_line =~
 	\ '\<\(`\@<!if\|`\@<!else\|for\|case\%[[zx]]\|always\|initial\)\>' ||
@@ -208,10 +212,10 @@ function GetVerilogIndent()
       echo vverb_str "De-indent the end of a multiple statement."
     endif
 
-  " De-indent `else and `endif
-  elseif curr_line =~ '^\s*`\<\(else\|endif\)\>'
+  " De-indent `elsif or `else or `endif
+  elseif curr_line =~ '^\s*`\<\(elsif\|else\|endif\)\>'
     let ind = ind - offset
-    if vverb | echo vverb_str "De-indent `else and `endif statement." | endif
+    if vverb | echo vverb_str "De-indent `elsif or `else or `endif statement." | endif
 
   endif