aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-04-17 10:15:41 +0200
committerGitHub <noreply@github.com>2022-04-17 10:15:41 +0200
commit670ecfc0cd81d7ec213591c96d45922390d109b9 (patch)
tree7e4edd6bf57e5b314f15fd44c2d0c8e27ee66231
parentae325e627484fa0402a3fd8c75508c8c0f82a9c3 (diff)
downloadrneovim-670ecfc0cd81d7ec213591c96d45922390d109b9.tar.gz
rneovim-670ecfc0cd81d7ec213591c96d45922390d109b9.tar.bz2
rneovim-670ecfc0cd81d7ec213591c96d45922390d109b9.zip
vim-patch:8.2.4766: KRL files using "deffct" not recognized (#18137)
Problem: KRL files using "deffct" not recognized. Solution: Adjust the pattern used for matching. (Patrick Meiser-Knosowski, closes vim/vim#10200) https://github.com/vim/vim/commit/93c7a45e86934a92ec513b437fe9b8cc343c53e3
-rw-r--r--runtime/autoload/dist/ft.vim7
-rw-r--r--src/nvim/testdir/test_filetype.vim14
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'