Skip to content

Commit 4e7b430

Browse files
dseomnchrisbra
authored andcommitted
patch 9.1.1231: filetype: SPA JSON files are not recognized
Problem: filetype: SPA (single page application) JSON files are not recognized (used by pipewire and wireplumber) Solution: detect pipewire and wireplumber configuration files as spajson filetype, include filetype, indent and syntax scripts for this new filetype (David Mandelberg). I looked at all the files found by this command to see if the syntax highlighting looked reasonable: ``` find {~/.config,/etc,/usr/share}/{pipewire,wireplumber} -type f -name \*.conf ``` References: * pipewire config files: https://docs.pipewire.org/page_config.html * wireplumber config files: https://pipewire.pages.freedesktop.org/wireplumber/daemon/configuration/conf_file.html and * https://pipewire.pages.freedesktop.org/wireplumber/daemon/locations.html closes: #16950 Signed-off-by: David Mandelberg <david@mandelberg.org> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 932a535 commit 4e7b430

7 files changed

Lines changed: 81 additions & 0 deletions

File tree

.github/MAINTAINERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ runtime/ftplugin/slint.vim @ribru17
285285
runtime/ftplugin/snakemake.vim @ribru17
286286
runtime/ftplugin/solidity.vim @cothi
287287
runtime/ftplugin/solution.vim @dkearns
288+
runtime/ftplugin/spajson.vim @dseomn
288289
runtime/ftplugin/spec.vim @ignatenkobrain
289290
runtime/ftplugin/squirrel.vim @ribru17
290291
runtime/ftplugin/ssa.vim @ObserverOfTime
@@ -396,6 +397,7 @@ runtime/indent/scheme.vim @evhan
396397
runtime/indent/scss.vim @tpope
397398
runtime/indent/sh.vim @chrisbra
398399
runtime/indent/solidity.vim @cothi
400+
runtime/indent/spajson.vim @dseomn
399401
runtime/indent/systemverilog.vim @Kocha
400402
runtime/indent/tcl.vim @dkearns
401403
runtime/indent/tcsh.vim @dkearns
@@ -609,6 +611,7 @@ runtime/syntax/sed.vim @dkearns
609611
runtime/syntax/shared/debversions.vim @jamessan
610612
runtime/syntax/shaderslang.vim @mTvare6
611613
runtime/syntax/solidity.vim @cothi
614+
runtime/syntax/spajson.vim @dseomn
612615
runtime/syntax/spec.vim @ignatenkobrain
613616
runtime/syntax/sqloracle.vim @chrisbra
614617
runtime/syntax/squirrel.vim @zenmatic

runtime/filetype.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,10 @@ au BufNewFile,BufRead *.class
25152515
" SMCL
25162516
au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl
25172517

2518+
" SPA JSON
2519+
au BufNewFile,BufRead */pipewire/*.conf setf spajson
2520+
au BufNewFile,BufRead */wireplumber/*.conf setf spajson
2521+
25182522
" Stored Procedures
25192523
au BufNewFile,BufRead *.stp setf stp
25202524

runtime/ftplugin/spajson.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
" Vim filetype plugin
2+
" Language: SPA JSON
3+
" Maintainer: David Mandelberg <david@mandelberg.org>
4+
" Last Change: 2025 Mar 22
5+
6+
if exists('b:did_ftplugin')
7+
finish
8+
endif
9+
let b:did_ftplugin = 1
10+
11+
setlocal comments=:###,:##,:#
12+
setlocal commentstring=#\ %s
13+
14+
let b:undo_ftplugin = "setlocal comments< commentstring<"

runtime/indent/spajson.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
" Vim indent file
2+
" Language: SPA JSON
3+
" Maintainer: David Mandelberg <david@mandelberg.org>
4+
" Last Change: 2025 Mar 22
5+
6+
runtime! indent/json.vim

runtime/syntax/spajson.vim

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
" Vim syntax file
2+
" Language: SPA JSON
3+
" Maintainer: David Mandelberg <david@mandelberg.org>
4+
" Last Change: 2025 Mar 22
5+
"
6+
" Based on parser code:
7+
" https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/include/spa/utils/json-core.h
8+
9+
if exists("b:current_syntax")
10+
finish
11+
endif
12+
let b:current_syntax = "spajson"
13+
14+
syn sync minlines=500
15+
16+
" Treat the __BARE parser state as a keyword, to make it easier to match
17+
" keywords and numbers only when they're not part of a larger __BARE section.
18+
" E.g., v4l2 and pipewire-0 probably shouldn't highlight anything as
19+
" spajsonInt.
20+
syn iskeyword 32-126,^ ,^",^#,^:,^,,^=,^],^},^\
21+
22+
syn match spajsonEscape "\\["\\/bfnrt]" contained
23+
syn match spajsonEscape "\\u[0-9A-Fa-f]\{4}" contained
24+
25+
syn match spajsonError "."
26+
syn match spajsonBare "\k\+"
27+
syn match spajsonComment "#.*$" contains=@Spell
28+
syn region spajsonString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=spajsonEscape
29+
syn match spajsonKeyDelimiter "[:=]"
30+
syn region spajsonArray matchgroup=spajsonBracket start="\[" end="]" contains=ALLBUT,spajsonKeyDelimiter fold
31+
syn region spajsonObject matchgroup=spajsonBrace start="{" end="}" contains=ALL fold
32+
syn match spajsonFloat "\<[+-]\?[0-9]\+\(\.[0-9]*\)\?\([Ee][+-]\?[0-9]\+\)\?\>"
33+
syn match spajsonFloat "\<[+-]\?\.[0-9]\+\([Ee][+-]\?[0-9]\+\)\?\>"
34+
syn match spajsonInt "\<[+-]\?0[Xx][0-9A-Fa-f]\+\>"
35+
syn match spajsonInt "\<[+-]\?[1-9][0-9]*\>"
36+
syn match spajsonInt "\<[+-]\?0[0-7]*\>"
37+
syn keyword spajsonBoolean true false
38+
syn keyword spajsonNull null
39+
syn match spajsonWhitespace "[\x00\t \r\n,]"
40+
41+
hi def link spajsonBoolean Boolean
42+
hi def link spajsonBrace Delimiter
43+
hi def link spajsonBracket Delimiter
44+
hi def link spajsonComment Comment
45+
hi def link spajsonError Error
46+
hi def link spajsonEscape SpecialChar
47+
hi def link spajsonFloat Float
48+
hi def link spajsonInt Number
49+
hi def link spajsonNull Constant
50+
hi def link spajsonString String

src/testdir/test_filetype.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,8 @@ def s:GetFilenameChecks(): dict<list<string>>
721721
snobol4: ['file.sno', 'file.spt'],
722722
solidity: ['file.sol'],
723723
solution: ['file.sln'],
724+
spajson: ['any/pipewire/file.conf', 'any/pipewire/file.conf.d/other.conf',
725+
'any/wireplumber/file.conf', 'any/wireplumber/file.conf.d/other.conf'],
724726
sparql: ['file.rq', 'file.sparql'],
725727
spec: ['file.spec'],
726728
spice: ['file.sp', 'file.spice'],

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1231,
707709
/**/
708710
1230,
709711
/**/

0 commit comments

Comments
 (0)