diff options
-rw-r--r-- | runtime/lua/vim/filetype.lua | 3 | ||||
-rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 14 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 4 |
3 files changed, 13 insertions, 8 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 1ea1bbccf6..4d3d219415 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -248,6 +248,8 @@ local extension = { bzl = 'bzl', bazel = 'bzl', BUILD = 'bzl', + mdh = 'c', + epro = 'c', qc = 'c', cabal = 'cabal', cairo = 'cairo', @@ -1206,6 +1208,7 @@ local extension = { zsh = 'zsh', zunit = 'zsh', ['zsh-theme'] = 'zsh', + mdd = 'zsh', vala = 'vala', web = detect.web, pl = detect.pl, diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 05b4ffc223..ba86d8de5a 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1141,12 +1141,14 @@ end --- Distinguish between "default", Prolog and Cproto prototype file. --- @type vim.filetype.mapfn function M.proto(_, bufnr) - -- 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 - -- character before the ';'. - if getline(bufnr, 2):find('.;$') then + if getline(bufnr, 2):find('/%* Generated automatically %*/') then + return 'c' + elseif getline(bufnr, 2):find('.;$') then + -- 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 + -- character before the ';'. return 'cpp' end -- Recognize Prolog by specific text in the first non-empty line; diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 3dd3db512a..1da97bb724 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -132,7 +132,7 @@ func s:GetFilenameChecks() abort \ 'bst': ['file.bst'], \ 'bzl': ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'], \ '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'], \ 'cabalconfig': ['cabal.config', expand("$HOME/.config/cabal/config")] + s:WhenConfigHome('$XDG_CONFIG_HOME/cabal/config'), \ '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', \ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history', \ '.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'], \ } |