mirror of
https://github.com/neovim/neovim.git
synced 2026-08-30 19:11:52 +00:00
vim-patch:9.2.0237: filetype: ObjectScript routines are not recognized (#38479)
Problem: filetype: ObjectScript routines are not recognized
Solution: Add ObjectScript routines detection for .mac, .int, and .inc
files (Hannah Kimura)
Reference:
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GORIENT_ch_intro#GORIENT_intro_routines
closes: vim/vim#19805
25f6539645
Co-authored-by: Hannah Kimura <hannah.kimura@intersystems.com>
This commit is contained in:
@@ -233,7 +233,6 @@ local extension = {
|
||||
a = detect.asm,
|
||||
A = detect.asm,
|
||||
lst = detect.asm,
|
||||
mac = detect.asm,
|
||||
asn1 = 'asn',
|
||||
asn = 'asn',
|
||||
asp = detect.asp,
|
||||
@@ -598,7 +597,6 @@ local extension = {
|
||||
ihex = 'hex',
|
||||
ihe = 'hex',
|
||||
ihx = 'hex',
|
||||
int = 'hex',
|
||||
mcs = 'hex',
|
||||
hjson = 'hjson',
|
||||
m3u = 'hlsplaylist',
|
||||
@@ -633,6 +631,7 @@ local extension = {
|
||||
ii = 'initng',
|
||||
inko = 'inko',
|
||||
inp = detect.inp,
|
||||
int = detect.int,
|
||||
ms = detect_seq(detect.nroff, 'xmath'),
|
||||
ipkg = 'ipkg',
|
||||
iss = 'iss',
|
||||
@@ -764,6 +763,7 @@ local extension = {
|
||||
mc = detect.mc,
|
||||
quake = 'm3quake',
|
||||
m4 = detect.m4,
|
||||
mac = detect.mac,
|
||||
eml = 'mail',
|
||||
mk = detect.make,
|
||||
mak = detect.make,
|
||||
|
||||
@@ -63,6 +63,14 @@ function M.app(path, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
--- @return boolean
|
||||
local function is_objectscript_routime(bufnr)
|
||||
local line1 = getline(bufnr, 1)
|
||||
line1 = fn.substitute(line1, [[^\ufeff]], '', '')
|
||||
return matchregex(line1, [[\c^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)]])
|
||||
end
|
||||
|
||||
-- This function checks for the kind of assembly that is wanted by the user, or
|
||||
-- can be detected from the beginning of the file.
|
||||
--- @type vim.filetype.mapfn
|
||||
@@ -85,6 +93,17 @@ function M.asm(path, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.mac(path, bufnr)
|
||||
if vim.g.filetype_mac then
|
||||
return vim.g.filetype_mac
|
||||
elseif is_objectscript_routime(bufnr) then
|
||||
return 'objectscript_routine'
|
||||
else
|
||||
return M.asm(path, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
-- Checks the first lines for a asmsyntax=foo override.
|
||||
-- Only whitespace characters can be present immediately before or after this statement.
|
||||
--- @type vim.filetype.mapfn
|
||||
@@ -896,6 +915,9 @@ function M.inc(path, bufnr)
|
||||
if vim.g.filetype_inc then
|
||||
return vim.g.filetype_inc
|
||||
end
|
||||
if is_objectscript_routime(bufnr) then
|
||||
return 'objectscript_routine'
|
||||
end
|
||||
for _, line in ipairs(getlines(bufnr, 1, 20)) do
|
||||
if line:lower():find('perlscript') then
|
||||
return 'aspperl'
|
||||
@@ -945,6 +967,17 @@ function M.install(path, bufnr)
|
||||
return M.bash(path, bufnr)
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.int(_, bufnr)
|
||||
if vim.g.filetype_int then
|
||||
return vim.g.filetype_int
|
||||
elseif is_objectscript_routime(bufnr) then
|
||||
return 'objectscript_routine'
|
||||
else
|
||||
return 'hex'
|
||||
end
|
||||
end
|
||||
|
||||
--- Innovation Data Processing
|
||||
--- (refactor of filetype.vim since the patterns are case-insensitive)
|
||||
--- @type vim.filetype.mapfn
|
||||
|
||||
Reference in New Issue
Block a user