mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
Merge pull request #29798 from zeertzjq/vim-9.1.0558
vim-patch:9.1.{0558,0602}
This commit is contained in:
@@ -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
|
||||
|
@@ -2576,4 +2576,69 @@ func Test_uci_file()
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
func Test_pro_file()
|
||||
filetype on
|
||||
|
||||
"Prolog
|
||||
call writefile([':-module(test/1,'], 'Xfile.pro', 'D')
|
||||
split Xfile.pro
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['% comment'], 'Xfile.pro', 'D')
|
||||
split Xfile.pro
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['/* multiline comment'], 'Xfile.pro', 'D')
|
||||
split Xfile.pro
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['rule(test, 1.7).'], 'Xfile.pro', 'D')
|
||||
split Xfile.pro
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
" IDL
|
||||
call writefile(['x = findgen(100)/10'], 'Xfile.pro', 'D')
|
||||
split Xfile.pro
|
||||
call assert_equal('idlang', &filetype)
|
||||
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
|
||||
func Test_pl_file()
|
||||
filetype on
|
||||
|
||||
"Prolog
|
||||
call writefile([':-module(test/1,'], 'Xfile.pl', 'D')
|
||||
split Xfile.pl
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['% comment'], 'Xfile.pl', 'D')
|
||||
split Xfile.pl
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['/* multiline comment'], 'Xfile.pl', 'D')
|
||||
split Xfile.pl
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['rule(test, 1.7).'], 'Xfile.pl', 'D')
|
||||
split Xfile.pl
|
||||
call assert_equal('prolog', &filetype)
|
||||
bwipe!
|
||||
|
||||
" Perl
|
||||
call writefile(['%data = (1, 2, 3);'], 'Xfile.pl', 'D')
|
||||
split Xfile.pl
|
||||
call assert_equal('perl', &filetype)
|
||||
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user