patch 9.1.0401: filetype: zsh module files are not recognized

Problem:  filetype: zsh module files are not recognized
Solution: Detect '*.mdh' and '*.epro' as C filetype, '*.mdd' as zsh
          filetype, determine zsh-modules '*.pro' from from it's content
          (Wu, Zhenyu)

closes: #14737

Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Wu, Zhenyu
2024-05-09 20:35:13 +02:00
committed by Christian Brabandt
parent ce2ad9ffd7
commit 887a38cee7
4 changed files with 18 additions and 5 deletions

View File

@ -406,14 +406,18 @@ export def FTidl()
setf idl
enddef
# Distinguish between "default", Prolog and Cproto prototype file.
# Distinguish between "default", Prolog, zsh module's C and Cproto prototype file.
export def ProtoCheck(default: string)
# zsh modules use '#include "*.pro"'
# https://github.com/zsh-users/zsh/blob/63f086d167960a27ecdbcb762179e2c2bf8a29f5/Src/Modules/example.c#L31
if getline(1) =~ '/* Generated automatically */'
setf c
# Cproto files have a comment in the first line and a function prototype in
# the second line, it always ends in ";". Indent files may also have
# comments, thus we can't match comments to see the difference.
# IDL files can have a single ';' in the second line, require at least one
# chacter before the ';'.
if getline(2) =~ '.;$'
elseif getline(2) =~ '.;$'
setf cpp
else
# recognize Prolog by specific text in the first non-empty line