vim-patch:9.1.0998: filetype: TI assembly files are not recognized (#31929)

Problem:  filetype: TI assembly files are not recognized
Solution: inspect '*.sa' and assembly files and detect TI assembly
          files, include filetype plugin and syntax script for TI
          assembly files (Wu, Zhenyu)

closes: vim/vim#15827

4f73c07abf

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
This commit is contained in:
zeertzjq
2025-01-09 17:30:26 +08:00
committed by GitHub
parent d740a4274d
commit 3f0adf90de
5 changed files with 152 additions and 2 deletions

View File

@@ -1064,11 +1064,11 @@ local extension = {
builder = 'ruby',
rake = 'ruby',
rs = 'rust',
sa = detect.sa,
sage = 'sage',
sls = 'salt',
sas = 'sas',
sass = 'sass',
sa = 'sather',
sbt = 'sbt',
scala = 'scala',
ss = 'scheme',

View File

@@ -34,6 +34,12 @@ local matchregex = vim.filetype._matchregex
-- can be detected from the first five lines of the file.
--- @type vim.filetype.mapfn
function M.asm(path, bufnr)
-- tiasm uses `* commment`
local lines = table.concat(getlines(bufnr, 1, 10), '\n')
if findany(lines, { '^%*', '\n%*', 'Texas Instruments Incorporated' }) then
return 'tiasm'
end
local syntax = vim.b[bufnr].asmsyntax
if not syntax or syntax == '' then
syntax = M.asm_syntax(path, bufnr)
@@ -1424,6 +1430,15 @@ function M.sig(_, bufnr)
end
end
--- @type vim.filetype.mapfn
function M.sa(_, bufnr)
local lines = table.concat(getlines(bufnr, 1, 4), '\n')
if findany(lines, { '^;', '\n;' }) then
return 'tiasm'
end
return 'sather'
end
-- This function checks the first 25 lines of file extension "sc" to resolve
-- detection between scala and SuperCollider
--- @type vim.filetype.mapfn