patch 9.1.0602: filetype: Prolog detection can be improved

Problem:  filetype: Prolog detection can be improved
Solution: update the prolog detection regex
          (igna_martinoli)

related: #10835
related: #15206
closes: #15253

Co-authored-by: clason <c.clason@uni-graz.at>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: igna_martinoli <ignamartinoli@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
igna_martinoli
2024-07-18 21:34:36 +02:00
committed by Christian Brabandt
parent eb6d733bef
commit 37853b7de3
4 changed files with 45 additions and 3 deletions

View File

@ -9,6 +9,8 @@ vim9script
# These functions are moved here from runtime/filetype.vim to make startup
# faster.
var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
export def Check_inp()
if getline(1) =~ '%%'
setf tex
@ -465,7 +467,7 @@ export def ProtoCheck(default: string)
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var lnum = getline(nextnonblank(1))
if lnum =~ '\<prolog\>' || lnum =~ '^\(:-\|%\|\/\*\)\|\.$'
if lnum =~ '\<prolog\>' || lnum =~ prolog_pattern
setf prolog
else
exe 'setf ' .. default
@ -644,7 +646,7 @@ export def FTpl()
# recognize Prolog by specific text in the first non-empty line
# require a blank after the '%' because Perl uses "%list" and "%translate"
var line = getline(nextnonblank(1))
if line =~ '\<prolog\>' || line =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || line =~ ':-'
if line =~ '\<prolog\>' || line =~ prolog_pattern
setf prolog
else
setf perl