]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1360: filetype: GNU Radio companion files are not recognized v9.1.1360
authorzeertzjq <zeertzjq@outlook.com>
Fri, 2 May 2025 13:35:58 +0000 (15:35 +0200)
committerChristian Brabandt <cb@256bit.org>
Fri, 2 May 2025 13:35:58 +0000 (15:35 +0200)
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: #17241

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 209f0dc2e7a6188438725637ac997096907a495a..a6f13c8b887898c4c935550e65e5c540c6ce65c8 100644 (file)
@@ -1023,6 +1023,14 @@ au BufNewFile,BufRead *.gjs                      setf javascript.glimmer
 " Gnuplot scripts
 au BufNewFile,BufRead *.gpi,*.gnuplot,.gnuplot_history setf gnuplot
 
+" GNU Radio Companion files
+au BufNewFile,BufRead *.grc
+       \ if getline(1) =~# '<?xml' |
+       \   setf xml |
+       \ else |
+       \   setf yaml |
+       \ endif
+
 " Go (Google)
 au BufNewFile,BufRead *.go                     setf go
 au BufNewFile,BufRead Gopkg.lock               setf toml
index bfafdbb3616b4c86de128a1d0949eb435d19e2a5..7cac3d0aa2be02039e43476a13c297ec6a3bcce4 100644 (file)
@@ -1631,6 +1631,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'))
index d64a1e6c54d7dc6ef635130537d601c7d5e02382..c0c98b40ba225621aa4b88d389a0dab77daf06fb 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1360,
 /**/
     1359,
 /**/