vim-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: vim/vim#14737

887a38cee7

Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
This commit is contained in:
Christian Clason
2024-05-10 18:30:15 +02:00
parent 8c7a8be274
commit a9fd17e232
3 changed files with 13 additions and 8 deletions

View File

@@ -248,6 +248,8 @@ local extension = {
bzl = 'bzl', bzl = 'bzl',
bazel = 'bzl', bazel = 'bzl',
BUILD = 'bzl', BUILD = 'bzl',
mdh = 'c',
epro = 'c',
qc = 'c', qc = 'c',
cabal = 'cabal', cabal = 'cabal',
cairo = 'cairo', cairo = 'cairo',
@@ -1206,6 +1208,7 @@ local extension = {
zsh = 'zsh', zsh = 'zsh',
zunit = 'zsh', zunit = 'zsh',
['zsh-theme'] = 'zsh', ['zsh-theme'] = 'zsh',
mdd = 'zsh',
vala = 'vala', vala = 'vala',
web = detect.web, web = detect.web,
pl = detect.pl, pl = detect.pl,

View File

@@ -1141,12 +1141,14 @@ end
--- Distinguish between "default", Prolog and Cproto prototype file. --- Distinguish between "default", Prolog and Cproto prototype file.
--- @type vim.filetype.mapfn --- @type vim.filetype.mapfn
function M.proto(_, bufnr) function M.proto(_, bufnr)
-- Cproto files have a comment in the first line and a function prototype in if getline(bufnr, 2):find('/%* Generated automatically %*/') then
-- the second line, it always ends in ";". Indent files may also have return 'c'
-- comments, thus we can't match comments to see the difference. elseif getline(bufnr, 2):find('.;$') then
-- IDL files can have a single ';' in the second line, require at least one -- Cproto files have a comment in the first line and a function prototype in
-- character before the ';'. -- the second line, it always ends in ";". Indent files may also have
if getline(bufnr, 2):find('.;$') then -- 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
-- character before the ';'.
return 'cpp' return 'cpp'
end end
-- Recognize Prolog by specific text in the first non-empty line; -- Recognize Prolog by specific text in the first non-empty line;

View File

@@ -132,7 +132,7 @@ func s:GetFilenameChecks() abort
\ 'bst': ['file.bst'], \ 'bst': ['file.bst'],
\ 'bzl': ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'], \ 'bzl': ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'],
\ 'bzr': ['bzr_log.any', 'bzr_log.file'], \ 'bzr': ['bzr_log.any', 'bzr_log.file'],
\ 'c': ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg'], \ 'c': ['enlightenment/file.cfg', 'file.qc', 'file.c', 'some-enlightenment/file.cfg', 'file.mdh', 'file.epro'],
\ 'cabal': ['file.cabal'], \ 'cabal': ['file.cabal'],
\ 'cabalconfig': ['cabal.config', expand("$HOME/.config/cabal/config")] + s:WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'), \ 'cabalconfig': ['cabal.config', expand("$HOME/.config/cabal/config")] + s:WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'),
\ 'cabalproject': ['cabal.project', 'cabal.project.local'], \ 'cabalproject': ['cabal.project', 'cabal.project.local'],
@@ -856,7 +856,7 @@ func s:GetFilenameChecks() abort
\ 'zsh': ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', 'file.zsh-theme', 'file.zunit', \ 'zsh': ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', 'file.zsh-theme', 'file.zunit',
\ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history', \ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history',
\ '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file', \ '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file',
\ 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'], \ 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file', 'file.mdd'],
\ \
\ 'help': [$VIMRUNTIME .. '/doc/help.txt'], \ 'help': [$VIMRUNTIME .. '/doc/help.txt'],
\ } \ }