From 3280dc2b60db8d4e36bff6d481e3e873f32040b1 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sat, 9 Apr 2022 17:42:46 +0200 Subject: vim-patch:8.2.4720: ABB Rapid files are not recognized properly (#18057) Problem: ABB Rapid files are not recognized properly. Solution: Add checks for ABB Rapid files. (Patrick Meiser-Knosowski, closes #10104) https://github.com/vim/vim/commit/b09c320039ad49e62d2e2d7f14ba47ee3ca0706a --- runtime/autoload/dist/ft.vim | 71 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'runtime/autoload') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index f473d5f80b..0063e9da0b 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -112,6 +112,25 @@ func dist#ft#BindzoneCheck(default) endif endfunc +" Returns true if file content looks like RAPID +func IsRapid(sChkExt = "") + if a:sChkExt == "cfg" + return getline(1) =~? '\v^%(EIO|MMC|MOC|PROC|SIO|SYS):CFG' + endif + " called from FTmod, FTprg or FTsys + return getline(nextnonblank(1)) =~? '\v^\s*%(\%{3}|module\s+\k+\s*%(\(|$))' +endfunc + +func dist#ft#FTcfg() + if exists("g:filetype_cfg") + exe "setf " .. g:filetype_cfg + elseif IsRapid("cfg") + setf rapid + else + setf cfg + endif +endfunc + func dist#ft#FTlpc() if exists("g:lpc_syntax_for_c") let lnum = 1 @@ -173,7 +192,7 @@ endfunc func dist#ft#FTent() " This function checks for valid cl syntax in the first five lines. - " Look for either an opening comment, '#', or a block start, '{". + " Look for either an opening comment, '#', or a block start, '{'. " If not found, assume SGML. let lnum = 1 while lnum < 6 @@ -415,6 +434,36 @@ func dist#ft#FTmm() setf nroff endfunc +" Returns true if file content looks like LambdaProlog +func IsLProlog() + " skip apparent comments and blank lines, what looks like + " LambdaProlog comment may be RAPID header + let l = nextnonblank(1) + while l > 0 && l < line('$') && getline(l) =~ '^\s*%' " LambdaProlog comment + let l = nextnonblank(l + 1) + endwhile + " this pattern must not catch a go.mod file + return getline(l) =~ '\") =~ '\ 50 ? 50 : line("$") @@ -739,6 +800,14 @@ func dist#ft#FTperl() return 0 endfunc +func dist#ft#FTsys() + if IsRapid() + setf rapid + else + setf bat + endif +endfunc + " Choose context, plaintex, or tex (LaTeX) based on these rules: " 1. Check the first line of the file for "%&". " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. -- cgit