patch 8.2.4064: foam files are not detected

Problem:    Foam files are not detected.
Solution:   Detect the foam filetype by the path and file contents. (Mohammed
            Elwardi Fadeli, closes #9501)
This commit is contained in:
Elwardi
2022-01-11 18:14:23 +00:00
committed by Bram Moolenaar
parent b8822442d7
commit 2284f6cca3
4 changed files with 72 additions and 0 deletions

View File

@ -829,6 +829,23 @@ func dist#ft#Dep3patch()
endfor
endfunc
" This function checks the first 15 lines for appearance of 'FoamFile'
" and then 'object' in a following line.
" In that case, it's probably an OpenFOAM file
func dist#ft#FTfoam()
let ffile = 0
let lnum = 1
while lnum <= 15
if getline(lnum) =~# '^FoamFile'
let ffile = 1
elseif ffile == 1 && getline(lnum) =~# '^\s*object'
setf foam
return
endif
let lnum = lnum + 1
endwhile
endfunc
" Restore 'cpoptions'
let &cpo = s:cpo_save
unlet s:cpo_save