changeset 30890:ebcaf6bbb410 v9.0.0779

patch 9.0.0779: lsl and lm3 file extensions are not recognized Commit: https://github.com/vim/vim/commit/4ac8e7948cb3e07bc4598ede8b274891d14dfa7c Author: Doug Kearns <dougkearns@gmail.com> Date: Mon Oct 17 13:32:17 2022 +0100 patch 9.0.0779: lsl and lm3 file extensions are not recognized Problem: lsl and lm3 file extensions are not recognized. Solution: Add *.lsl and *.lm3 patterns. (Doug Kearns, closes https://github.com/vim/vim/issues/11384)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 Oct 2022 14:45:08 +0200
parents 712d3ac8e9d2
children 2b1d792efdf1
files runtime/autoload/dist/ft.vim runtime/doc/filetype.txt runtime/filetype.vim src/testdir/test_filetype.vim src/version.c
diffstat 5 files changed, 55 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -1087,5 +1087,18 @@ export def FTdat()
   endif
 enddef
 
+export def FTlsl()
+  if exists("g:filetype_lsl")
+    exe "setf " .. g:filetype_lsl
+  endif
+
+  var line = getline(nextnonblank(1))
+  if line =~ '^\s*%' || line =~# ':\s*trait\s*$'
+    setf larch
+  else
+    setf lsl
+  endif
+enddef
+
 # Uncomment this line to check for compilation errors early
 # defcompile
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -150,6 +150,7 @@ variables can be used to overrule the fi
 	*.fs		g:filetype_fs	|ft-forth-syntax|
 	*.i		g:filetype_i	|ft-progress-syntax|
 	*.inc		g:filetype_inc
+	*.lsl		g:filetype_lsl
 	*.m		g:filetype_m	|ft-mathematica-syntax|
 	*.mod		g:filetype_mod
 	*.p		g:filetype_p	|ft-pascal-syntax|
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1032,6 +1032,9 @@ au BufNewFile,BufRead Kconfig,Kconfig.de
 " Lace (ISE)
 au BufNewFile,BufRead *.ace,*.ACE		setf lace
 
+" Larch Shared Language
+au BufNewFile,BufRead .lsl			call dist#ft#FTlsl()
+
 " Latexmkrc
 au BufNewFile,BufRead .latexmkrc,latexmkrc	setf perl
 
@@ -1122,7 +1125,7 @@ au BufNewFile,BufRead .luacheckrc		setf 
 au BufNewFile,BufRead *.rockspec		setf lua
 
 " Linden Scripting Language (Second Life)
-au BufNewFile,BufRead *.lsl			setf lsl
+au BufNewFile,BufRead *.lsl			call dist#ft#FTlsl()
 
 " Lynx style file (or LotusScript!)
 au BufNewFile,BufRead *.lss			setf lss
@@ -1220,6 +1223,9 @@ au BufNewFile,BufRead *.m2,*.DEF,*.mi		s
 " Modula-3 (.m3, .i3, .mg, .ig)
 au BufNewFile,BufRead *.[mi][3g]		setf modula3
 
+" Larch/Modula-3
+au BufNewFile,BufRead *.lm3			setf modula3
+
 " Monk
 au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc	setf monk
 
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -365,7 +365,7 @@ let s:filename_checks = {
     \ 'mmp': ['file.mmp'],
     \ 'modconf': ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules', '/etc/modprobe.file', 'any/etc/conf.modules', 'any/etc/modprobe.file', 'any/etc/modules', 'any/etc/modules.conf'],
     \ 'modula2': ['file.m2', 'file.mi'],
-    \ 'modula3': ['file.m3', 'file.mg', 'file.i3', 'file.ig'],
+    \ 'modula3': ['file.m3', 'file.mg', 'file.i3', 'file.ig', 'file.lm3'],
     \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'],
     \ 'moo': ['file.moo'],
     \ 'moonscript': ['file.moon'],
@@ -1931,4 +1931,35 @@ func Test_inc_file()
   filetype off
 endfunc
 
+func Test_lsl_file()
+  filetype on
+
+  call writefile(['looks like Linden Scripting Language'], 'Xfile.lsl', 'D')
+  split Xfile.lsl
+  call assert_equal('lsl', &filetype)
+  bwipe!
+
+  " Test dist#ft#FTlsl()
+
+  let g:filetype_lsl = 'larch'
+  split Xfile.lsl
+  call assert_equal('larch', &filetype)
+  bwipe!
+  unlet g:filetype_lsl
+
+  " Larch Shared Language
+
+  call writefile(['% larch comment'], 'Xfile.lsl')
+  split Xfile.lsl
+  call assert_equal('larch', &filetype)
+  bwipe!
+
+  call writefile(['foo: trait'], 'Xfile.lsl')
+  split Xfile.lsl
+  call assert_equal('larch', &filetype)
+  bwipe!
+
+  filetype off
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    779,
+/**/
     778,
 /**/
     777,