changeset 28351:1aa3460f799d v8.2.4701

patch 8.2.4701: Kuka Robot Language files not recognized Commit: https://github.com/vim/vim/commit/3ad2090316edc85e93094bba7af64f9991cc7f85 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Apr 6 18:57:39 2022 +0100 patch 8.2.4701: Kuka Robot Language files not recognized Problem: Kuka Robot Language files not recognized. Solution: Recognize *.src and *.dat files. (Patrick Meiser-Knosowski, closes #10096)
author Bram Moolenaar <Bram@vim.org>
date Wed, 06 Apr 2022 20:00:03 +0200
parents 12d0eb14c3f2
children 10886e23615f
files runtime/autoload/dist/ft.vim runtime/filetype.vim src/testdir/test_filetype.vim src/version.c
diffstat 4 files changed, 73 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -896,6 +896,23 @@ export def FTtf()
   setf tf
 enddef
 
+# Determine if a *.src file is Kuka Robot Language
+export def FTsrc()
+  if exists("g:filetype_src")
+    exe "setf " .. g:filetype_src
+  elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)'
+    setf krl
+  endif
+enddef
+
+# Determine if a *.dat file is Kuka Robot Language
+export def FTdat()
+  if exists("g:filetype_dat")
+    exe "setf " .. g:filetype_dat
+  elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)'
+    setf krl
+  endif
+enddef
 
 # Uncomment this line to check for compilation errors early
 # defcompile
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -951,6 +951,11 @@ au BufNewFile,BufRead *.jl			setf julia
 " Kixtart
 au BufNewFile,BufRead *.kix			setf kix
 
+" Kuka Robot Language
+au BufNewFile,BufRead *.src\c			call dist#ft#FTsrc()
+au BufNewFile,BufRead *.dat\c			call dist#ft#FTdat()
+au BufNewFile,BufRead *.sub\c			setf krl
+
 " Kimwitu[++]
 au BufNewFile,BufRead *.k			setf kwt
 
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -290,6 +290,7 @@ let s:filename_checks = {
     \ 'kivy': ['file.kv'],
     \ 'kix': ['file.kix'],
     \ 'kotlin': ['file.kt', 'file.ktm', 'file.kts'],
+    \ 'krl': ['file.sub', 'file.Sub', 'file.SUB'],
     \ 'kscript': ['file.ks'],
     \ 'kwt': ['file.k'],
     \ 'lace': ['file.ace', 'file.ACE'],
@@ -869,6 +870,30 @@ func Test_d_file()
   call delete('Xfile.d')
 endfunc
 
+func Test_dat_file()
+  filetype on
+
+  call writefile(['&ACCESS'], 'datfile.dat')
+  split datfile.dat
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('datfile.dat')
+
+  call writefile(['  DEFDAT datfile'], 'datfile.Dat')
+  split datfile.Dat
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('datfile.Dat')
+
+  call writefile(['', 'defdat  datfile'], 'datfile.DAT')
+  split datfile.DAT
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('datfile.DAT')
+
+  filetype off
+endfunc
+
 func Test_dep3patch_file()
   filetype on
 
@@ -1311,6 +1336,30 @@ func Test_pp_file()
   filetype off
 endfunc
 
+func Test_src_file()
+  filetype on
+
+  call writefile(['&ACCESS'], 'srcfile.src')
+  split srcfile.src
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('srcfile.src')
+
+  call writefile(['  DEF srcfile()'], 'srcfile.Src')
+  split srcfile.Src
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('srcfile.Src')
+
+  call writefile(['', 'global  def  srcfile()'], 'srcfile.SRC')
+  split srcfile.SRC
+  call assert_equal('krl', &filetype)
+  bwipe!
+  call delete('srcfile.SRC')
+
+  filetype off
+endfunc
+
 func Test_tex_file()
   filetype on
 
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4701,
+/**/
     4700,
 /**/
     4699,