diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-07-19 15:08:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-19 15:08:53 +0800 |
commit | d8aee77a4e74b0ac886fee1b29f719314051f39c (patch) | |
tree | ace5221035955d16ee50afe799f841201d8065a9 /runtime/lua/vim | |
parent | e54f503c44ed8a8d2892622577e6d2270b8f642b (diff) | |
parent | f67a7365afacfad3f05e7aaca0bb2538a6e9f125 (diff) | |
download | rneovim-d8aee77a4e74b0ac886fee1b29f719314051f39c.tar.gz rneovim-d8aee77a4e74b0ac886fee1b29f719314051f39c.tar.bz2 rneovim-d8aee77a4e74b0ac886fee1b29f719314051f39c.zip |
Merge pull request #29798 from zeertzjq/vim-9.1.0558
vim-patch:9.1.{0558,0602}
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/filetype/detect.lua | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 95e55ebb21..1fe7db0e1f 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -1116,6 +1116,8 @@ function M.perl(path, bufnr) end end +local prolog_patterns = { '^%s*:%-', '^%s*%%+%s', '^%s*%%+$', '^%s*/%*', '%.%s*$' } + --- @type vim.filetype.mapfn function M.pl(_, bufnr) if vim.g.filetype_pl then @@ -1124,11 +1126,7 @@ function M.pl(_, bufnr) -- Recognize Prolog by specific text in the first non-empty line; -- require a blank after the '%' because Perl uses "%list" and "%translate" local line = nextnonblank(bufnr, 1) - if - line and line:find(':%-') - or matchregex(line, [[\c\<prolog\>]]) - or findany(line, { '^%s*%%+%s', '^%s*%%+$', '^%s*/%*' }) - then + if line and matchregex(line, [[\c\<prolog\>]]) or findany(line, prolog_patterns) then return 'prolog' else return 'perl' @@ -1232,11 +1230,7 @@ function M.proto(_, bufnr) -- Recognize Prolog by specific text in the first non-empty line; -- require a blank after the '%' because Perl uses "%list" and "%translate" local line = nextnonblank(bufnr, 1) - if - line and line:find(':%-') - or matchregex(line, [[\c\<prolog\>]]) - or findany(line, { '^%s*%%+%s', '^%s*%%+$', '^%s*/%*' }) - then + if line and matchregex(line, [[\c\<prolog\>]]) or findany(line, prolog_patterns) then return 'prolog' end end |