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 --- runtime/lua/vim/filetype.lua | 4 +-- runtime/lua/vim/filetype/detect.lua | 55 +++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 5 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 8cd5f19569..a83c74fd7c 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -341,7 +341,7 @@ local extension = { decl = detect.decl, dec = detect.decl, dcl = detect_seq(detect.decl, 'clean'), - def = 'def', + def = detect.def, desc = 'desc', directory = 'desktop', desktop = 'desktop', @@ -674,8 +674,6 @@ local extension = { mmp = 'mmp', mms = detect.mms, DEF = 'modula2', - m2 = 'modula2', - mi = 'modula2', lm3 = 'modula3', mojo = 'mojo', ['🔥'] = 'mojo', -- 🙄 diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index 6a14c73c92..ce3b873e40 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -419,6 +419,55 @@ function M.dtrace(_, bufnr) return 'd' end +--- @param bufnr integer +--- @return boolean +local function is_modula2(bufnr) + return matchregex(nextnonblank(bufnr, 1), [[\