vim-patch:9.0.0349: filetype of *.sil files not well detected (#20050)

Problem:    Filetype of *.sil files not well detected.
Solution:   Inspect the file contents to guess the filetype.
be807d5824
This commit is contained in:
Jonas Strittmatter
2022-09-02 08:16:17 +02:00
committed by GitHub
parent 12fe197cff
commit ce80b8f50d
5 changed files with 75 additions and 5 deletions

View File

@@ -902,7 +902,9 @@ local extension = {
sig = function(path, bufnr)
return require('vim.filetype.detect').sig(bufnr)
end,
sil = 'sil',
sil = function(path, bufnr)
return require('vim.filetype.detect').sil(bufnr)
end,
sim = 'simula',
['s85'] = 'sinda',
sin = 'sinda',

View File

@@ -1194,6 +1194,19 @@ function M.shell(path, contents, name)
return name
end
-- Swift Intermediate Language or SILE
function M.sil(bufnr)
for _, line in ipairs(getlines(bufnr, 1, 100)) do
if line:find('^%s*[\\%%]') then
return 'sile'
elseif line:find('^%s*%S') then
return 'sil'
end
end
-- No clue, default to "sil"
return 'sil'
end
-- SMIL or SNMP MIB file
function M.smi(bufnr)
local line = getlines(bufnr, 1)