diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-03-06 19:39:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-06 19:39:49 +0800 |
commit | baccb569dc8508af5bea521bd27800c478883b29 (patch) | |
tree | 62e36e4e6ca58bc0e4d3d41139d8ad37903ff81e | |
parent | fa46441264b28e9272973ead7bea65f27868e94c (diff) | |
download | rneovim-baccb569dc8508af5bea521bd27800c478883b29.tar.gz rneovim-baccb569dc8508af5bea521bd27800c478883b29.tar.bz2 rneovim-baccb569dc8508af5bea521bd27800c478883b29.zip |
vim-patch:9.1.1173: filetype: ABNF files are not detected (#32751)
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: vim/vim#16802
https://github.com/vim/vim/commit/9f827ec58728c4ea55a8d71d40a283ca2ce5b058
Co-authored-by: A4-Tacks <wdsjxhno1001@163.com>
-rw-r--r-- | runtime/lua/vim/filetype.lua | 1 | ||||
-rw-r--r-- | runtime/syntax/abnf.vim | 33 | ||||
-rw-r--r-- | test/old/testdir/test_filetype.vim | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index c47ce5e761..930e2142e7 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -198,6 +198,7 @@ local extension = { abap = 'abap', abc = 'abc', abl = 'abel', + abnf = 'abnf', wrm = 'acedb', ads = 'ada', ada = 'ada', diff --git a/runtime/syntax/abnf.vim b/runtime/syntax/abnf.vim new file mode 100644 index 0000000000..13459eb9f8 --- /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 diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 37337d9b54..798a214769 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -88,6 +88,7 @@ func s:GetFilenameChecks() abort \ 'abap': ['file.abap'], \ 'abc': ['file.abc'], \ 'abel': ['file.abl'], + \ 'abnf': ['file.abnf'], \ 'acedb': ['file.wrm'], \ 'ada': ['file.adb', 'file.ads', 'file.ada', 'file.gpr'], \ 'ahdl': ['file.tdf'], |