aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-04-09 17:42:46 +0200
committerGitHub <noreply@github.com>2022-04-09 17:42:46 +0200
commit3280dc2b60db8d4e36bff6d481e3e873f32040b1 (patch)
tree4e27da77a7d757ef40810021fe67efe788e94157 /runtime/autoload
parentf3183a4d7c051e8062d28cfc9905b21e13bb7775 (diff)
downloadrneovim-3280dc2b60db8d4e36bff6d481e3e873f32040b1.tar.gz
rneovim-3280dc2b60db8d4e36bff6d481e3e873f32040b1.tar.bz2
rneovim-3280dc2b60db8d4e36bff6d481e3e873f32040b1.zip
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
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/dist/ft.vim71
1 files changed, 70 insertions, 1 deletions
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) =~ '\<module\s\+\w\+\s*\.\s*\(%\|$\)'
+endfunc
+
+" Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod
+func dist#ft#FTmod()
+ if exists("g:filetype_mod")
+ exe "setf " .. g:filetype_mod
+ elseif IsLProlog()
+ setf lprolog
+ elseif getline(nextnonblank(1)) =~ '\%(\<MODULE\s\+\w\+\s*;\|^\s*(\*\)'
+ setf modula2
+ elseif IsRapid()
+ setf rapid
+ elseif expand("<afile>") =~ '\<go.mod$'
+ setf gomod
+ else
+ " Nothing recognized, assume modsim3
+ setf modsim3
+ endif
+endfunc
+
func dist#ft#FTpl()
if exists("g:filetype_pl")
exe "setf " . g:filetype_pl
@@ -531,6 +580,18 @@ func dist#ft#FTpp()
endif
endfunc
+" Determine if *.prg is ABB RAPID. Can also be Clipper, FoxPro or eviews
+func dist#ft#FTprg()
+ if exists("g:filetype_prg")
+ exe "setf " .. g:filetype_prg
+ elseif IsRapid()
+ setf rapid
+ else
+ " Nothing recognized, assume Clipper
+ setf clipper
+ endif
+endfunc
+
func dist#ft#FTr()
let max = line("$") > 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 "%&<format>".
" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.