vim-patch:9.1.1360: filetype: GNU Radio companion files are not recognized

Problem:  filetype: GNU Radio companion files are not recognized
Solution: detect *.grc files as xml or yaml filetype depending on the
          first line (zeertzjq).

Ref:
- https://wiki.gnuradio.org/index.php/XML_GRC
- https://wiki.gnuradio.org/index.php/YAML_GRC

closes: vim/vim#17241

af4a5d6e2a
This commit is contained in:
zeertzjq
2025-05-02 21:50:17 +08:00
parent 074a6abd55
commit da3eeb4b32
2 changed files with 17 additions and 0 deletions

View File

@@ -1390,6 +1390,7 @@ local extension = {
yaml = 'yaml',
eyaml = 'yaml',
mplstyle = 'yaml',
grc = detect_line1('<%?xml', 'xml', 'yaml'),
yang = 'yang',
yuck = 'yuck',
z8a = 'z8a',

View File

@@ -1597,6 +1597,22 @@ func Test_git_file()
filetype off
endfunc
func Test_grc_file()
filetype on
call writefile(['<?xml version="1.0"?>', '<block>', '</block>'], 'Xfile.grc')
split Xfile.grc
call assert_equal('xml', &filetype)
bwipe!
call writefile(['metadata:', ' file_format: 1'], 'Xfile.grc')
split Xfile.grc
call assert_equal('yaml', &filetype)
bwipe!
filetype off
endfunc
func Test_haredoc_file()
filetype on
call assert_true(mkdir('foo/bar', 'pR'))