diff options
author | Christian Clason <c.clason@uni-graz.at> | 2024-12-31 11:53:02 +0100 |
---|---|---|
committer | Christian Clason <ch.clason+github@icloud.com> | 2024-12-31 12:29:35 +0100 |
commit | 1877cd5fcdc0bbe5f3d0685d42d4e295fb819724 (patch) | |
tree | b0171f103d6e42e5c71cf1b688565e7dd56f9273 /runtime/lua/vim | |
parent | 7ecd348b3da3bd27a0dd8db07896bf17a86bb26c (diff) | |
download | rneovim-1877cd5fcdc0bbe5f3d0685d42d4e295fb819724.tar.gz rneovim-1877cd5fcdc0bbe5f3d0685d42d4e295fb819724.tar.bz2 rneovim-1877cd5fcdc0bbe5f3d0685d42d4e295fb819724.zip |
vim-patch:9.1.0982: TI linker files are not recognized
Problem: TI linker files are not recognized
Solution: inspect '*.cmd' files and detect TI linker files
as 'lnk' filetype, include a lnk ftplugin and syntax
script (Wu, Zhenyu)
closes: vim/vim#16320
https://github.com/vim/vim/commit/39a4eb0b2ca901b59800fad086550053556e59dc
Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index cef3d667d3..173de8b5d5 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -1393,7 +1393,7 @@ local extension = { txt = detect.txt, xml = detect.xml, y = detect.y, - cmd = detect_line1('^/%*', 'rexx', 'dosbatch'), + cmd = detect.cmd, rul = detect.rul, cpy = detect_line1('^##', 'python', 'cobol'), dsl = detect_line1('^%s*<!', 'dsl', 'structurizr'), 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 |