mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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 <cb@256bit.org>
This commit is contained in:
9
runtime/autoload/dist/ft.vim
vendored
9
runtime/autoload/dist/ft.vim
vendored
@@ -3,7 +3,7 @@ vim9script
|
|||||||
# Vim functions for file type detection
|
# Vim functions for file type detection
|
||||||
#
|
#
|
||||||
# Maintainer: The Vim Project <https://github.com/vim/vim>
|
# Maintainer: The Vim Project <https://github.com/vim/vim>
|
||||||
# Last Change: 2025 Jan 11
|
# Last Change: 2025 Jan 25
|
||||||
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
|
|
||||||
# These functions are moved here from runtime/filetype.vim to make startup
|
# These functions are moved here from runtime/filetype.vim to make startup
|
||||||
@@ -1384,7 +1384,7 @@ export def FTdsp()
|
|||||||
setf faust
|
setf faust
|
||||||
enddef
|
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.
|
# lines.
|
||||||
export def FTv()
|
export def FTv()
|
||||||
if did_filetype()
|
if did_filetype()
|
||||||
@@ -1397,7 +1397,7 @@ export def FTv()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
var in_comment = 0
|
var in_comment = 0
|
||||||
for lnum in range(1, min([line("$"), 200]))
|
for lnum in range(1, min([line("$"), 500]))
|
||||||
var line = getline(lnum)
|
var line = getline(lnum)
|
||||||
# Skip Verilog and V comments (lines and blocks).
|
# Skip Verilog and V comments (lines and blocks).
|
||||||
if line =~ '^\s*/\*'
|
if line =~ '^\s*/\*'
|
||||||
@@ -1429,7 +1429,8 @@ export def FTv()
|
|||||||
# Verilog: line ends with ';' followed by an optional variable number of
|
# Verilog: line ends with ';' followed by an optional variable number of
|
||||||
# spaces and an optional start of a comment.
|
# spaces and an optional start of a comment.
|
||||||
# Example: " b <= a + 1; // Add 1".
|
# 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
|
setf verilog
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
Reference in New Issue
Block a user