runtime(filetype): Improve Verilog detection by checking for modules definition
Commit: https://github.com/vim/vim/commit/99181205c5f8284a30f839107a12932924168f17 Author: Christian Brabandt <c...@256bit.org> Date: Sat Jan 25 14:54:28 2025 +0100 runtime(filetype): Improve Verilog detection by checking for modules definition While at it, also increase the maximum number of lines to check to 500. fixes: #16513 Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 5bbf8ee25..819f51f57 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -3,7 +3,7 @@ vim9script # Vim functions for file type detection # # Maintainer: The Vim Project <https://github.com/vim/vim> -# Last Change: 2025 Jan 11 +# Last Change: 2025 Jan 25 # Former Maintainer: Bram Moolenaar <b...@vim.org> # These functions are moved here from runtime/filetype.vim to make startup @@ -1384,7 +1384,7 @@ export def FTdsp() setf faust enddef -# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200 +# Set the filetype of a *.v file to Verilog, V or Cog based on the first 500 # lines. export def FTv() if did_filetype() @@ -1397,7 +1397,7 @@ export def FTv() endif var in_comment = 0 - for lnum in range(1, min([line("$"), 200])) + for lnum in range(1, min([line("$"), 500])) var line = getline(lnum) # Skip Verilog and V comments (lines and blocks). if line =~ '^\s*/\*' @@ -1429,7 +1429,8 @@ export def FTv() # Verilog: line ends with ';' followed by an optional variable number of # spaces and an optional start of a comment. # Example: " b <= a + 1; // Add 1". - if line =~ ';\s*\(/[/*].*\)\?$' + # Alternatively: a module is defined: " module MyModule" + if line =~ ';\s*\(/[/*].*\)\?$' || line =~ '\C^\s*module\>' setf verilog return endif -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tbhAk-000hzq-FM%40256bit.org.