From 91dc04a5e12a3d0c5be56768ded5971bc80e6f8e Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 16 Jan 2024 17:45:57 +0000 Subject: vim-patch:9.1.0013: Modula2 filetype support lacking (#27020) Problem: Modula2 filetype support lacking Solution: Improve the Modula-2 runtime support, add additional modula2 dialects, add compiler plugin, update syntax highlighting, include syntax tests, update Makefiles (Doug Kearns) closes: vim/vim#6796 closes: vim/vim#8115 https://github.com/vim/vim/commit/68a89470693c7687d4e736ca056c05de632e3ac7 - Luaify the detection script: - Split the `(*!m2foo*)` and `(*!m2foo+bar*)` detection into two Lua patterns, as Lua capture groups cannot be used with `?` and friends (as they only work on character classes). - Use `vim.api.nvim_buf_call()` (ew) to call `modula2#SetDialect()` to ensure `b:modula2` is set for the given bufnr. - Skip the syntax screendump tests. (A shame as they test some of the detection from `(*!m2foo+bar*)` tags, but I tested this locally and it seems to work) - Port the synmenu.vim changes from Vim9 script. (Also tested this locally) - (And also add the missing comma for `b:browsefilter` from earlier.) Co-authored-by: Doug Kearns --- test/old/testdir/test_filetype.vim | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 9f493bb792..50e60de484 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -424,7 +424,6 @@ func s:GetFilenameChecks() abort \ 'mma': ['file.nb'], \ 'mmp': ['file.mmp'], \ 'modconf': ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules', '/etc/modprobe.file', 'any/etc/conf.modules', 'any/etc/modprobe.file', 'any/etc/modules', 'any/etc/modules.conf'], - \ 'modula2': ['file.m2', 'file.mi'], \ 'modula3': ['file.m3', 'file.mg', 'file.i3', 'file.ig', 'file.lm3'], \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'], \ 'moo': ['file.moo'], @@ -1550,13 +1549,16 @@ func Test_mod_file() call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'modfile.MOD') split modfile.MOD call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) bwipe! " Modula-2 with comment and empty lines prior MODULE call writefile(['', '(* with', ' comment *)', '', 'MODULE Module2Mod;'], 'modfile.MOD') split modfile.MOD call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) bwipe! + call delete('modfile.MOD') " LambdaProlog module @@ -2284,4 +2286,38 @@ func Test_i_file() filetype off endfunc +func Test_def_file() + filetype on + + call writefile(['this is the fallback'], 'Xfile.def', 'D') + split Xfile.def + call assert_equal('def', &filetype) + bwipe! + + " Test dist#ft#FTdef() + + let g:filetype_def = 'modula2' + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + unlet g:filetype_def + + " Modula-2 + + call writefile(['(* a Modula-2 comment *)'], 'Xfile.def') + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + + call writefile(['IMPLEMENTATION MODULE Module2Mod;'], 'Xfile.def') + split Xfile.def + call assert_equal('modula2', &filetype) + call assert_equal('pim', b:modula2.dialect) + bwipe! + + filetype off +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit