From a31ccc3b1f65fd86780c03fec9c6e1bf56e30e35 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 25 Feb 2025 17:20:44 +0800 Subject: [PATCH] vim-patch:9.1.1140: filetype: m17ndb files are not detected (#32618) Problem: filetype: m17ndb files are not detected Solution: detect m17ndb files as m17ndb filetype, include filetype, syntax and indent files for the new filetype (David Mandelberg). References: https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html describes the format. https://git.savannah.nongnu.org/cgit/m17n/m17n-db.git/tree/ has examples of the files. closes: vim/vim#16696 https://github.com/vim/vim/commit/ed7d8e55ac232758fc14fd132994b4a09b19350b Also adjust the xkb parent pattern according to dev_vimpatch.txt. Co-authored-by: David Mandelberg --- runtime/ftplugin/m17ndb.vim | 17 ++++++++++++++++ runtime/indent/m17ndb.vim | 14 ++++++++++++++ runtime/lua/vim/filetype.lua | 31 +++++++++++++++++++++++++++++- runtime/syntax/m17ndb.vim | 28 +++++++++++++++++++++++++++ test/old/testdir/test_filetype.vim | 3 +++ 5 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 runtime/ftplugin/m17ndb.vim create mode 100644 runtime/indent/m17ndb.vim create mode 100644 runtime/syntax/m17ndb.vim diff --git a/runtime/ftplugin/m17ndb.vim b/runtime/ftplugin/m17ndb.vim new file mode 100644 index 0000000000..e4457cef9d --- /dev/null +++ b/runtime/ftplugin/m17ndb.vim @@ -0,0 +1,17 @@ +" Vim filetype plugin +" Language: m17n database +" Maintainer: David Mandelberg +" Last Change: 2025 Feb 21 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=:;;;,:;;,:; +setlocal commentstring=;\ %s +setlocal iskeyword=!-~,@,^34,^(,^),^92 +setlocal lisp +setlocal lispwords= + +let b:undo_ftplugin = "setlocal comments< commentstring< iskeyword< lisp< lispwords<" diff --git a/runtime/indent/m17ndb.vim b/runtime/indent/m17ndb.vim new file mode 100644 index 0000000000..d25aafe135 --- /dev/null +++ b/runtime/indent/m17ndb.vim @@ -0,0 +1,14 @@ +" Vim indent file +" Language: m17n database +" Maintainer: David Mandelberg +" Last Change: 2025 Feb 21 + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal nosmartindent + +let b:undo_indent = "setlocal autoindent< smartindent<" diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 66ee45587a..c47ce5e761 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -2325,13 +2325,42 @@ local pattern = { ['^Neomuttrc'] = detect_neomuttrc, ['%.neomuttdebug'] = 'neomuttlog', }, - ['/%.?xkb/'] = { + ['xkb/'] = { ['/%.?xkb/compat/'] = detect_xkb, ['/%.?xkb/geometry/'] = detect_xkb, ['/%.?xkb/keycodes/'] = detect_xkb, ['/%.?xkb/symbols/'] = detect_xkb, ['/%.?xkb/types/'] = detect_xkb, }, + ['m17n'] = { + ['/m17n/.*%.ali$'] = 'm17ndb', + ['/m17n/.*%.cs$'] = 'm17ndb', + ['/m17n/.*%.dir$'] = 'm17ndb', + ['/m17n/.*%.flt$'] = 'm17ndb', + ['/m17n/.*%.fst$'] = 'm17ndb', + ['/m17n/.*%.lnm$'] = 'm17ndb', + ['/m17n/.*%.mic$'] = 'm17ndb', + ['/m17n/.*%.mim$'] = 'm17ndb', + ['/m17n/.*%.tbl$'] = 'm17ndb', + ['/%.m17n%.d/.*%.ali$'] = 'm17ndb', + ['/%.m17n%.d/.*%.cs$'] = 'm17ndb', + ['/%.m17n%.d/.*%.dir$'] = 'm17ndb', + ['/%.m17n%.d/.*%.flt$'] = 'm17ndb', + ['/%.m17n%.d/.*%.fst$'] = 'm17ndb', + ['/%.m17n%.d/.*%.lnm$'] = 'm17ndb', + ['/%.m17n%.d/.*%.mic$'] = 'm17ndb', + ['/%.m17n%.d/.*%.mim$'] = 'm17ndb', + ['/%.m17n%.d/.*%.tbl$'] = 'm17ndb', + ['/m17n%-db/.*%.ali$'] = 'm17ndb', + ['/m17n%-db/.*%.cs$'] = 'm17ndb', + ['/m17n%-db/.*%.dir$'] = 'm17ndb', + ['/m17n%-db/.*%.flt$'] = 'm17ndb', + ['/m17n%-db/.*%.fst$'] = 'm17ndb', + ['/m17n%-db/.*%.lnm$'] = 'm17ndb', + ['/m17n%-db/.*%.mic$'] = 'm17ndb', + ['/m17n%-db/.*%.mim$'] = 'm17ndb', + ['/m17n%-db/.*%.tbl$'] = 'm17ndb', + }, ['^%.'] = { ['^%.cshrc'] = detect.csh, ['^%.login'] = detect.csh, diff --git a/runtime/syntax/m17ndb.vim b/runtime/syntax/m17ndb.vim new file mode 100644 index 0000000000..8d63e6f918 --- /dev/null +++ b/runtime/syntax/m17ndb.vim @@ -0,0 +1,28 @@ +" Vim syntax file +" Language: m17n database +" Maintainer: David Mandelberg +" Last Change: 2025 Feb 21 +" +" https://www.nongnu.org/m17n/manual-en/m17nDBFormat.html describes the +" syntax, but some of its regexes don't match the code. read_element() in +" https://git.savannah.nongnu.org/cgit/m17n/m17n-lib.git/tree/src/plist.c +" seems to be a better place to understand the syntax. + +if exists("b:current_syntax") + finish +endif +let b:current_syntax = "m17ndb" + +syn match m17ndbSymbol /\([^\x00- ()"\\]\|\\\_.\)\+/ +syn match m17ndbComment ";.*$" contains=@Spell +syn match m17ndbInteger "-\?[0-9]\+" +syn match m17ndbInteger "[0#]x[0-9A-Fa-f]\+" +syn match m17ndbCharacter "?\(\_[^\\]\|\\\_.\)" +syn region m17ndbText start=/\Z"/ skip=/\\\\\|\\"/ end=/"/ +syn region m17ndbPlist matchgroup=m17ndbParen start="(" end=")" fold contains=ALL + +hi def link m17ndbCharacter Character +hi def link m17ndbComment Comment +hi def link m17ndbInteger Number +hi def link m17ndbParen Delimiter +hi def link m17ndbText String diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index eb261077a3..37337d9b54 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -446,6 +446,9 @@ func s:GetFilenameChecks() abort \ 'luau': ['file.luau'], \ 'lynx': ['lynx.cfg'], \ 'lyrics': ['file.lrc'], + \ 'm17ndb': ['any/m17n/file.ali', 'any/m17n/file.cs', 'any/m17n/file.dir', 'any/m17n/file.flt', 'any/m17n/file.fst', 'any/m17n/file.lnm', 'any/m17n/file.mic', 'any/m17n/file.mim', 'any/m17n/file.tbl', + \ 'any/.m17n.d/file.ali', 'any/.m17n.d/file.cs', 'any/.m17n.d/file.dir', 'any/.m17n.d/file.flt', 'any/.m17n.d/file.fst', 'any/.m17n.d/file.lnm', 'any/.m17n.d/file.mic', 'any/.m17n.d/file.mim', 'any/.m17n.d/file.tbl', + \ 'any/m17n-db/file.ali', 'any/m17n-db/file.cs', 'any/m17n-db/file.dir', 'any/m17n-db/FLT/file.flt', 'any/m17n-db/file.fst', 'any/m17n-db/LANGDATA/file.lnm', 'any/m17n-db/file.mic', 'any/m17n-db/MIM/file.mim', 'any/m17n-db/file.tbl'], \ 'm3build': ['m3makefile', 'm3overrides'], \ 'm3quake': ['file.quake', 'cm3.cfg'], \ 'm4': ['file.at', '.m4_history'],