vim-patch:9.0.0349: filetype of *.sil files not well detected (#20050)

Problem:    Filetype of *.sil files not well detected.
Solution:   Inspect the file contents to guess the filetype.
be807d5824
This commit is contained in:
Jonas Strittmatter
2022-09-02 08:16:17 +02:00
committed by GitHub
parent 12fe197cff
commit ce80b8f50d
5 changed files with 75 additions and 5 deletions

View File

@@ -468,7 +468,7 @@ endfunc
" Returns true if file content looks like LambdaProlog module
func IsLProlog()
" skip apparent comments and blank lines, what looks like
" skip apparent comments and blank lines, what looks like
" LambdaProlog comment may be RAPID header
let l = nextnonblank(1)
while l > 0 && l < line('$') && getline(l) =~ '^\s*%' " LambdaProlog comment
@@ -877,6 +877,23 @@ func dist#ft#FTsig()
endif
endfunc
" This function checks the first 100 lines of files matching "*.sil" to
" resolve detection between Swift Intermediate Language and SILE.
func dist#ft#FTsil()
for lnum in range(1, [line('$'), 100]->min())
let line = getline(lnum)
if line =~ '^\s*[\\%]'
setf sile
return
elseif line =~ '^\s*\S'
setf sil
return
endif
endfor
" no clue, default to "sil"
setf sil
endfunc
func dist#ft#FTsys()
if exists("g:filetype_sys")
exe "setf " .. g:filetype_sys