diff options
Diffstat (limited to 'runtime/lua/vim/filetype')
| -rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 0d9c1ebc2b..a1c17bc1af 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -219,6 +219,24 @@ function M.cls(_, bufnr) return 'st' end +--- *.cmd is close to a Batch file, but on OS/2 Rexx files and TI linker command files also use *.cmd. +--- lnk: `/* comment */`, `// comment`, and `--linker-option=value` +--- rexx: `/* comment */`, `-- comment` +--- @type vim.filetype.mapfn +function M.cmd(_, bufnr) + local lines = table.concat(getlines(bufnr, 1, 20)) + if matchregex(lines, [[MEMORY\|SECTIONS\|\%(^\|\n\)--\S\|\%(^\|\n\)//]]) then + return 'lnk' + else + local line1 = getline(bufnr, 1) + if line1:find('^/%*') then + return 'rexx' + else + return 'dosbatch' + end + end +end + --- @type vim.filetype.mapfn function M.conf(path, bufnr) if fn.did_filetype() ~= 0 or path:find(vim.g.ft_ignore_pat) then |