vim-patch:9.0.0779: lsl and lm3 file extensions are not recognized (#20704)

Problem:    lsl and lm3 file extensions are not recognized.
Solution:   Add *.lsl and *.lm3 patterns. (Doug Kearns, closes vim/vim#11384)
4ac8e7948c
This commit is contained in:
Christian Clason
2022-10-18 20:05:50 +02:00
committed by GitHub
parent aa2f08a050
commit 228a04070e
4 changed files with 54 additions and 2 deletions

View File

@@ -148,6 +148,7 @@ variables can be used to overrule the filetype used for certain extensions:
*.fs g:filetype_fs |ft-forth-syntax| *.fs g:filetype_fs |ft-forth-syntax|
*.i g:filetype_i |ft-progress-syntax| *.i g:filetype_i |ft-progress-syntax|
*.inc g:filetype_inc *.inc g:filetype_inc
*.lsl g:filetype_lsl
*.m g:filetype_m |ft-mathematica-syntax| *.m g:filetype_m |ft-mathematica-syntax|
*.mod g:filetype_mod *.mod g:filetype_mod
*.p g:filetype_p |ft-pascal-syntax| *.p g:filetype_p |ft-pascal-syntax|

View File

@@ -611,7 +611,9 @@ local extension = {
c = function(path, bufnr) c = function(path, bufnr)
return require('vim.filetype.detect').lpc(bufnr) return require('vim.filetype.detect').lpc(bufnr)
end, end,
lsl = 'lsl', lsl = function(path, bufnr)
return require('vim.filetype.detect').lsl(bufnr)
end,
lss = 'lss', lss = 'lss',
nse = 'lua', nse = 'lua',
rockspec = 'lua', rockspec = 'lua',
@@ -674,6 +676,7 @@ local extension = {
DEF = 'modula2', DEF = 'modula2',
['m2'] = 'modula2', ['m2'] = 'modula2',
mi = 'modula2', mi = 'modula2',
lm3 = 'modula3',
ssc = 'monk', ssc = 'monk',
monk = 'monk', monk = 'monk',
tsc = 'monk', tsc = 'monk',
@@ -1459,6 +1462,9 @@ local filename = {
['.sawfishrc'] = 'lisp', ['.sawfishrc'] = 'lisp',
['/etc/login.access'] = 'loginaccess', ['/etc/login.access'] = 'loginaccess',
['/etc/login.defs'] = 'logindefs', ['/etc/login.defs'] = 'logindefs',
['.lsl'] = function(path, bufnr)
return require('vim.filetype.detect').lsl(bufnr)
end,
['.luacheckrc'] = 'lua', ['.luacheckrc'] = 'lua',
['lynx.cfg'] = 'lynx', ['lynx.cfg'] = 'lynx',
['m3overrides'] = 'm3build', ['m3overrides'] = 'm3build',

View File

@@ -634,6 +634,19 @@ function M.lpc(bufnr)
return 'c' return 'c'
end end
function M.lsl(bufnr)
if vim.g.filetype_lsl then
return vim.g.filetype_lsl
end
local line = nextnonblank(bufnr, 1)
if findany(line, { '^%s*%%', ':%s*trait%s*$' }) then
return 'larch'
else
return 'lsl'
end
end
function M.m(bufnr) function M.m(bufnr)
if vim.g.filetype_m then if vim.g.filetype_m then
return vim.g.filetype_m return vim.g.filetype_m

View File

@@ -366,7 +366,7 @@ let s:filename_checks = {
\ 'mmp': ['file.mmp'], \ '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'], \ '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'], \ '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'], \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'],
\ 'moo': ['file.moo'], \ 'moo': ['file.moo'],
\ 'moonscript': ['file.moon'], \ 'moonscript': ['file.moon'],
@@ -1963,4 +1963,36 @@ func Test_inc_file()
filetype off filetype off
endfunc endfunc
func Test_lsl_file()
filetype on
call writefile(['looks like Linden Scripting Language'], 'Xfile.lsl')
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!
call delete('Xfile.lsl')
filetype off
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab