mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
vim-patch:9.2.0557: filetype: Kawasaki Robots files are not recognized
Problem: filetype: Kawasaki Robots files are not recognized
Solution: Detect *.pg as kawasaki_as filetype, add filetype detection
for *.as as atlas or kawasaki_as filetype (KnoP-01).
In Kawasaki robots (https://kawasakirobotics.com/products-robots/)
AS language
*.pg is the extention for a program file and
*.as is for a complete backup.
closes: vim/vim#20370
dec3d6c7da
Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
This commit is contained in:
@@ -137,6 +137,7 @@ variables can be used to overrule the filetype used for certain extensions:
|
||||
|
||||
file name variable ~
|
||||
`*.app` g:filetype_app
|
||||
`*.as` g:filetype_as
|
||||
`*.asa` g:filetype_asa |ft-aspperl-syntax|
|
||||
|ft-aspvbs-syntax|
|
||||
`*.asm` g:asmsyntax |ft-asm-syntax|
|
||||
|
||||
@@ -275,7 +275,7 @@ local extension = {
|
||||
astro = 'astro',
|
||||
asy = 'asy',
|
||||
atl = 'atlas',
|
||||
as = 'atlas',
|
||||
as = detect.as,
|
||||
zed = 'authzed',
|
||||
ahk = 'autohotkey',
|
||||
au3 = 'autoit',
|
||||
@@ -730,6 +730,7 @@ local extension = {
|
||||
JUST = 'just',
|
||||
kl = 'karel',
|
||||
KL = 'karel',
|
||||
pg = 'kawasaki_as',
|
||||
kdl = 'kdl',
|
||||
kerml = 'kerml',
|
||||
kv = 'kivy',
|
||||
|
||||
@@ -63,6 +63,20 @@ function M.app(path, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
-- This function checks for Kawasaki robots AS file or atlas file type.
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.as(_, bufnr)
|
||||
if vim.g.filetype_as then
|
||||
return vim.g.filetype_as
|
||||
end
|
||||
for _, line in ipairs(getlines(bufnr, 1, 30)) do
|
||||
if line:find('^%.NETCONF') then
|
||||
return 'kawasaki_as'
|
||||
end
|
||||
end
|
||||
return 'atlas'
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
--- @return boolean
|
||||
local function is_objectscript_routime(bufnr)
|
||||
|
||||
@@ -433,6 +433,7 @@ func s:GetFilenameChecks() abort
|
||||
\ 'julia': ['file.jl'],
|
||||
\ 'just': ['justfile', 'Justfile', '.justfile', 'config.just'],
|
||||
\ 'karel': ['file.kl', 'file.KL'],
|
||||
\ 'kawasaki_as': ['file.pg'],
|
||||
\ 'kconfig': ['Kconfig', 'Kconfig.debug', 'Kconfig.file', 'Config.in', 'Config.in.host'],
|
||||
\ 'kdl': ['file.kdl'],
|
||||
\ 'kerml': ['file.kerml'],
|
||||
@@ -3526,4 +3527,19 @@ func Test_cucumber_code_injection()
|
||||
filetype plugin off
|
||||
endfunc
|
||||
|
||||
func Test_as_file()
|
||||
filetype on
|
||||
|
||||
call writefile([], 'Xfile.as', 'D')
|
||||
split Xfile.as
|
||||
call assert_equal('atlas', &filetype)
|
||||
bwipe!
|
||||
call writefile(['', '.NETCONF'], 'Xfile.as', 'D')
|
||||
split Xfile.as
|
||||
call assert_equal('kawasaki_as', &filetype)
|
||||
bwipe!
|
||||
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user