diff options
-rw-r--r-- | runtime/autoload/dist/ft.vim | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 14 |
2 files changed, 13 insertions, 8 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 38fe8d4872..975e2c23d8 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -992,20 +992,23 @@ func dist#ft#FTtf() setf tf endfunc +let s:ft_krl_header = '\&\w+' " Determine if a *.src file is Kuka Robot Language func dist#ft#FTsrc() + let ft_krl_def_or_deffct = '%(global\s+)?def%(fct)?>' if exists("g:filetype_src") exe "setf " .. g:filetype_src - elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)' + elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. s:ft_krl_header .. '|' .. ft_krl_def_or_deffct .. ')' setf krl endif endfunc " Determine if a *.dat file is Kuka Robot Language func dist#ft#FTdat() + let ft_krl_defdat = 'defdat>' if exists("g:filetype_dat") exe "setf " .. g:filetype_dat - elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)' + elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. s:ft_krl_header .. '|' .. ft_krl_defdat .. ')' setf krl endif endfunc diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 85d9a75824..2a26c58bb6 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -743,7 +743,7 @@ func Test_setfiletype_completion() endfunc """"""""""""""""""""""""""""""""""""""""""""""""" -" Tests for specific extentions and filetypes. +" Tests for specific extensions and filetypes. " Keep sorted. """"""""""""""""""""""""""""""""""""""""""""""""" @@ -1535,11 +1535,13 @@ func Test_src_file() bwipe! call delete('srcfile.Src') - " KRL global def with embedded spaces, file starts with empty line(s). - call writefile(['', 'global def srcfile()'], 'srcfile.SRC') - split srcfile.SRC - call assert_equal('krl', &filetype) - bwipe! + " KRL global deffct with embedded spaces, file starts with empty line(s). + for text in ['global def srcfile()', 'global deffct srcfile()'] + call writefile(['', text], 'srcfile.SRC') + split srcfile.SRC + call assert_equal('krl', &filetype, text) + bwipe! + endfor " User may overrule file inspection let g:filetype_src = 'src' |