mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-07 05:50:04 -04:00
Better ftdetect for OpenFOAM
This commit is contained in:
parent
76f34166bf
commit
99d4d7e2d8
1 changed files with 18 additions and 5 deletions
|
|
@ -1,13 +1,26 @@
|
|||
" Last Change: 2021 Dec 13
|
||||
" Last Change: 2022 Jan 08
|
||||
|
||||
function! s:foamFile(path)
|
||||
let l:lines = getline(1, 10)
|
||||
" 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
|
||||
for line in lines
|
||||
if match(line, 'FoamFile') >= 0
|
||||
set filetype=foam
|
||||
if (match(line, 'FoamFile') >= 0)
|
||||
let l:f = index(lines, line)
|
||||
endif
|
||||
if (match(line, 'object') >= 0)
|
||||
let l:o = index(lines, line)
|
||||
endif
|
||||
endfor
|
||||
if ((l:o >= 0) && (l:f) && (l:o > l:f))
|
||||
set filetype=foam
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd BufNewFile,BufRead *Dict,*Properties,fvSchemes,fvSolution,*/constant/g,*/0/* call s:foamFile(expand("%"))
|
||||
autocmd FileType cpp call s:foamFile(expand("%"))
|
||||
autocmd BufNewFile,BufRead *Dict,*Properties,fvSchemes,fvSolution,*/constant/g,*/0/* call s:foamFile(expand("%"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue