patch 9.0.1539: typst filetype is not recognized

Problem:    Typst filetype is not recognized.
Solution:   Distinguish between sql and typst. (Gaetan Lepage, closes #12363)
This commit is contained in:
Gaetan Lepage
2023-05-10 22:01:55 +01:00
committed by Bram Moolenaar
parent 411da64e77
commit 4ce1bda869
5 changed files with 65 additions and 3 deletions

View File

@ -470,7 +470,7 @@ enddef
# Returns true if file content looks like LambdaProlog module
def IsLProlog(): bool
# skip apparent comments and blank lines, what looks like
# skip apparent comments and blank lines, what looks like
# LambdaProlog comment may be RAPID header
var l: number = nextnonblank(1)
while l > 0 && l < line('$') && getline(l) =~ '^\s*%' # LambdaProlog comment
@ -1106,6 +1106,31 @@ export def FTlsl()
endif
enddef
export def FTtyp()
if exists("g:filetype_typ")
exe "setf " .. g:filetype_typ
return
endif
# Look for SQL type definition syntax
for line in getline(1, 200)
# SQL type files may define the casing
if line =~ '^CASE\s\==\s\=\(SAME\|LOWER\|UPPER\|OPPOSITE\)$'
setf sql
return
endif
# SQL type files may define some types as follows
if line =~ '^TYPE\s.*$'
setf sql
return
endif
endfor
# Otherwise, affect the typst filetype
setf typst
enddef
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
# lines.
export def FTv()