mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:ef387c062bb1 (#27553)
runtime(filetype): Modula-2 files with priority not detected (vim/vim#14055)
Problem: Modula-2 files with a specified priority are not detected.
Solution: Match the priority syntax in module header lines when
performing heuristic content detection.
Disable the :defcompile debug line. This was accidentally left enabled
in commit 68a8947.
ef387c062b
Co-authored-by: dkearns <dougkearns@gmail.com>
This commit is contained in:
parent
5e4a5f1aaa
commit
f25c0c1eb9
@ -422,7 +422,7 @@ end
|
|||||||
--- @param bufnr integer
|
--- @param bufnr integer
|
||||||
--- @return boolean
|
--- @return boolean
|
||||||
local function is_modula2(bufnr)
|
local function is_modula2(bufnr)
|
||||||
return matchregex(nextnonblank(bufnr, 1), [[\<MODULE\s\+\w\+\s*;\|^\s*(\*]])
|
return matchregex(nextnonblank(bufnr, 1), [[\<MODULE\s\+\w\+\s*\%(\[.*]\s*\)\=;\|^\s*(\*]])
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param bufnr integer
|
--- @param bufnr integer
|
||||||
|
@ -1511,82 +1511,89 @@ func Test_mod_file()
|
|||||||
filetype on
|
filetype on
|
||||||
|
|
||||||
" *.mod defaults to Modsim III
|
" *.mod defaults to Modsim III
|
||||||
call writefile(['locks like Modsim III'], 'modfile.mod')
|
call writefile(['locks like Modsim III'], 'Xfile.mod', 'D')
|
||||||
split modfile.mod
|
split Xfile.mod
|
||||||
call assert_equal('modsim3', &filetype)
|
call assert_equal('modsim3', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
" Users preference set by g:filetype_mod
|
" Users preference set by g:filetype_mod
|
||||||
let g:filetype_mod = 'lprolog'
|
let g:filetype_mod = 'lprolog'
|
||||||
split modfile.mod
|
split Xfile.mod
|
||||||
call assert_equal('lprolog', &filetype)
|
call assert_equal('lprolog', &filetype)
|
||||||
unlet g:filetype_mod
|
unlet g:filetype_mod
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
" LambdaProlog module
|
||||||
|
call writefile(['module lpromod.'], 'Xfile.mod')
|
||||||
|
split Xfile.mod
|
||||||
|
call assert_equal('lprolog', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" LambdaProlog with comment and empty lines prior module
|
||||||
|
call writefile(['', '% with', '% comment', '', 'module lpromod.'], 'Xfile.mod')
|
||||||
|
split Xfile.mod
|
||||||
|
call assert_equal('lprolog', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
" RAPID header start with a line containing only "%%%",
|
" RAPID header start with a line containing only "%%%",
|
||||||
" but is not always present.
|
" but is not always present.
|
||||||
call writefile(['%%%'], 'modfile.mod')
|
call writefile(['%%%'], 'Xfile.mod')
|
||||||
split modfile.mod
|
split Xfile.mod
|
||||||
call assert_equal('rapid', &filetype)
|
call assert_equal('rapid', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('modfile.mod')
|
|
||||||
|
|
||||||
" RAPID supports umlauts in module names, leading spaces,
|
" RAPID supports umlauts in module names, leading spaces,
|
||||||
" the .mod extension is not case sensitive.
|
" the .mod extension is not case sensitive.
|
||||||
call writefile([' module ÜmlautModule'], 'modfile.Mod')
|
call writefile([' module ÜmlautModule'], 'Xfile.Mod', 'D')
|
||||||
split modfile.Mod
|
split Xfile.Mod
|
||||||
call assert_equal('rapid', &filetype)
|
call assert_equal('rapid', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('modfile.Mod')
|
|
||||||
|
|
||||||
" RAPID is not case sensitive, embedded spaces, sysmodule,
|
" RAPID is not case sensitive, embedded spaces, sysmodule,
|
||||||
" file starts with empty line(s).
|
" file starts with empty line(s).
|
||||||
call writefile(['', 'MODULE rapidmödüle (SYSMODULE,NOSTEPIN)'], 'modfile.MOD')
|
call writefile(['', 'MODULE rapidmödüle (SYSMODULE,NOSTEPIN)'], 'Xfile.MOD', 'D')
|
||||||
split modfile.MOD
|
split Xfile.MOD
|
||||||
call assert_equal('rapid', &filetype)
|
call assert_equal('rapid', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
" Modula-2 MODULE not start of line
|
" Modula-2 MODULE not start of line
|
||||||
call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'modfile.MOD')
|
call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'Xfile.mod')
|
||||||
split modfile.MOD
|
split Xfile.mod
|
||||||
call assert_equal('modula2', &filetype)
|
call assert_equal('modula2', &filetype)
|
||||||
call assert_equal('pim', b:modula2.dialect)
|
call assert_equal('pim', b:modula2.dialect)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
" Modula-2 with comment and empty lines prior MODULE
|
" Modula-2 with comment and empty lines prior MODULE
|
||||||
call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'modfile.MOD')
|
call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'Xfile.mod')
|
||||||
split modfile.MOD
|
split Xfile.mod
|
||||||
call assert_equal('modula2', &filetype)
|
call assert_equal('modula2', &filetype)
|
||||||
call assert_equal('pim', b:modula2.dialect)
|
call assert_equal('pim', b:modula2.dialect)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
call delete('modfile.MOD')
|
" Modula-2 program MODULE with priorty (and uppercase extension)
|
||||||
|
call writefile(['MODULE Module2Mod [42];'], 'Xfile.MOD')
|
||||||
" LambdaProlog module
|
split Xfile.MOD
|
||||||
call writefile(['module lpromod.'], 'modfile.mod')
|
call assert_equal('modula2', &filetype)
|
||||||
split modfile.mod
|
call assert_equal('pim', b:modula2.dialect)
|
||||||
call assert_equal('lprolog', &filetype)
|
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
" LambdaProlog with comment and empty lines prior module
|
" Modula-2 implementation MODULE with priorty (and uppercase extension)
|
||||||
call writefile(['', '% with', '% comment', '', 'module lpromod.'], 'modfile.mod')
|
call writefile(['IMPLEMENTATION MODULE Module2Mod [42];'], 'Xfile.MOD')
|
||||||
split modfile.mod
|
split Xfile.MOD
|
||||||
call assert_equal('lprolog', &filetype)
|
call assert_equal('modula2', &filetype)
|
||||||
|
call assert_equal('pim', b:modula2.dialect)
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('modfile.mod')
|
|
||||||
|
|
||||||
" go.mod
|
" go.mod
|
||||||
call writefile(['module example.com/M'], 'go.mod')
|
call writefile(['module example.com/M'], 'go.mod', 'D')
|
||||||
split go.mod
|
split go.mod
|
||||||
call assert_equal('gomod', &filetype)
|
call assert_equal('gomod', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('go.mod')
|
|
||||||
|
|
||||||
call writefile(['module M'], 'go.mod')
|
call writefile(['module M'], 'go.mod')
|
||||||
split go.mod
|
split go.mod
|
||||||
call assert_equal('gomod', &filetype)
|
call assert_equal('gomod', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('go.mod')
|
|
||||||
|
|
||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
Loading…
Reference in New Issue
Block a user