vim-patch:9.0.1820: Rexx files may not be recognised (#24956)

Problem:  Rexx files may not be recognised
Solution: Add shebang detection and improve disambiguation of *.cls
	  files

closes: vim/vim#12951

e06afb7860

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
This commit is contained in:
zeertzjq
2023-08-31 08:20:00 +08:00
committed by GitHub
parent 7914881356
commit 5d49542b56
2 changed files with 27 additions and 4 deletions

View File

@@ -194,13 +194,18 @@ function M.cls(_, bufnr)
return vim.g.filetype_cls
end
local line1 = getline(bufnr, 1)
if line1:find('^[%%\\]') then
return 'tex'
elseif line1:find('^#') and line1:lower():find('rexx') then
if matchregex(line1, [[^#!.*\<\%(rexx\|regina\)\>]]) then
return 'rexx'
elseif line1 == 'VERSION 1.0 CLASS' then
return 'vb'
end
local nonblank1 = nextnonblank(bufnr, 1)
if nonblank1 and nonblank1:find('^[%%\\]') then
return 'tex'
elseif nonblank1 and findany(nonblank1, { '^%s*/%*', '^%s*::%w' }) then
return 'rexx'
end
return 'st'
end
@@ -1648,6 +1653,7 @@ local patterns_hashbang = {
guile = 'scheme',
['nix%-shell'] = 'nix',
['crystal\\>'] = { 'crystal', { vim_regex = true } },
['^\\%(rexx\\|regina\\)\\>'] = { 'rexx', { vim_regex = true } },
}
---@private