2022-01-08 00:02:28 +01:00
|
|
|
" Last Change: 2022 Jan 08
|
2021-12-14 13:45:56 +01:00
|
|
|
|
|
|
|
|
function! s:foamFile(path)
|
2022-01-08 00:02:28 +01:00
|
|
|
" Return if file type already set
|
|
|
|
|
if (&filetype == 'foam')
|
|
|
|
|
return
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
let l:lines = getline(1, 15)
|
|
|
|
|
let l:f = -1
|
|
|
|
|
let l:o = -1
|
2021-12-14 13:45:56 +01:00
|
|
|
for line in lines
|
2022-01-10 11:31:00 +01:00
|
|
|
if (match(line, '\CFoamFile') >= 0)
|
2022-01-08 00:02:28 +01:00
|
|
|
let l:f = index(lines, line)
|
|
|
|
|
endif
|
2022-01-10 11:31:00 +01:00
|
|
|
if (match(line, '\Cobject') >= 0)
|
2022-01-08 00:02:28 +01:00
|
|
|
let l:o = index(lines, line)
|
2021-12-14 13:45:56 +01:00
|
|
|
endif
|
|
|
|
|
endfor
|
2022-01-10 11:31:00 +01:00
|
|
|
if ((l:o >= 0) && (l:f >= 0) && (l:o > l:f))
|
2022-01-08 00:02:28 +01:00
|
|
|
set filetype=foam
|
|
|
|
|
endif
|
2021-12-14 13:45:56 +01:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
autocmd FileType cpp call s:foamFile(expand("%"))
|
2022-01-08 00:02:28 +01:00
|
|
|
autocmd BufNewFile,BufRead *Dict,*Properties,fvSchemes,fvSolution,*/constant/g,*/0/* call s:foamFile(expand("%"))
|