@@ -1186,26 +1186,46 @@ export def FTv()
11861186 # " :setf" will do nothing, bail out early
11871187 return
11881188 endif
1189+ if exists (" g:filetype_v" )
1190+ exe " setf " .. g: filetype_v
1191+ return
1192+ endif
11891193
1190- for line in getline (1 , 200 )
1191- if line [0 ] = ~ ' ^\s*/'
1194+ var in_comment = 0
1195+ for lnum in range (1 , min ([line (" $" ), 200 ]))
1196+ var line = getline (lnum)
1197+ # Skip Verilog and V comments (lines and blocks).
1198+ if line = ~ ' ^\s*/\*'
1199+ # start comment block
1200+ in_comment = 1
1201+ endif
1202+ if in_comment == 1
1203+ if line = ~ ' \*/'
1204+ # end comment block
1205+ in_comment = 0
1206+ endif
1207+ # skip comment - block line
1208+ continue
1209+ endif
1210+ if line = ~ ' ^\s*//'
11921211 # skip comment line
11931212 continue
11941213 endif
11951214
1196- # Verilog: line ends with ' ;' followed by an optional variable number of
1197- # spaces and an optional start of a comment .
1198- # Example: " b <= a + 1; // Add 1" .
1199- if line = ~ ' ;\(\s*\)\?\(/.*\)\?$'
1200- setf verilog
1215+ # Coq: line ends with a ' .' followed by an optional variable number of
1216+ # spaces or contains the start of a comment , but not inside a Verilog or V
1217+ # comment .
1218+ # Example: " Definition x := 10. (*" .
1219+ if (line = ~ ' \.\s*$' && line !~ ' /[/*]' ) || (line = ~ ' (\*' && line !~ ' /[/*].*(\*' )
1220+ setf coq
12011221 return
12021222 endif
12031223
1204- # Coq : line ends with a ' . ' followed by an optional variable number of
1224+ # Verilo g : line ends with ' ; ' followed by an optional variable number of
12051225 # spaces and an optional start of a comment .
1206- # Example: " Definition x := 10. (* " .
1207- if line = ~ ' \.\(\ s*\)\?\((\* .*\)\?$'
1208- setf coq
1226+ # Example: " b <= a + 1; // Add 1 " .
1227+ if line = ~ ' ;\ s*\(/[/*] .*\)\?$'
1228+ setf verilog
12091229 return
12101230 endif
12111231 endfor
0 commit comments