patch 9.1.1173: filetype: ABNF files are not detected
Problem: filetype: ABNF files are not detected
Solution: detect '.abnf' file as abnf filetype and
include an abnf syntax plugin (A4-Tacks).
References:
- RFC5234
- RFC7405
closes: #16802
Signed-off-by: A4-Tacks <wdsjxhno1001@163.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index ff6905f..50c9f08 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2025 Feb 23
+" Last Change: 2025 Mar 05
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" Listen very carefully, I will say this only once
@@ -75,6 +75,9 @@
" ABEL
au BufNewFile,BufRead *.abl setf abel
+" ABNF
+au BufNewFile,BufRead *.abnf setf abnf
+
" AceDB
au BufNewFile,BufRead *.wrm setf acedb
diff --git a/runtime/syntax/abnf.vim b/runtime/syntax/abnf.vim
new file mode 100644
index 0000000..13459eb
--- /dev/null
+++ b/runtime/syntax/abnf.vim
@@ -0,0 +1,33 @@
+" Vim compiler file
+" Language: abnf
+" Maintainer: A4-Tacks <wdsjxhno1001@163.com>
+" Last Change: 2025 Mar 05
+" Upstream: https://github.com/A4-Tacks/abnf.vim
+
+" Implementing RFC-5234, RFC-7405
+
+if exists('b:current_syntax')
+ finish
+endif
+
+syn case ignore
+
+syn match abnfError /[<>"]/
+syn match abnfComment /;.*/
+syn match abnfOption /[[/\]]/
+syn region abnfString start=/\(%[si]\)\="/ end=/"/ oneline
+syn region abnfProse start=/</ end=/>/ oneline
+syn match abnfNumVal /\v\%b[01]+%(%(\.[01]+)+|-[01]+)=>/
+syn match abnfNumVal /\v\%d\d+%(%(\.\d+)+|-\d+)=>/
+syn match abnfNumVal /\v\%x[0-9a-f]+%(%(\.[0-9a-f]+)+|-[0-9a-f]+)=>/
+syn match abnfRepeat /\v%(%(<\d+)=\*\d*|<\d+ =)\ze[^ \t\r\n0-9*/)\]]/
+
+hi def link abnfError Error
+hi def link abnfComment Comment
+hi def link abnfOption PreProc
+hi def link abnfString String
+hi def link abnfProse String
+hi def link abnfNumVal Number
+hi def link abnfRepeat Repeat
+
+" vim:noet:ts=8:sts=8:nowrap